Repository navigation
chore(build): Compile with a JDK 21 toolchain and upgrade Mockito and Error Prone #6242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
markushi
wants to merge
13
commits into
main
Choose a base branch
from
build/jdk-21
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
01efed6
build: Switch to JDK 21 and upgrade Mockito, Robolectric and Error Prone
markushi 8ff189d
build: Compile tests for JDK 21 and fix buildSrc JVM target
markushi 3dc76c0
build: Compile with a JDK 21 toolchain from a build-logic convention โฆ
markushi 26b8a60
docs(kafka): Explain the explicit double cast at the latency call site
markushi 9788085
build: Compile the samples and their tests with the toolchain JDK
markushi f6de52d
Format code
getsentry-bot 6e81176
build: Drop the now-unused JvmTarget imports from the samples
markushi 1c7fbf3
build: Clarify the jvm-targets plugin comments and rename its helper
markushi 5c8907d
Merge branch 'build/jdk-21' of github.com:getsentry/sentry-java into โฆ
markushi 7bd342c
build: Require JDK 21 to run Gradle again
markushi 37b01cf
build: Keep the Spring Boot 2 sample apps on their published bytecodeโฆ
markushi d663f01
ci: Drop the stale Java version from the build job name
markushi 445f5e4
build: Keep Robolectric at 4.15 and leave its test environment untouched
markushi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
build-logic/src/main/kotlin/io.sentry.jvm-targets.gradle.kts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
| import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile | ||
|
|
||
| // Compilation and tests run on this JDK whatever JDK runs Gradle, so a contributor on a newer JDK | ||
| // gets the same output as CI. Error Prone 2.50 ships Java 21 bytecode and needs javac 21 as well. | ||
| // This picks the JDK only - every module pins the bytecode level it publishes itself. | ||
| val buildJdk = JavaLanguageVersion.of(21) | ||
|
|
||
| plugins.withType<JavaBasePlugin> { | ||
| extensions.configure<JavaPluginExtension> { toolchain { languageVersion.set(buildJdk) } } | ||
| } | ||
|
|
||
| /** | ||
| * Targets [buildJdk] in the compile tasks that [taskFilter] selects. Both languages move together, | ||
| * because the Kotlin plugin rejects a Java/Kotlin target mismatch. | ||
| */ | ||
| fun Project.applyToolchainToCompileTasks(taskFilter: (Task) -> Boolean) { | ||
| // AGP assigns these task properties while it creates the variants, so this has to run later. | ||
| afterEvaluate { | ||
| tasks.withType<JavaCompile>().matching(taskFilter).configureEach { | ||
| sourceCompatibility = buildJdk.toString() | ||
| targetCompatibility = buildJdk.toString() | ||
| } | ||
| tasks.withType<KotlinJvmCompile>().matching(taskFilter).configureEach { | ||
| compilerOptions.jvmTarget.set(JvmTarget.fromTarget(buildJdk.toString())) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| listOf("com.android.library", "com.android.application").forEach { pluginId -> | ||
| plugins.withId(pluginId) { | ||
| // Mockito 5 and mockito-kotlin 6 are built for Java 11, so test code (never published) can't | ||
| // share the Java 8 target of the published code. Other modules pin main compilation only, which | ||
| // leaves their test tasks on the toolchain; AGP has no such split, as compileOptions applies to | ||
| // every variant, so its unit tests need this. | ||
| applyToolchainToCompileTasks { it.name.contains("UnitTest") } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,7 @@ | ||
| import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
|
||
| plugins { | ||
| `kotlin-dsl` | ||
| } | ||
|
|
||
| repositories { | ||
| mavenCentral() | ||
| } | ||
|
|
||
| tasks.withType<KotlinCompile>().configureEach { | ||
|
markushi marked this conversation as resolved.
|
||
| compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.