Ensure that kapt configurations are not exposed for consumption
This commit is contained in:
+12
@@ -472,4 +472,16 @@ open class Kapt3IT : Kapt3BaseIT() {
|
|||||||
assertTasksExecuted(":app:kaptGenerateStubsKotlin", ":app:kaptKotlin")
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+4
-1
@@ -127,7 +127,10 @@ class Kapt3KotlinGradleSubplugin : KotlinGradleSubplugin<KotlinCompile> {
|
|||||||
val configurationName = Kapt3KotlinGradleSubplugin.getKaptConfigurationName(sourceSetName)
|
val configurationName = Kapt3KotlinGradleSubplugin.getKaptConfigurationName(sourceSetName)
|
||||||
|
|
||||||
project.configurations.findByName(configurationName)?.let { return it }
|
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) {
|
if (aptConfiguration.name != Kapt3KotlinGradleSubplugin.MAIN_KAPT_CONFIGURATION_NAME) {
|
||||||
// The main configuration can be created after the current one. We should handle this case
|
// The main configuration can be created after the current one. We should handle this case
|
||||||
|
|||||||
Reference in New Issue
Block a user