Skip to content

Commit 2de047f

Browse files
committed
build: Move the Java 8 release pin into the jvm-targets convention plugin
1 parent 445f5e4 commit 2de047f

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

‎build-logic/src/main/kotlin/io.sentry.jvm-targets.gradle.kts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,20 @@ listOf("com.android.library", "com.android.application").forEach { pluginId ->
3636
applyToolchainToCompileTasks { it.name.contains("UnitTest") }
3737
}
3838
}
39+
40+
// Published code targets Java 8. release compiles against that version's class library instead of
41+
// the build JDK's, so newer JDK APIs (e.g. List.getFirst()) can't leak into published bytecode.
42+
// Modules that publish a higher level override this; test code and samples are never published and
43+
// follow the toolchain.
44+
// Keep this in sync with the publication filter in the root build script.
45+
val isPublished =
46+
!name.contains("sample") &&
47+
!name.contains("integration-tests") &&
48+
name != "sentry-system-test-support" &&
49+
name != "sentry-test-support"
50+
51+
if (isPublished) {
52+
plugins.withId("java-library") {
53+
tasks.named<JavaCompile>("compileJava") { options.release.set(8) }
54+
}
55+
}

‎build.gradle.kts‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,19 +168,12 @@ subprojects {
168168
configure<JavaPluginExtension> {
169169
withJavadocJar()
170170
}
171-
172-
// Published code targets Java 8. release compiles against that version's class library
173-
// instead of the build JDK's, so newer JDK APIs (e.g. List.getFirst()) can't leak into
174-
// published bytecode. Modules that publish a higher level override this; test code is
175-
// never published and follows the toolchain.
176-
tasks.named<JavaCompile>("compileJava") {
177-
options.release.set(8)
178-
}
179171
}
180172

181173
// AGP 9 defaults Android modules to Java 11. Pin the published library modules back
182174
// to Java 8 so their bytecode stays consumable by Java 8 projects, mirroring the
183-
// java-library pin above.
175+
// java-library pin in the io.sentry.jvm-targets plugin. AGP compiles against android.jar,
176+
// so it has no release equivalent.
184177
plugins.withId("com.android.library") {
185178
configure<com.android.build.gradle.BaseExtension> {
186179
compileOptions {

0 commit comments

Comments
 (0)