Skip to content

Commit 5e1994e

Browse files
gavlyukovskiyBreus
authored andcommitted
Reimplement multi-release jar support
Fixes #219
1 parent 562eb1e commit 5e1994e

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

build.gradle.kts

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ plugins {
88
alias(libs.plugins.nexus.publish)
99
alias(libs.plugins.jmh)
1010
alias(libs.plugins.errorprone)
11-
alias(libs.plugins.mrjar)
1211
`maven-publish`
1312
`java-library`
1413
signing
@@ -34,15 +33,19 @@ java {
3433
withSourcesJar()
3534
}
3635

37-
multiRelease {
38-
targetVersions(11, 17)
36+
val java17: SourceSet by sourceSets.creating {
37+
java.srcDir("src/main/java17")
38+
}
39+
40+
val java17Implementation: Configuration by configurations.getting {
41+
extendsFrom(configurations.implementation.get())
3942
}
4043

4144
dependencies {
4245
testImplementation(platform(libs.junit.bom))
4346

47+
java17Implementation(sourceSets.main.get().output.classesDirs)
4448
api(libs.jspecify)
45-
"java17Implementation"(libs.jspecify)
4649

4750
testImplementation(libs.junit.platform.launcher)
4851
testImplementation(libs.assertj.core)
@@ -173,15 +176,25 @@ tasks {
173176
targetCompatibility = "11"
174177
}
175178

176-
compileTestJava {
177-
sourceCompatibility = "17"
178-
targetCompatibility = "17"
179-
}
180-
181179
test {
182180
useJUnitPlatform()
183181
}
184182

183+
jar {
184+
into("META-INF/versions/17") {
185+
from(java17.output)
186+
}
187+
manifest {
188+
attributes("Multi-Release" to "true")
189+
}
190+
}
191+
192+
named<Jar>("sourcesJar") {
193+
into("META-INF/versions/17") {
194+
from(java17.allSource)
195+
}
196+
}
197+
185198
withType<JavaCompile>().configureEach {
186199
options.errorprone {
187200
error(

gradle/libs.versions.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,3 @@ nexus-publish = { id = "io.github.gradle-nexus.publish-plugin", version = "2.0.0
2121
test-logger = { id = "com.adarshr.test-logger", version = "4.0.0" }
2222
sonarqube = { id = "org.sonarqube", version = "6.1.0.5360" }
2323
errorprone = { id = "net.ltgt.errorprone", version = "4.1.0" }
24-
mrjar = { id = "me.champeau.mrjar", version = "0.1.1" }

0 commit comments

Comments
 (0)