Skip to content

Commit 21e2b0d

Browse files
committed
Add full JPMS support
1 parent 1c244f6 commit 21e2b0d

11 files changed

Lines changed: 159 additions & 118 deletions

File tree

.github/workflows/build.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
os: [ ubuntu-18.04, ubuntu-20.04, windows-latest ]
20+
os: [ ubuntu-latest, windows-latest ]
2121
java: [ '8', '11', '17' ]
2222
arch: [ 'x86', 'x64' ]
2323
exclude:
24-
- os: ubuntu-18.04
25-
arch: x86
26-
- os: ubuntu-20.04
24+
- os: ubuntu-latest
2725
arch: x86
2826

2927
name: Java ${{ matrix.java }}/${{ matrix.arch }}/${{ matrix.os }}
@@ -44,12 +42,12 @@ jobs:
4442
cache: maven
4543

4644
- name: Build with Maven
47-
if: "${{ !(matrix.arch == 'x64' && matrix.os == 'ubuntu-20.04' && matrix.java == '11') || github.event.pull_request.head.repo.full_name != 'dnsjava/dnsjava' }}"
45+
if: "${{ !(matrix.arch == 'x64' && matrix.os == 'ubuntu-latest' && matrix.java == '17') || github.event.pull_request.head.repo.full_name != 'dnsjava/dnsjava' }}"
4846
run: mvn verify -B -"Dgpg.skip"
4947

5048
# doesn't work with PRs from forks, see https://jira.sonarsource.com/browse/MMF-1371
5149
- name: Cache Sonar plugins
52-
if: "${{ (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/') || github.event.pull_request.head.repo.full_name == 'dnsjava/dnsjava') && matrix.arch == 'x64' && matrix.os == 'ubuntu-20.04' && matrix.java == '11' }}"
50+
if: "${{ (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/') || github.event.pull_request.head.repo.full_name == 'dnsjava/dnsjava') && matrix.arch == 'x64' && matrix.os == 'ubuntu-latest' && matrix.java == '17' }}"
5351
uses: actions/cache@v2
5452
with:
5553
path: ~/.sonar/cache
@@ -58,27 +56,29 @@ jobs:
5856
${{ runner.os }}-sonar
5957
6058
- name: Build with Maven and run Sonar
61-
if: "${{ (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/') || github.event.pull_request.head.repo.full_name == 'dnsjava/dnsjava') && matrix.arch == 'x64' && matrix.os == 'ubuntu-20.04' && matrix.java == '11' }}"
59+
if: "${{ (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/') || github.event.pull_request.head.repo.full_name == 'dnsjava/dnsjava') && matrix.arch == 'x64' && matrix.os == 'ubuntu-latest' && matrix.java == '17' }}"
6260
env:
6361
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6462
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
6563
run: mvn -B -"Dgpg.skip" verify jacoco:report org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
6664

6765
- name: Run codecovc
68-
if: "${{ matrix.arch == 'x64' && matrix.os == 'ubuntu-20.04' && matrix.java == '11' }}"
66+
if: "${{ matrix.arch == 'x64' && matrix.java == '17' }}"
6967
uses: codecov/codecov-action@v2
68+
with:
69+
flags: ${{matrix.os}},${{ matrix.java }}
7070

7171
release:
7272
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')
7373
needs: test
74-
runs-on: ubuntu-20.04
74+
runs-on: ubuntu-latest
7575
steps:
7676
- uses: actions/checkout@v2
7777

78-
- name: Set up JDK 8
78+
- name: Set up JDK 17
7979
uses: actions/setup-java@v2
8080
with:
81-
java-version: '8'
81+
java-version: '17'
8282
architecture: 'x64'
8383
distribution: temurin
8484
cache: maven

checkstyle/checkstyle-config.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@
99
<property name="headerFile" value="checkstyle/header.template.txt"/>
1010
<property name="fileExtensions" value="java"/>
1111
</module>
12+
<!-- Excludes all 'module-info.java' files, see https://github.com/checkstyle/checkstyle/issues/8240 -->
13+
<module name="BeforeExecutionExclusionFileFilter">
14+
<property name="fileNamePattern" value="module\-info\.java$"/>
15+
</module>
1216
</module>

pom.xml

Lines changed: 56 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,16 @@
4545

4646
<properties>
4747
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
48+
<build.jdk>17</build.jdk>
4849
<target.jdk>8</target.jdk>
4950

5051
<org.junit.version>5.8.2</org.junit.version>
51-
<mockito.version>4.1.0</mockito.version>
52-
<slf4j.version>1.7.32</slf4j.version>
52+
<mockito.version>4.2.0</mockito.version>
53+
<slf4j.version>1.7.33</slf4j.version>
5354
<lombok.version>1.18.22</lombok.version>
5455
<jna.version>5.9.0</jna.version>
5556
<bouncycastle.version>1.69</bouncycastle.version>
56-
<vertx.version>4.2.1</vertx.version>
57+
<vertx.version>4.2.2</vertx.version>
5758

5859
<sonar.projectKey>dnsjava_dnsjava</sonar.projectKey>
5960
<sonar.organization>dnsjava</sonar.organization>
@@ -89,9 +90,10 @@
8990
<plugin>
9091
<groupId>org.apache.maven.plugins</groupId>
9192
<artifactId>maven-compiler-plugin</artifactId>
92-
<version>3.8.1</version>
93+
<version>3.9.0</version>
9394
<configuration>
94-
<compilerArgument>-Xlint:unchecked</compilerArgument>
95+
<release>${build.jdk}</release>
96+
<compilerArgument>-Xlint:all</compilerArgument>
9597
<annotationProcessorPaths>
9698
<path>
9799
<groupId>org.projectlombok</groupId>
@@ -100,6 +102,32 @@
100102
</path>
101103
</annotationProcessorPaths>
102104
</configuration>
105+
<executions>
106+
<!-- Compile Java 9+ stuff -->
107+
<execution>
108+
<id>default-compile</id>
109+
<configuration>
110+
<release>${build.jdk}</release>
111+
<includes>
112+
<include>module-info.java</include>
113+
</includes>
114+
</configuration>
115+
</execution>
116+
117+
<!-- Compile everything else for Java 8 -->
118+
<execution>
119+
<id>base-compile</id>
120+
<goals>
121+
<goal>compile</goal>
122+
</goals>
123+
<configuration>
124+
<release>${target.jdk}</release>
125+
<excludes>
126+
<exclude>module-info.java</exclude>
127+
</excludes>
128+
</configuration>
129+
</execution>
130+
</executions>
103131
</plugin>
104132

105133
<plugin>
@@ -111,31 +139,38 @@
111139
<plugin>
112140
<groupId>org.apache.felix</groupId>
113141
<artifactId>maven-bundle-plugin</artifactId>
114-
<version>5.1.2</version>
142+
<version>5.1.4</version>
115143
<extensions>true</extensions>
116144
<configuration>
145+
<niceManifest>true</niceManifest>
146+
<excludeDependencies>lombok</excludeDependencies>
117147
<instructions>
118148
<Bundle-Name>dnsjava is an implementation of DNS in Java</Bundle-Name>
119149
<Bundle-SymbolicName>org.xbill.dns</Bundle-SymbolicName>
120-
<Automatic-Module-Name>org.dnsjava</Automatic-Module-Name>
150+
<Bundle-DocURL>https://javadoc.io/doc/dnsjava/dnsjava</Bundle-DocURL>
121151
<_noclassforname>true</_noclassforname>
152+
<_donotcopy>android|sun</_donotcopy>
153+
<_nouses>true</_nouses>
122154
<Export-Package>
155+
!org.xbill.DNS.spi,
123156
org.xbill.DNS.*
124157
</Export-Package>
158+
<Private-Package>!android.*,!sun.*,.</Private-Package>
125159
<Import-Package>
126160
!org.xbill.DNS*,
127161
!sun.*,
128162
!lombok,
129-
android.*;resolution:=optional,
163+
android.content;resolution:=optional,
164+
android.net;resolution:=optional,
130165
javax.naming.*;resolution:=optional,
131-
com.sun.jna.*;resolution:=optional,
166+
com.sun.jna.*;resolution:=optional;version="[5,6)",
132167
*
133168
</Import-Package>
134-
<Bundle-RequiredExecutionEnvironment>JavaSE-1.8</Bundle-RequiredExecutionEnvironment>
135169
<Bundle-License>
136170
BSD-3-Clause;link="https://raw.githubusercontent.com/dnsjava/dnsjava/master/LICENSE"
137171
</Bundle-License>
138-
<_removeheaders>Bnd-*, Tool, Require-Capability, Include-Resource</_removeheaders>
172+
<_removeheaders>Bnd-*, Tool, Require-Capability, Include-Resource, Private-Package</_removeheaders>
173+
<_snapshot>SNAPSHOT</_snapshot>
139174
<Include-Resource>
140175
{maven-resources},
141176
META-INF/LICENSE=LICENSE
@@ -161,7 +196,7 @@
161196
<plugin>
162197
<groupId>org.apache.maven.plugins</groupId>
163198
<artifactId>maven-surefire-plugin</artifactId>
164-
<version>2.22.2</version>
199+
<version>3.0.0-M5</version>
165200
<configuration>
166201
<includes>
167202
<!-- Override default config to include inner test classes -->
@@ -171,6 +206,10 @@
171206
<!-- Override default config to not exclude inner test classes -->
172207
<exclude/>
173208
</excludes>
209+
<argLine>
210+
${argLine} --add-opens java.base/sun.net.dns=ALL-UNNAMED
211+
</argLine>
212+
<useModulePath>false</useModulePath>
174213
</configuration>
175214
</plugin>
176215

@@ -212,6 +251,9 @@
212251
<breakBuildOnBinaryIncompatibleModifications>true</breakBuildOnBinaryIncompatibleModifications>
213252
<breakBuildOnSourceIncompatibleModifications>true</breakBuildOnSourceIncompatibleModifications>
214253
<excludes>
254+
<!-- Ignore classes that we need for compilation only -->
255+
<exclude>android</exclude>
256+
<exclude>sun</exclude>
215257
<!-- JDK9 removed the Nameservice SPI as per bug 8134577. -->
216258
<exclude>org.xbill.DNS.spi</exclude>
217259
<!-- internal API detected as public -->
@@ -255,6 +297,7 @@
255297
<plugin>
256298
<groupId>com.coveo</groupId>
257299
<artifactId>fmt-maven-plugin</artifactId>
300+
<!-- newer versions are broken on Java 16+, see https://github.com/google/google-java-format/issues/612 -->
258301
<version>2.9.1</version>
259302
<executions>
260303
<execution>
@@ -292,7 +335,7 @@
292335
<dependency>
293336
<groupId>com.puppycrawl.tools</groupId>
294337
<artifactId>checkstyle</artifactId>
295-
<version>9.2</version>
338+
<version>9.2.1</version>
296339
</dependency>
297340
</dependencies>
298341
</plugin>
@@ -368,12 +411,6 @@
368411
<version>${lombok.version}</version>
369412
<scope>provided</scope>
370413
</dependency>
371-
<dependency>
372-
<groupId>org.robolectric</groupId>
373-
<artifactId>android-all</artifactId>
374-
<version>12-robolectric-7732740</version>
375-
<scope>provided</scope>
376-
</dependency>
377414
<dependency>
378415
<groupId>net.java.dev.jna</groupId>
379416
<artifactId>jna</artifactId>
@@ -442,77 +479,6 @@
442479
</dependency>
443480
</dependencies>
444481

445-
<profiles>
446-
<profile>
447-
<id>java8</id>
448-
<activation>
449-
<jdk>[,9)</jdk>
450-
</activation>
451-
<build>
452-
<plugins>
453-
<plugin>
454-
<groupId>org.apache.maven.plugins</groupId>
455-
<artifactId>maven-compiler-plugin</artifactId>
456-
<configuration>
457-
<source>${target.jdk}</source>
458-
<target>${target.jdk}</target>
459-
</configuration>
460-
</plugin>
461-
</plugins>
462-
</build>
463-
</profile>
464-
465-
<profile>
466-
<!-- JDK9 removed the Nameservice SPI as per bug 8134577. There's no replacement. -->
467-
<id>no-spi-on-java9</id>
468-
<activation>
469-
<jdk>[9,)</jdk>
470-
</activation>
471-
472-
<build>
473-
<plugins>
474-
<plugin>
475-
<groupId>org.apache.maven.plugins</groupId>
476-
<artifactId>maven-compiler-plugin</artifactId>
477-
<configuration>
478-
<release>${target.jdk}</release>
479-
<excludes>
480-
<exclude>org/xbill/DNS/spi/**</exclude>
481-
</excludes>
482-
</configuration>
483-
</plugin>
484-
485-
<plugin>
486-
<groupId>org.apache.maven.plugins</groupId>
487-
<artifactId>maven-javadoc-plugin</artifactId>
488-
<configuration>
489-
<excludePackageNames>*.spi</excludePackageNames>
490-
</configuration>
491-
</plugin>
492-
493-
<plugin>
494-
<groupId>org.apache.maven.plugins</groupId>
495-
<artifactId>maven-surefire-plugin</artifactId>
496-
<configuration>
497-
<argLine>
498-
${argLine} --add-opens java.base/sun.net.dns=ALL-UNNAMED
499-
</argLine>
500-
</configuration>
501-
</plugin>
502-
</plugins>
503-
504-
<resources>
505-
<resource>
506-
<directory>src/main/resources</directory>
507-
<excludes>
508-
<exclude>META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor</exclude>
509-
</excludes>
510-
</resource>
511-
</resources>
512-
</build>
513-
</profile>
514-
</profiles>
515-
516482
<distributionManagement>
517483
<snapshotRepository>
518484
<id>ossrh</id>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
2+
package android.content;
3+
4+
public class Context {
5+
public <T> T getSystemService(Class<T> serviceClass) {
6+
throw new UnsupportedOperationException();
7+
}
8+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
2+
package android.net;
3+
4+
public class ConnectivityManager {
5+
public Network getActiveNetwork() {
6+
throw new UnsupportedOperationException();
7+
}
8+
9+
public LinkProperties getLinkProperties(Network network) {
10+
throw new UnsupportedOperationException();
11+
}
12+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
2+
package android.net;
3+
4+
import java.net.InetAddress;
5+
import java.util.List;
6+
7+
public class LinkProperties {
8+
public List<InetAddress> getDnsServers() {
9+
throw new UnsupportedOperationException();
10+
}
11+
12+
public String getDomains() {
13+
throw new UnsupportedOperationException();
14+
}
15+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
2+
package android.net;
3+
4+
public class Network {}

src/main/java/module-info.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
2+
module org.dnsjava {
3+
requires static lombok;
4+
requires static java.naming;
5+
requires static com.sun.jna;
6+
requires static com.sun.jna.platform;
7+
requires org.slf4j;
8+
9+
exports org.xbill.DNS;
10+
exports org.xbill.DNS.config;
11+
exports org.xbill.DNS.dnssec;
12+
exports org.xbill.DNS.hosts;
13+
exports org.xbill.DNS.lookup;
14+
exports org.xbill.DNS.tools;
15+
exports org.xbill.DNS.utils;
16+
}

0 commit comments

Comments
 (0)