diff --git a/lib/build.gradle b/lib/build.gradle index e1a4b4e7..2bb5c599 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -55,6 +55,10 @@ dependencies { testImplementation 'org.mockito:mockito-core:2.18.3' } +jacoco { + toolVersion = "0.8.7" +} + jacocoTestReport { reports { xml.enabled = true @@ -87,6 +91,48 @@ task compileModuleInfoJava(type: JavaCompile) { } } +compileTestJava { + options.compilerArgs = ['--release', "8"] +} + +def testJava8 = tasks.register('testJava8', Test) { + description = 'Runs unit tests on Java 8.' + group = 'verification' + + javaLauncher.set(javaToolchains.launcherFor { + languageVersion = JavaLanguageVersion.of(8) + }) + shouldRunAfter(tasks.named('test')) +} + +def testJava17 = tasks.register('testJava17', Test) { + description = 'Runs unit tests on Java 17.' + group = 'verification' + + javaLauncher.set(javaToolchains.launcherFor { + languageVersion = JavaLanguageVersion.of(17) + }) + shouldRunAfter(tasks.named('test')) + + //Following Tests are excluded in Java 17 since secp256k1 curve is disabled Java 15+ + filter { + excludeTestsMatching "*.jwt.ConcurrentVerifyTest.shouldPassECDSA256KVerificationWithJOSESignature" + excludeTestsMatching "*.jwt.JWTCreatorTest.shouldAddKeyIdIfAvailableFromECDSAKAlgorithms" + excludeTestsMatching "*.jwt.JWTCreatorTest.shouldNotOverwriteKeyIdIfAddedFromECDSAKAlgorithms" + excludeTestsMatching "*.jwt.JWTTest.shouldCreateAnEmptyECDSA256KSignedToken" + excludeTestsMatching "*.jwt.algorithms.ECDSAAlgorithmTest.shouldPassECDSA256KVerificationWithJOSESignature" + excludeTestsMatching "*.jwt.algorithms.ECDSAAlgorithmTest.shouldPassECDSA256KVerificationWithJOSESignatureWithBothKeys" + excludeTestsMatching "*.jwt.algorithms.ECDSAAlgorithmTest.shouldPassECDSA256KVerificationWithProvidedPublicKey" + excludeTestsMatching "*.jwt.ECDSABouncyCastleProviderTests.shouldPassECDSA256KVerificationWithJOSESignatureWithBothKeys" + excludeTestsMatching "*.jwt.ECDSABouncyCastleProviderTests.shouldPassECDSA256KVerificationWithProvidedPublicKey" + } +} + +tasks.named('check') { + dependsOn(testJava8) + dependsOn(testJava17) +} + jar { manifest.attributes('Multi-Release': 'true') }