Ensure that kapt configurations are not exposed for consumption

This commit is contained in:
Sergey Igushkin
2018-09-21 19:59:58 +03:00
parent 7c05f77cb7
commit 54988932a3
2 changed files with 16 additions and 1 deletions
@@ -472,4 +472,16 @@ open class Kapt3IT : Kapt3BaseIT() {
assertTasksExecuted(":app:kaptGenerateStubsKotlin", ":app:kaptKotlin")
}
}
@Test
fun testDependencyOnKaptModule() = with(Project("simpleProject")) {
setupWorkingDir()
val kaptProject = Project("simple", directoryPrefix = "kapt2").apply { setupWorkingDir() }
kaptProject.projectDir.copyRecursively(projectDir.resolve("simple"))
projectDir.resolve("settings.gradle").writeText("include 'simple'")
gradleBuildScript().appendText("\ndependencies { implementation project(':simple') }")
testResolveAllConfigurations()
}
}
@@ -127,7 +127,10 @@ class Kapt3KotlinGradleSubplugin : KotlinGradleSubplugin<KotlinCompile> {
val configurationName = Kapt3KotlinGradleSubplugin.getKaptConfigurationName(sourceSetName)
project.configurations.findByName(configurationName)?.let { return it }
val aptConfiguration = project.configurations.create(configurationName)
val aptConfiguration = project.configurations.create(configurationName).apply {
// Should not be available for consumption from other projects during variant-aware dependency resolution:
isCanBeConsumed = false
}
if (aptConfiguration.name != Kapt3KotlinGradleSubplugin.MAIN_KAPT_CONFIGURATION_NAME) {
// The main configuration can be created after the current one. We should handle this case