Add the expectedBy dependency to the compile configuration

Enable its propagation through transitive dependencies (including
POMs generated by Gradle)

Issue #KT-22824 Fixed
This commit is contained in:
Sergey Igushkin
2018-02-20 15:35:16 +03:00
parent 3836dcab85
commit 5901c2163f
2 changed files with 25 additions and 0 deletions
@@ -201,4 +201,25 @@ class MultiplatformGradleIT : BaseGradleIT() {
assertTasksExecuted(listOf(":lib:compileKotlinCommon", ":libJvm:compileKotlin", ":libJs:compileKotlin2Js"))
}
}
@Test
fun testCommonModuleAsTransitiveDependency() = with(Project("multiplatformProject")) {
setupWorkingDir()
gradleBuildScript("libJvm").appendText("""
${'\n'}
task printCompileConfiguration(type: DefaultTask) {
doFirst {
configurations.compile.resolvedConfiguration.resolvedArtifacts.each {
println("Dependency: '" + it.name + "'")
}
}
}
""".trimIndent())
build("printCompileConfiguration") {
assertSuccessful()
// Check that `lib` is contained in the resolved compile artifacts of `libJvm`:
assertContains("Dependency: 'lib'")
}
}
}
@@ -72,6 +72,10 @@ open class KotlinPlatformImplementationPluginBase(platformName: String) : Kotlin
config.dependencies.whenObjectAdded { dep ->
if (dep is ProjectDependency) {
addCommonProject(dep.dependencyProject, project)
// Needed for the projects that depend on this one to recover the common module sources through
// the transitive dependency (also, it will be added to the POM generated by Gradle):
project.configurations.getByName("compile").dependencies.add(dep)
}
else {
throw GradleException("$project '${config.name}' dependency is not a project: $dep")