Fix kapt class structure configuration not resolving MPP deps, KT-33105

This commit is contained in:
Sergey Igushkin
2019-09-02 21:29:08 +03:00
parent 3deff3b347
commit 032686ebe0
2 changed files with 12 additions and 1 deletions
@@ -325,10 +325,15 @@ class NewMultiplatformIT : BaseGradleIT() {
jvm6MainImplementation("com.google.dagger:dagger:2.24")
kapt("com.google.dagger:dagger-compiler:2.24")
kapt(project(":sample-lib-gradle-kotlin-dsl"))
// also check incremental Kapt class structure configurations, KT-33105
jvm6MainImplementation(project(":sample-lib-gradle-kotlin-dsl"))
}
""".trimIndent()
)
}
// also check incremental Kapt class structure configurations, KT-33105
projectDir.resolve("gradle.properties").appendText("\nkapt.incremental.apt=true")
// Check Kapt:
projectDir.resolve("src/jvm6Main/kotlin/Main.kt").appendText(
@@ -396,7 +396,13 @@ class Kapt3KotlinGradleSubplugin : KotlinGradleSubplugin<KotlinCompile> {
maybeRegisterTransform(project)
val classStructure = project.configurations.create("_classStructure${taskName}")
project.dependencies.add(classStructure.name, kotlinCompile.classpath)
// Wrap the `kotlinCompile.classpath` into a file collection, so that, if the classpath is represented by a configuration,
// the configuration is not extended (via extendsFrom, which normally happens when one configuration is _added_ into another)
// but is instead included as the (lazily) resolved files. This is needed because the class structure configuration doesn't have
// the attributes that are potentially needed to resolve dependencies on MPP modules, and the classpath configuration does.
project.dependencies.add(classStructure.name, project.files(project.provider { kotlinCompile.classpath }))
kaptTask.classpathStructure = classStructure.incoming.artifactView { viewConfig ->
viewConfig.attributes.attribute(artifactType, CLASS_STRUCTURE_ARTIFACT_TYPE)
}.files