1+ buildscript {
2+ repositories {
3+ jcenter()
4+ }
5+
6+ dependencies {
7+ // https://github.com/melix/japicmp-gradle-plugin/issues/36
8+ classpath ' com.google.guava:guava:31.1-jre'
9+ }
10+ }
111
212plugins {
313 id ' java'
414 id ' jacoco'
5- id ' com.auth0.gradle.oss-library.java'
615 id ' checkstyle'
16+ id ' me.champeau.gradle.japicmp' version ' 0.2.9'
717}
818
919sourceSets {
@@ -29,37 +39,69 @@ tasks.named("checkstyleJmh").configure({
2939 enabled = false
3040})
3141
32- logger. lifecycle(" Using version ${ version} for ${ group} .${ name} " )
42+ apply from : rootProject. file(' gradle/versioning.gradle' )
43+
44+ version = getVersionFromFile()
45+ group = GROUP
46+ logger. lifecycle(" Using version ${ version} for ${ name} group $group " )
3347
34- def signingKey = findProperty(' signingKey' )
35- def signingKeyPwd = findProperty(' signingPassword' )
48+ import me.champeau.gradle.japicmp.JapicmpTask
3649
37- oss {
38- name " java jwt"
39- repository " java-jwt"
40- organization " auth0"
41- description " Java implementation of JSON Web Token (JWT)"
42- baselineCompareVersion " 4.1.0"
43- skipAssertSigningConfiguration true
50+ project. afterEvaluate {
4451
45- developers {
46- auth0 {
47- displayName = " Auth0"
48- email = " oss@auth0.com"
52+ def versions = project. ext. testInJavaVersions
53+ for (pluginJavaTestVersion in versions) {
54+ def taskName = " testInJava-${ pluginJavaTestVersion} "
55+ tasks. register(taskName, Test ) {
56+ def versionToUse = taskName. split(" -" ). getAt(1 ) as Integer
57+ description = " Runs unit tests on Java version ${ versionToUse} ."
58+ project. logger. quiet(" Test will be running in ${ versionToUse} " )
59+ group = ' verification'
60+ javaLauncher. set(javaToolchains. launcherFor {
61+ languageVersion = JavaLanguageVersion . of(versionToUse)
62+ })
63+ shouldRunAfter(tasks. named(' test' ))
4964 }
50- lbalmaceda {
51- displayName = " Luciano Balmaceda"
52- email = " luciano.balmaceda@auth0.com"
65+ tasks. named(' check' ) {
66+ dependsOn(taskName)
5367 }
54- hzalaz {
55- displayName = " Hernan Zalazar"
56- email = " hernan@auth0.com"
68+ }
69+
70+ project. configure(project) {
71+ def baselineVersion = project. ext. baselineCompareVersion
72+ task(' apiDiff' , type : JapicmpTask , dependsOn : ' jar' ) {
73+ oldClasspath = files(getBaselineJar(project, baselineVersion))
74+ newClasspath = files(jar. archiveFile)
75+ onlyModified = true
76+ failOnModification = true
77+ ignoreMissingClasses = true
78+ htmlOutputFile = file(" $buildDir /reports/apiDiff/apiDiff.html" )
79+ txtOutputFile = file(" $buildDir /reports/apiDiff/apiDiff.txt" )
80+ doLast {
81+ project. logger. quiet(" Comparing against baseline version ${ baselineVersion} " )
82+ }
83+ }
84+ }
85+ }
86+
87+ private static File getBaselineJar (Project project , String baselineVersion ) {
88+ // Use detached configuration: https://github.com/square/okhttp/blob/master/build.gradle#L270
89+ def group = project. group
90+ try {
91+ def baseline = " ${ project.group} :${ project.name} :$baselineVersion "
92+ project. group = ' virtual_group_for_japicmp'
93+ def dependency = project. dependencies. create(baseline + " @jar" )
94+ return project. configurations. detachedConfiguration(dependency). files. find {
95+ it. name == " ${ project.name} -${ baselineVersion} .jar"
5796 }
97+ } finally {
98+ project. group = group
5899 }
59100}
60101
61- signing {
62- useInMemoryPgpKeys(signingKey, signingKeyPwd)
102+ ext {
103+ baselineCompareVersion = ' 4.1.0'
104+ testInJavaVersions = [8 , 11 , 17 , 21 ]
63105}
64106
65107java {
@@ -198,3 +240,4 @@ tasks.register('jmhHelp', JavaExec) {
198240 args ' -h'
199241}
200242
243+ apply from : rootProject. file(' gradle/maven-publish.gradle' )
0 commit comments