@@ -36,33 +36,43 @@ dependencies {
3636defaultTasks(" assemble" )
3737
3838// https://docs.gradle.org/current/userguide/compatibility.html
39- val javaVersion = " 1.8" // JvmTarget.JVM_1_6, default depends on kotlin release
40- val kotlinVersion = " 1.7"
4139tasks.apply {
4240
43- // // Kotlin
44- // compileKotlin {
45- // kotlinOptions {
46- // jvmTarget = javaVersion
47- // languageVersion = kotlinVersion
48- // }
49- // }
50- // compileTestKotlin {
51- // kotlinOptions {
52- // jvmTarget = javaVersion
53- // languageVersion = kotlinVersion
54- // }
55- // }
41+ // class files versions depend on Kotlin compiler (default is 1.8)
42+ // module.json includes "org.gradle.jvm.version" of jdk used by gradle
43+ // https://docs.gradle.org/8.5/userguide/variant_attributes.html#sub:jvm_default_attributes
44+ // for other projects using gradle this could cause issues like
45+ // "Incompatible because this component declares a component,
46+ // compatible with Java 21 and the consumer needed a component, compatible with Java 17"
47+ // Hence we explicitly set the Kotlin and Java version here
48+
49+ val javaVersion = " 1.8" // JvmTarget.JVM_1_6, default depends on kotlin release
50+ val kotlinVersion = " 1.7"
51+
52+ // Kotlin
53+ compileKotlin {
54+ kotlinOptions {
55+ jvmTarget = javaVersion
56+ languageVersion = kotlinVersion
57+ }
58+ }
59+ compileTestKotlin {
60+ kotlinOptions {
61+ jvmTarget = javaVersion
62+ languageVersion = kotlinVersion
63+ }
64+ }
65+
66+ // Java
67+ compileJava {
68+ sourceCompatibility = javaVersion
69+ targetCompatibility = javaVersion
70+ }
71+ compileTestJava {
72+ sourceCompatibility = javaVersion
73+ targetCompatibility = javaVersion
74+ }
5675
57- // Java
58- // compileJava {
59- // sourceCompatibility = javaVersion
60- // targetCompatibility = javaVersion
61- // }
62- // compileTestJava {
63- // sourceCompatibility = javaVersion
64- // targetCompatibility = javaVersion
65- // }
6676 jar {
6777 manifest {
6878 attributes(
@@ -113,8 +123,9 @@ publishing {
113123 // https://central.sonatype.org/publish/publish-portal-snapshots/#publishing-snapshot-releases-for-your-project
114124 // https://central.sonatype.com/repository/maven-snapshots/
115125 // https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/
126+ val isSNAPSHOT = version.toString().endsWith(" -SNAPSHOT" )
116127 url = uri(
117- if (version.toString().endsWith( " -SNAPSHOT " ) ) " https://central.sonatype.com/repository/maven-snapshots/"
128+ if (isSNAPSHOT ) " https://central.sonatype.com/repository/maven-snapshots/"
118129 else " https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/"
119130 )
120131 println (" > publish.url: $url " )
0 commit comments