Skip to content

Commit

Permalink
Add module system support
Browse files Browse the repository at this point in the history
  • Loading branch information
Xakep_SDK authored and lbalmaceda committed Jun 22, 2021
1 parent 5e94a2e commit 6c63469
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
34 changes: 30 additions & 4 deletions lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ oss {
def javaVersion = 8
java {
toolchain {
languageVersion = JavaLanguageVersion.of(javaVersion)
languageVersion = JavaLanguageVersion.of(11)
}
}

compileJava {
sourceCompatibility "$javaVersion"
targetCompatibility "$javaVersion"
exclude 'module-info.java'

options.compilerArgs = ['--release', "$javaVersion"]
}

// Use latest JDK for javadoc generation
Expand All @@ -51,7 +52,7 @@ tasks.withType(Javadoc).configureEach {

javadoc {
// Exclude internal implementation package from javadoc
excludes = ['com/auth0/jwt/impl']
excludes = ['com/auth0/jwt/impl', 'module-info.java']
// Specify Java version this project uses
// Otherwise would use version of javadoc toolchain by default which could
// cause compilation error mismatch between compileJava and javadoc creation
Expand Down Expand Up @@ -80,3 +81,28 @@ test {
exceptionFormat "short"
}
}

task compileModuleInfoJava(type: JavaCompile) {
classpath = files()
source = 'src/main/java/module-info.java'
destinationDir = compileJava.destinationDir
doLast {
def descriptor = new File(compileJava.destinationDir, 'module-info.class')
def dest = new File(compileJava.destinationDir, 'META-INF/versions/9')
ant.move file: descriptor, todir: dest
}

doFirst {
options.compilerArgs = [
'--release', '9',
'--module-path', compileJava.classpath.asPath
]
}
}

jar {
manifest.attributes('Multi-Release': 'true')
}

compileModuleInfoJava.dependsOn compileJava
classes.dependsOn compileModuleInfoJava
11 changes: 11 additions & 0 deletions lib/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module com.auth0.jwt {
// remove transitive in next major release
requires com.fasterxml.jackson.databind;
// remove in next major release
exports com.auth0.jwt.impl;

exports com.auth0.jwt;
exports com.auth0.jwt.algorithms;
exports com.auth0.jwt.exceptions;
exports com.auth0.jwt.interfaces;
}

0 comments on commit 6c63469

Please sign in to comment.