File tree Expand file tree Collapse file tree
src/main/kotlin/io/sentry/gradle Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,7 +4,6 @@ plugins {
44
55repositories {
66 gradlePluginPortal()
7- // AGP is only published to Google's repository.
87 google()
98}
109
Original file line number Diff line number Diff line change @@ -70,17 +70,19 @@ class SentryCompilationPlugin : Plugin<Project> {
7070 .toInt()
7171
7272 private fun Project.targetBuildJdkForUnitTests () {
73- // AGP assigns these task properties when it creates the compile tasks, as they can be
74- // variant aware, so right now there's no way around using afterEvaluate
73+ val unitTestTask = { task: Task -> task.name.contains(" UnitTest" ) }
74+ // jvmTarget is a Property, so this set wins over the AGP convention whenever it runs.
75+ tasks.withType(KotlinJvmCompile ::class .java).matching(unitTestTask).configureEach {
76+ compilerOptions.jvmTarget.set(JvmTarget .fromTarget(BUILD_JDK .toString()))
77+ }
78+ // source/targetCompatibility are plain fields, so the last write wins, and AGP writes its
79+ // compileOptions while it creates the compile tasks. Registering earlier - at apply time or
80+ // in onVariants - is silently overwritten, so right now there's no way around afterEvaluate.
7581 afterEvaluate {
76- val unitTestTask = { task: Task -> task.name.contains(" UnitTest" ) }
7782 tasks.withType(JavaCompile ::class .java).matching(unitTestTask).configureEach {
7883 sourceCompatibility = BUILD_JDK .toString()
7984 targetCompatibility = BUILD_JDK .toString()
8085 }
81- tasks.withType(KotlinJvmCompile ::class .java).matching(unitTestTask).configureEach {
82- compilerOptions.jvmTarget.set(JvmTarget .fromTarget(BUILD_JDK .toString()))
83- }
8486 }
8587 }
8688}
You can’t perform that action at this time.
0 commit comments