Create and configure Android compilations earlier (KT-29964)
As Android variants are created after the project is evaluated, the build script and plugins might have added some item handlers to the domain object containers which are yet to be filled. To ensure that those handlers see properly configured compilations and their tasks, we need to add a compilations to the container only after it has been properly configured. Also, the `forEachVariant` handler is already executed in `afterEvaluate`, and there seems to be no need to wrap our code working with variants in `afterEvaluate`. Issue #KT-29964 Fixed
This commit is contained in:
+2
@@ -21,6 +21,8 @@ class KotlinAndroid32GradleIT : KotlinAndroid3GradleIT(androidGradlePluginVersio
|
||||
build("assemble", "compileDebugUnitTestJavaWithJavac", "printCompilerPluginOptions") {
|
||||
assertSuccessful()
|
||||
|
||||
assertContains("KT-29964 OK") // Output from lib/build.gradle
|
||||
|
||||
assertTasksExecuted(
|
||||
":lib:compileDebugKotlinAndroidLib",
|
||||
":lib:compileReleaseKotlinAndroidLib",
|
||||
|
||||
+15
@@ -36,6 +36,21 @@ dependencies {
|
||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||
}
|
||||
|
||||
kotlin.targets.all {
|
||||
compilations.all {
|
||||
// KT-29964: check that Android compilations can be configured with an `all { ... }` handler:
|
||||
kotlinOptions {
|
||||
verbose = true
|
||||
}
|
||||
compileKotlinTask.doFirst {
|
||||
if (!compileKotlinTask.kotlinOptions.verbose) {
|
||||
throw new AssertionError("kotlinOptions were not configured properly")
|
||||
}
|
||||
println "KT-29964 OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kotlin {
|
||||
sourceSets {
|
||||
jvmLibMain {
|
||||
|
||||
Reference in New Issue
Block a user