Fix lint task in Android projects depending on MPP, KT-27170

This commit is contained in:
Sergey Igushkin
2019-09-04 19:15:47 +03:00
parent 032686ebe0
commit 3abb1b3f40
2 changed files with 33 additions and 0 deletions
@@ -324,6 +324,19 @@ open class KotlinAndroid32GradleIT : KotlinAndroid3GradleIT() {
}
}
@Test
fun testLintInAndroidProjectsDependingOnMppWithoutAndroid() = with(Project("AndroidProject")) {
embedProject(Project("sample-lib", directoryPrefix = "new-mpp-lib-and-app"))
gradleBuildScript("Lib").appendText(
"\ndependencies { implementation(project(':sample-lib')) }"
)
val lintTask = ":Lib:lintFlavor1Debug"
build(lintTask) {
assertSuccessful()
assertTasksExecuted(lintTask) // Check that the lint task ran successfully, KT-27170
}
}
@Test
fun testKaptUsingApOptionProvidersAsNestedInputOutput() = with(Project("AndroidProject")) {
setupWorkingDir()
@@ -20,6 +20,26 @@ class KotlinJvmTargetConfigurator(kotlinPluginVersion: String) :
KotlinOnlyTargetConfigurator<KotlinJvmCompilation, KotlinJvmTarget>(true, true, kotlinPluginVersion),
KotlinTargetWithTestsConfigurator<KotlinJvmTestRun, KotlinJvmTarget> {
override fun configurePlatformSpecificModel(target: KotlinJvmTarget) {
super<KotlinOnlyTargetConfigurator>.configurePlatformSpecificModel(target)
super<KotlinTargetWithTestsConfigurator>.configurePlatformSpecificModel(target)
// Create the configuration under the name 'compileClasspath', as Android lint tasks want it, KT-27170
target.project.whenEvaluated {
if (configurations.findByName("compileClasspath") == null) {
configurations.create("compileClasspath").apply {
isCanBeResolved = false
isCanBeConsumed = false
extendsFrom(
target.project.configurations.getByName(
target.compilations.getByName(KotlinCompilation.MAIN_COMPILATION_NAME).compileDependencyConfigurationName
)
)
}
}
}
}
override val testRunClass: Class<KotlinJvmTestRun>
get() = KotlinJvmTestRun::class.java