Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: robinst/autolink-java
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: autolink-0.11.0
Choose a base ref
...
head repository: robinst/autolink-java
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Loading
14 changes: 8 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -9,15 +9,16 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [9, 11, 17]
java: [11, 17, 21, 24]
steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'zulu'

- name: Build
run: mvn -B package
@@ -26,12 +27,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: 17
java-version: 24
distribution: 'zulu'

- name: Build with coverage
run: mvn -B -Pcoverage clean test jacoco:report
15 changes: 8 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -14,16 +14,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Maven Central repository
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
server-id: ossrh
server-username: MAVEN_USERNAME # env variable to use for username in release
server-password: MAVEN_PASSWORD # env variable to use for password in release
# See https://central.sonatype.org/publish/publish-portal-maven/
server-id: central
server-username: CENTRAL_USERNAME # env variable to use for username in release
server-password: CENTRAL_PASSWORD # env variable to use for password in release
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable to use for passphrase in release

@@ -37,6 +38,6 @@ jobs:
mvn -B -Dpassword=${{ secrets.GITHUB_TOKEN }} release:prepare
mvn -B release:perform
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.12.0] - 2025-06-04
### Added
- Include OSGi metadata in jar
### Changed
- Require at least Java 11

## [0.11.0] - 2023-02-27
### Changed
- Modular JAR: Require at least Java 9 and add a module descriptor (module-info),
@@ -81,6 +87,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Initial release!


[0.12.0]: https://github.com/robinst/autolink-java/compare/autolink-0.11.0...autolink-0.12.0
[0.11.0]: https://github.com/robinst/autolink-java/compare/autolink-0.10.1...autolink-0.11.0
[0.10.1]: https://github.com/robinst/autolink-java/compare/autolink-0.10.0...autolink-0.10.1
[0.10.0]: https://github.com/robinst/autolink-java/compare/autolink-0.9.0...autolink-0.10.0
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -32,19 +32,19 @@ Thanks to [Rinku](https://github.com/vmg/rinku) for the inspiration.
Usage
-----

This library is supported on Java 9 or later. It works on Android
This library is supported on Java 11 or later. It works on Android
(minimum API level 19). It has no external dependencies.

Maven coordinates
(see
[here](https://search.maven.org/artifact/org.nibor.autolink/autolink/0.10.1/jar)
[here](https://central.sonatype.com/artifact/org.nibor.autolink/autolink/0.12.0/overview)
for other build systems):

```xml
<dependency>
<groupId>org.nibor.autolink</groupId>
<artifactId>autolink</artifactId>
<version>0.10.1</version>
<version>0.12.0</version>
</dependency>
```

@@ -53,16 +53,17 @@ Extracting links:
```java
import org.nibor.autolink.*;

String input = "wow, so example: http://test.com";
LinkExtractor linkExtractor = LinkExtractor.builder()
.linkTypes(EnumSet.of(LinkType.URL, LinkType.WWW, LinkType.EMAIL))
var input = "two links: https://test.com and https://example.com";
var linkExtractor = LinkExtractor.builder()
.linkTypes(EnumSet.of(LinkType.URL)) // limit to URLs
.build();
Iterable<LinkSpan> links = linkExtractor.extractLinks(input);
LinkSpan link = links.iterator().next();
link.getType(); // LinkType.URL
link.getBeginIndex(); // 17
link.getEndIndex(); // 32
input.substring(link.getBeginIndex(), link.getEndIndex()); // "http://test.com"
var links = new ArrayList<>();
for (var span : linkExtractor.extractLinks(input)) {
var link = input.substring(span.getBeginIndex(), span.getEndIndex());
links.add(link);
}

links; // List.of("https://test.com", "https://example.com")
```

Note that by default all supported types of links are extracted. If
@@ -208,6 +209,6 @@ See CONTRIBUTING.md file.
License
-------

Copyright (c) 2015-2022 Robin Stocker and others, see Git history
Copyright (c) 2015, Robin Stocker and others, see Git history

MIT licensed, see LICENSE file.
90 changes: 61 additions & 29 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@

<groupId>org.nibor.autolink</groupId>
<artifactId>autolink</artifactId>
<version>0.11.0</version>
<version>0.12.1-SNAPSHOT</version>

<name>autolink-java</name>
<description>
@@ -20,9 +20,9 @@

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.13.0</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -34,20 +34,56 @@
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<!-- 6.0.0 requires Java 17+ (currently on Java 11) -->
<version>5.1.9</version>
<configuration>
<instructions>
<Import-Package>
!java
</Import-Package>
<Export-Package>
{local-packages}
</Export-Package>
</instructions>
</configuration>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<version>3.14.0</version>
<configuration>
<source>9</source>
<target>9</target>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>com.github.siom79.japicmp</groupId>
<artifactId>japicmp-maven-plugin</artifactId>
<version>0.15.7</version>
<version>0.23.1</version>
<configuration>
<oldVersion>
<dependency>
@@ -83,29 +119,33 @@
</execution>
</executions>
</plugin>
<!-- https://central.sonatype.org/publish/publish-portal-maven/ -->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.7.0</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
<stagingProgressTimeoutMinutes>10</stagingProgressTimeoutMinutes>
<publishingServerId>central</publishingServerId>
<autoPublish>true</autoPublish>
<waitUntil>published</waitUntil>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>3.0.0-M7</version>
<version>3.1.1</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<useReleaseProfile>false</useReleaseProfile>
<releaseProfiles>release</releaseProfiles>
<goals>deploy</goals>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
</plugin>
</plugins>
</build>

@@ -128,7 +168,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version>
<version>0.8.13</version>
<executions>
<execution>
<id>prepare-agent</id>
@@ -148,7 +188,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<version>3.3.1</version>
<executions>
<execution>
<id>attach-sources</id>
@@ -161,7 +201,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.4.1</version>
<version>3.11.2</version>
<executions>
<execution>
<id>attach-javadocs</id>
@@ -177,7 +217,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.0.1</version>
<version>3.2.7</version>
<executions>
<execution>
<id>sign-artifacts</id>
@@ -199,17 +239,9 @@
</profile>
</profiles>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

<developers>
<developer>
<name>Robin Stocker</name>
<email>robin@nibor.org</email>
<url>https://github.com/robinst/</url>
</developer>
</developers>
@@ -225,7 +257,7 @@
<connection>scm:git:git@github.com:robinst/autolink-java.git</connection>
<developerConnection>scm:git:https://github.com/robinst/autolink-java.git</developerConnection>
<url>https://github.com/robinst/autolink-java</url>
<tag>autolink-0.11.0</tag>
<tag>HEAD</tag>
</scm>

</project>
38 changes: 19 additions & 19 deletions src/test/java/org/nibor/autolink/AutolinkEmailTest.java
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
package org.nibor.autolink;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.Parameter;
import org.junit.jupiter.params.ParameterizedClass;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

import java.util.Arrays;
import java.util.EnumSet;
import java.util.Set;
import java.util.stream.Stream;

@RunWith(Parameterized.class)
import static org.junit.jupiter.params.provider.Arguments.arguments;

@ParameterizedClass
@MethodSource("data")
public class AutolinkEmailTest extends AutolinkTestCase {

@Parameters(name = "{2}")
public static Iterable<Object[]> data() {
return Arrays.asList(new Object[][]{
{LinkExtractor.builder().linkTypes(EnumSet.of(LinkType.EMAIL)).build(), true, "email"},
{LinkExtractor.builder().linkTypes(EnumSet.allOf(LinkType.class)).build(), true, "all"},
{LinkExtractor.builder().emailDomainMustHaveDot(false).build(), false, "all, single part domain"}
});
public static Stream<Arguments> data() {
return Stream.of(
arguments(EnumSet.of(LinkType.EMAIL), true),
arguments(EnumSet.allOf(LinkType.class), true),
arguments(EnumSet.allOf(LinkType.class), false)
);
}

@Parameter(0)
public LinkExtractor linkExtractor;
public Set<LinkType> linkTypes;

@Parameter(1)
public boolean domainMustHaveDot;

@Parameter(2)
public String description;

@Test
public void notLinked() {
assertNotLinked("");
@@ -136,7 +136,7 @@ public void replyLevel() {

@Override
protected LinkExtractor getLinkExtractor() {
return linkExtractor;
return LinkExtractor.builder().linkTypes(linkTypes).emailDomainMustHaveDot(domainMustHaveDot).build();
}

private void assertLinked(String input, String expected) {
Loading