8000 Add full JPMS support by ibauersachs · Pull Request #246 · dnsjava/dnsjava · GitHub
[go: up one dir, main page]

Skip to content

Add full JPMS support #246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add full JPMS support
  • Loading branch information
ibauersachs committed Jan 23, 2022
commit 21e2b0d69dba56450a82ccf00a4c182f1a085041
22 changes: 11 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-18.04, ubuntu-20.04, windows-latest ]
os: [ ubuntu-latest, windows-latest ]
java: [ '8', '11', '17' ]
arch: [ 'x86', 'x64' ]
exclude:
- os: ubuntu-18.04
arch: x86
- os: ubuntu-20.04
- os: ubuntu-latest
arch: x86

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

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

# doesn't work with PRs from forks, see https://jira.sonarsource.com/browse/MMF-1371
- name: Cache Sonar plugins
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' }}"
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' }}"
uses: actions/cache@v2
with:
path: ~/.sonar/cache
Expand All @@ -58,27 +56,29 @@ jobs:
${{ runner.os }}-sonar

- name: Build with Maven and run Sonar
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' }}"
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' }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B -"Dgpg.skip" verify jacoco:report org.sonarsource.scanner.maven:sonar-maven-plugin:sonar

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

release:
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')
needs: test
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up JDK 8
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '8'
java-version: '17'
architecture: 'x64'
distribution: temurin
cache: maven
Expand Down
4 changes: 4 additions & 0 deletions checkstyle/checkstyle-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@
<property name="headerFile" value="checkstyle/header.template.txt"/>
<property name="fileExtensions" value="java"/>
</module>
<!-- Excludes all 'module-info.java' files, see https://github.com/checkstyle/checkstyle/issues/8240 -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$"/>
</module>
</module>
146 changes: 56 additions & 90 deletions pom.xml
67E6
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<build.jdk>17</build.jdk>
<target.jdk>8</target.jdk>

<org.junit.version>5.8.2</org.junit.version>
<mockito.version>4.1.0</mockito.version>
<slf4j.version>1.7.32</slf4j.version>
<mockito.version>4.2.0</mockito.version>
<slf4j.version>1.7.33</slf4j.version>
<lombok.version>1.18.22</lombok.version>
<jna.version>5.9.0</jna.version>
<bouncycastle.version>1.69</bouncycastle.version>
<vertx.version>4.2.1</vertx.version>
<vertx.version>4.2.2</vertx.version>

<sonar.projectKey>dnsjava_dnsjava</sonar.projectKey>
<sonar.organization>dnsjava</sonar.organization>
Expand Down Expand Up @@ -89,9 +90,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.9.0</version>
<configuration>
<compilerArgument>-Xlint:unchecked</compilerArgument>
<release>${build.jdk}</release>
<compilerArgument>-Xlint:all</compilerArgument>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
Expand All @@ -100,6 +102,32 @@
</path>
</annotationProcessorPaths>
</configuration>
<executions>
<!-- Compile Java 9+ stuff -->
<execution>
<id>default-compile</id>
<configuration>
<release>${build.jdk}</release>
<includes>
<include>module-info.java</include>
</includes>
</configuration>
</execution>

<!-- Compile everything else for Java 8 -->
<execution>
<id>base-compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>${target.jdk}</release>
<excludes>
<exclude>module-info.java</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
Expand All @@ -111,31 +139,38 @@
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>5.1.2</version>
<version>5.1.4</version>
<extensions>true</extensions>
<configuration>
<niceManifest>true</niceManifest>
<excludeDependencies>lombok</excludeDependencies>
<instructions>
<Bundle-Name>dnsjava is an implementation of DNS in Java</Bundle-Name>
<Bundle-SymbolicName>org.xbill.dns</Bundle-SymbolicName>
<Automatic-Module-Name>org.dnsjava</Automatic-Module-Name>
<Bundle-DocURL>https://javadoc.io/doc/dnsjava/dnsjava</Bundle-DocURL>
<_noclassforname>true</_noclassforname>
<_donotcopy>android|sun</_donotcopy>
<_nouses>true</_nouses>
<Export-Package>
!org.xbill.DNS.spi,
org.xbill.DNS.*
</Export-Package>
<Private-Package>!android.*,!sun.*,.</Private-Package>
<Import-Package>
!org.xbill.DNS*,
!sun.*,
!lombok,
android.*;resolution:=optional,
android.content;resolution:=optional,
android.net;resolution:=optional,
javax.naming.*;resolution:=optional,
com.sun.jna.*;resolution:=optional,
com.sun.jna.*;resolution:=optional;version="[5,6)",
*
</Import-Package>
<Bundle-RequiredExecutionEnvironment>JavaSE-1.8</Bundle-RequiredExecutionEnvironment>
<Bundle-License>
BSD-3-Clause;link="https://raw.githubusercontent.com/dnsjava/dnsjava/master/LICENSE"
</Bundle-License>
<_removeheaders>Bnd-*, Tool, Require-Capability, Include-Resource</_removeheaders>
<_removeheaders>Bnd-*, Tool, Require-Capability, Include-Resource, Private-Package</_removeheaders>
<_snapshot>SNAPSHOT</_snapshot>
<Include-Resource>
{maven-resources},
META-INF/LICENSE=LICENSE
Expand All @@ -161,7 +196,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<version>3.0.0-M5</version>
<configuration>
<includes>
<!-- Override default config to include inner test classes -->
Expand All @@ -171,6 +206,10 @@
<!-- Override default config to not exclude inner test classes -->
<exclude/>
</excludes>
<argLine>
${argLine} --add-opens java.base/sun.net.dns=ALL-UNNAMED
</argLine>
<useModulePath>false</useModulePath>
</configuration>
</plugin>

Exp A3E2 and Down Expand Up @@ -212,6 +251,9 @@
<breakBuildOnBinaryIncompatibleModifications>true</breakBuildOnBinaryIncompatibleModifications>
<breakBuildOnSourceIncompatibleModifications>true</breakBuildOnSourceIncompatibleModifications>
<excludes>
<!-- Ignore classes that we need for compilation only -->
<exclude>android</exclude>
<exclude>sun</exclude>
<!-- JDK9 removed the Nameservice SPI as per bug 8134577. -->
<exclude>org.xbill.DNS.spi</exclude>
<!-- internal API detected as public -->
Expand Down Expand Up @@ -255,6 +297,7 @@
<plugin>
<groupId>com.coveo</groupId>
<artifactId>fmt-maven-plugin</artifactId>
<!-- newer versions are broken on Java 16+, see https://github.com/google/google-java-format/issues/612 -->
<version>2.9.1</version>
<executions>
<execution>
Expand Down Expand Up @@ -292,7 +335,7 @@
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>9.2</version>
<version>9.2.1</version>
</dependency>
</dependencies>
</plugin>
Expand Down Expand Up @@ -368,12 +411,6 @@
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.robolectric</groupId>
<artifactId>android-all</artifactId>
<version>12-robolectric-7732740</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
Expand Down Expand Up @@ -442,77 +479,6 @@
</dependency>
</dependencies>

<profiles>
<profile>
<id>java8</id>
<activation>
<jdk>[,9)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${target.jdk}</source>
<target>${target.jdk}</target>
</configuration>
</plugin>
</plugins>
</build>
</profile>

<profile>
<!-- JDK9 removed the Nameservice SPI as per bug 8134577. There's no replacement. -->
<id>no-spi-on-java9</id>
<activation>
<jdk>[9,)</jdk>
</activation>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<release>${target.jdk}</release>
<excludes>
<exclude>org/xbill/DNS/spi/**</exclude>
</excludes>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<excludePackageNames>*.spi</excludePackageNames>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>
${argLine} --add-opens java.base/sun.net.dns=ALL-UNNAMED
</argLine>
</configuration>
</plugin>
</plugins>

<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor</exclude>
</excludes>
</resource>
</resources>
</build>
</profile>
</profiles>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/android/content/Context.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: BSD-3-Clause
package android.content;

public class Context {
public <T> T getSystemService(Class<T> serviceClass) {
throw new UnsupportedOperationException();
}
}
12 changes: 12 additions & 0 deletions src/main/java/android/net/ConnectivityManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: BSD-3-Clause
package android.net;

public class ConnectivityManager {
public Network getActiveNetwork() {
throw new UnsupportedOperationException();
}

public LinkProperties getLinkProperties(Network network) {
throw new UnsupportedOperationException();
}
}
15 changes: 15 additions & 0 deletions src/main/java/android/net/LinkProperties.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: BSD-3-Clause
package android.net;

import java.net.InetAddress;
import java.util.List;

public class LinkProperties {
public List<InetAddress> getDnsServers() {
throw new UnsupportedOperationException();
}

public String getDomains() {
throw new UnsupportedOperationException();
}
}
4 changes: 4 additions & 0 deletions src/main/java/android/net/Network.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// SPDX-License-Identifier: BSD-3-Clause
package android.net;

public class Network {}
16 changes: 16 additions & 0 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: BSD-3-Clause
module org.dnsjava {
requires static lombok;
requires static java.naming;
requires static com.sun.jna;
requires static com.sun.jna.platform;
requires org.slf4j;

exports org.xbill.DNS;
exports org.xbill.DNS.config;
exports org.xbill.DNS.dnssec;
exports org.xbill.DNS.hosts;
exports org.xbill.DNS.lookup;
exports org.xbill.DNS.tools;
exports org.xbill.DNS.utils;
}
Loading
0