From 9cbbdec56ce87eb960e225659b16a4f2e4e9dd1b Mon Sep 17 00:00:00 2001 From: A248 Date: Wed, 7 Apr 2021 20:43:28 -0400 Subject: [PATCH] Build a multi-release jar to provide module-info for JDK 11 Update CI and CONTRIBUTING with JDK 11 requirement --- .github/workflows/build-and-test.yml | 27 ++++++++++--------- CONTRIBUTING.md | 5 +++- argon2-jvm-nolibs/build.gradle | 25 +++++++++++++++-- .../src/main/java11/module-info.java | 5 ++++ build.gradle | 4 +++ 5 files changed, 51 insertions(+), 15 deletions(-) create mode 100644 argon2-jvm-nolibs/src/main/java11/module-info.java diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 11931ca..7f7aef4 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -11,22 +11,23 @@ on: jobs: - buildon-linux: + build-on-linux: strategy: matrix: os: [ ubuntu-latest ] - # New gradle doesn't run on <= 8 - # Java >= 12 doesn't support source/target level 6 anymore - java: [ 8, 9, 10, 11 ] + # See CONTRIBUTING.md on JDK 11 build requirement + java: [ 11 ] architecture: [ x86, x64 ] + distribution: [ 'zulu', 'adopt' ] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v1 + uses: actions/setup-java@v2 with: java-version: ${{ matrix.java }} architecture: ${{ matrix.architecture }} + distribution: ${{ matrix.distribution }} - name: Cache Gradle packages uses: actions/cache@v2 with: @@ -41,19 +42,20 @@ jobs: strategy: matrix: os: [ macos-latest ] - # New gradle doesn't run on <= 8 - # Java >= 12 doesn't support source/target level 6 anymore - java: [ 8, 9, 10, 11 ] + # See CONTRIBUTING.md on JDK 11 build requirement + java: [ 11 ] # MacOS has no support for x86 ("Error: No valid download found for version 11.x and package jdk.") architecture: [ x64 ] + distribution: [ 'zulu', 'adopt' ] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v1 + uses: actions/setup-java@v2 with: java-version: ${{ matrix.java }} architecture: ${{ matrix.architecture }} + distribution: ${{ matrix.distribution }} - name: Cache Gradle packages uses: actions/cache@v2 with: @@ -68,10 +70,10 @@ jobs: strategy: matrix: os: [ windows-latest ] - # New gradle doesn't run on <= 8 - # Java >= 12 doesn't support source/target level 6 anymore - java: [ 8, 9, 10, 11 ] + # See CONTRIBUTING.md on JDK 11 build requirement + java: [ 11 ] architecture: [ x86, x64 ] + distribution: [ 'zulu', 'adopt' ] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 @@ -80,6 +82,7 @@ jobs: with: java-version: ${{ matrix.java }} architecture: ${{ matrix.architecture }} + distribution: ${{ matrix.distribution }} - name: Cache Gradle packages uses: actions/cache@v2 with: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 10a33fe..f00c749 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,7 @@ # Contributing Feel free to fork the project and create pull requests. Please use the `develop` branch for new features, -I like to keep the `master` branch stable. \ No newline at end of file +I like to keep the `master` branch stable. + +Note that JDK 11 is required to build. Older versions do not allow creating a Multi-Release JAR and +newer versions do not support `--release 6`. diff --git a/argon2-jvm-nolibs/build.gradle b/argon2-jvm-nolibs/build.gradle index a549f51..e9edca6 100644 --- a/argon2-jvm-nolibs/build.gradle +++ b/argon2-jvm-nolibs/build.gradle @@ -2,20 +2,41 @@ plugins { id 'org.sonarqube' version '3.0' } +sourceSets { + java11 { + java { + srcDirs = ['src/main/java', 'src/main/java11'] + } + } +} + jar { manifest { attributes( - 'Automatic-Module-Name': 'de.mkammerer.argon2.nolibs' + 'Automatic-Module-Name': 'de.mkammerer.argon2.nolibs', + 'Multi-Release': 'true' ) } + into('META-INF/versions/11') { + from sourceSets.java11.output + exclude('de/**') + } } dependencies { implementation 'net.java.dev.jna:jna:5.8.0' } +compileJava11Java { + sourceCompatibility = 11 + targetCompatibility = 11 + options.compilerArgs.addAll([ + '--release', '11', + '--module-path', sourceSets.main.compileClasspath.asPath]); +} + sonarqube { properties { property 'sonar.exclusions', 'src/main/java/de/mkammerer/argon2/jna/*.java' } -} \ No newline at end of file +} diff --git a/argon2-jvm-nolibs/src/main/java11/module-info.java b/argon2-jvm-nolibs/src/main/java11/module-info.java new file mode 100644 index 0000000..0c2a34f --- /dev/null +++ b/argon2-jvm-nolibs/src/main/java11/module-info.java @@ -0,0 +1,5 @@ +module de.mkammerer.argon2.nolibs { + exports de.mkammerer.argon2; + exports de.mkammerer.argon2.jna; + requires com.sun.jna; +} diff --git a/build.gradle b/build.gradle index a8cc8b3..5b296c2 100644 --- a/build.gradle +++ b/build.gradle @@ -15,6 +15,10 @@ subprojects { options.encoding = 'UTF-8' } + compileJava { + options.compilerArgs.addAll(['--release', '6']); + } + java { sourceCompatibility = JavaVersion.VERSION_1_6 targetCompatibility = JavaVersion.VERSION_1_6