Fix Kapt configuration not resolving MPP deps to JVM variants, KT-31641
This commit is contained in:
+3
@@ -283,6 +283,8 @@ class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
|
|
||||||
private fun doTestJvmWithJava(testJavaSupportInJvmTargets: Boolean) =
|
private fun doTestJvmWithJava(testJavaSupportInJvmTargets: Boolean) =
|
||||||
with(Project("sample-lib", GradleVersionRequired.AtLeast("5.0"), "new-mpp-lib-and-app")) {
|
with(Project("sample-lib", GradleVersionRequired.AtLeast("5.0"), "new-mpp-lib-and-app")) {
|
||||||
|
embedProject(Project("sample-lib-gradle-kotlin-dsl", directoryPrefix = "new-mpp-lib-and-app"))
|
||||||
|
|
||||||
lateinit var classesWithoutJava: Set<String>
|
lateinit var classesWithoutJava: Set<String>
|
||||||
|
|
||||||
fun getFilePathsSet(inDirectory: String): Set<String> {
|
fun getFilePathsSet(inDirectory: String): Set<String> {
|
||||||
@@ -322,6 +324,7 @@ class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
dependencies {
|
dependencies {
|
||||||
jvm6MainImplementation("com.google.dagger:dagger:2.24")
|
jvm6MainImplementation("com.google.dagger:dagger:2.24")
|
||||||
kapt("com.google.dagger:dagger-compiler:2.24")
|
kapt("com.google.dagger:dagger-compiler:2.24")
|
||||||
|
kapt(project(":sample-lib-gradle-kotlin-dsl"))
|
||||||
}
|
}
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-1
@@ -62,7 +62,7 @@ class PluginsDslIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private const val MAVEN_LOCAL_URL_PLACEHOLDER = "<mavenLocalUrl>"
|
private const val MAVEN_LOCAL_URL_PLACEHOLDER = "<mavenLocalUrl>"
|
||||||
private const val PLUGIN_MARKER_VERSION_PLACEHOLDER = "<pluginMarkerVersion>"
|
internal const val PLUGIN_MARKER_VERSION_PLACEHOLDER = "<pluginMarkerVersion>"
|
||||||
|
|
||||||
internal fun BaseGradleIT.transformProjectWithPluginsDsl(
|
internal fun BaseGradleIT.transformProjectWithPluginsDsl(
|
||||||
projectName: String,
|
projectName: String,
|
||||||
|
|||||||
+12
-5
@@ -290,10 +290,17 @@ class VariantAwareDependenciesIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Project.embedProject(other: Project) {
|
}
|
||||||
setupWorkingDir()
|
|
||||||
other.setupWorkingDir()
|
internal fun BaseGradleIT.Project.embedProject(other: BaseGradleIT.Project) {
|
||||||
other.projectDir.copyRecursively(projectDir.resolve(other.projectName))
|
setupWorkingDir()
|
||||||
projectDir.resolve("settings.gradle").appendText("\ninclude '${other.projectName}'")
|
other.setupWorkingDir()
|
||||||
|
other.testCase.apply {
|
||||||
|
val gradleBuildScript = other.gradleBuildScript()
|
||||||
|
if (gradleBuildScript.extension == "kts") {
|
||||||
|
gradleBuildScript.modify { it.replace(".version(\"$PLUGIN_MARKER_VERSION_PLACEHOLDER\")", "") }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
other.projectDir.copyRecursively(projectDir.resolve(other.projectName))
|
||||||
|
projectDir.resolve("settings.gradle").appendText("\ninclude '${other.projectName}'")
|
||||||
}
|
}
|
||||||
+2
@@ -14,6 +14,7 @@ import org.gradle.api.Task
|
|||||||
import org.gradle.api.artifacts.Configuration
|
import org.gradle.api.artifacts.Configuration
|
||||||
import org.gradle.api.artifacts.Dependency
|
import org.gradle.api.artifacts.Dependency
|
||||||
import org.gradle.api.attributes.Attribute
|
import org.gradle.api.attributes.Attribute
|
||||||
|
import org.gradle.api.attributes.Usage
|
||||||
import org.gradle.api.tasks.SourceSet
|
import org.gradle.api.tasks.SourceSet
|
||||||
import org.gradle.api.tasks.TaskDependency
|
import org.gradle.api.tasks.TaskDependency
|
||||||
import org.gradle.api.tasks.compile.AbstractCompile
|
import org.gradle.api.tasks.compile.AbstractCompile
|
||||||
@@ -143,6 +144,7 @@ class Kapt3KotlinGradleSubplugin : KotlinGradleSubplugin<KotlinCompile> {
|
|||||||
val aptConfiguration = project.configurations.create(configurationName).apply {
|
val aptConfiguration = project.configurations.create(configurationName).apply {
|
||||||
// Should not be available for consumption from other projects during variant-aware dependency resolution:
|
// Should not be available for consumption from other projects during variant-aware dependency resolution:
|
||||||
isCanBeConsumed = false
|
isCanBeConsumed = false
|
||||||
|
attributes.attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage::class.java, Usage.JAVA_RUNTIME))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aptConfiguration.name != Kapt3KotlinGradleSubplugin.MAIN_KAPT_CONFIGURATION_NAME) {
|
if (aptConfiguration.name != Kapt3KotlinGradleSubplugin.MAIN_KAPT_CONFIGURATION_NAME) {
|
||||||
|
|||||||
Reference in New Issue
Block a user