Skip to content

Commit

Permalink
Build a multi-release jar to provide module-info for JDK 11
Browse files Browse the repository at this point in the history
  • Loading branch information
A248 committed Apr 8, 2021
1 parent 60b7cb1 commit 5bf61d8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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.
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`.
22 changes: 21 additions & 1 deletion argon2-jvm-nolibs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,38 @@ 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
}
}

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'
Expand Down
5 changes: 5 additions & 0 deletions argon2-jvm-nolibs/src/main/java11/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module de.mkammerer.argon2.nolibs {
exports de.mkammerer.argon2;
exports de.mkammerer.argon2.jna;
requires com.sun.jna;
}
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5bf61d8

Please sign in to comment.