Allow omitting version of standard artifacts when kotlin-android plugin is used

This commit is contained in:
technoir
2019-06-29 22:00:49 +03:00
committed by Sergey Igushkin
parent 0aa80d1912
commit 15feeddc46
2 changed files with 34 additions and 0 deletions
@@ -397,6 +397,38 @@ class KotlinAndroid30GradleIT : KotlinAndroid3GradleIT() {
override val defaultGradleVersion: GradleVersionRequired
get() = GradleVersionRequired.Until("4.10.2")
@Test
fun testOmittedStdlibVersion() = with(Project("AndroidProject", GradleVersionRequired.AtLeast("4.4"))) {
setupWorkingDir()
gradleBuildScript("Lib").modify {
it.replace("kotlin-stdlib:\$kotlin_version", "kotlin-stdlib").apply { check(!equals(it)) } + "\n" + """
apply plugin: 'maven'
group 'com.example'
version '1.0'
android {
defaultPublishConfig 'flavor1Debug'
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: "file://${'$'}buildDir/repo")
}
}
}
""".trimIndent()
}
build(":Lib:assembleFlavor1Debug", ":Lib:uploadArchives") {
assertSuccessful()
assertTasksExecuted(":Lib:compileFlavor1DebugKotlin", ":Lib:uploadArchives")
val pomLines = File(projectDir, "Lib/build/repo/com/example/Lib/1.0/Lib-1.0.pom").readLines()
val stdlibVersionLineNumber = pomLines.indexOfFirst { "<artifactId>kotlin-stdlib</artifactId>" in it } + 1
val versionLine = pomLines[stdlibVersionLineNumber]
assertTrue { "<version>${defaultBuildOptions().kotlinVersion}</version>" in versionLine }
}
}
}
abstract class KotlinAndroid3GradleIT : AbstractKotlinAndroidGradleTests() {
@@ -646,6 +646,8 @@ internal open class KotlinAndroidPlugin(
applyUserDefinedAttributes(androidTarget)
configureDefaultVersionsResolutionStrategy(project, kotlinPluginVersion)
registry.register(KotlinModelBuilder(kotlinPluginVersion, androidTarget))
project.whenEvaluated { project.components.addAll(androidTarget.components) }