Fix test was using removed publication plugin.

Replace usage of removed 'maven' plugin with 'maven-publish'.

^KT-44949 In Progress
This commit is contained in:
Yahor Berdnikau
2021-02-22 12:25:48 +01:00
parent 2042508df0
commit c072c8200b
5 changed files with 77 additions and 95 deletions
@@ -522,27 +522,43 @@ open class KotlinAndroid34GradleIT : KotlinAndroid3GradleIT() {
setupWorkingDir()
gradleBuildScript("Lib").modify {
it.checkedReplace("kotlin-stdlib:\$kotlin_version", "kotlin-stdlib") + "\n" + """
apply plugin: 'maven'
group 'com.example'
version '1.0'
android {
defaultPublishConfig 'flavor1Debug'
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: "file://${'$'}buildDir/repo")
it.checkedReplace(
"kotlin-stdlib:\$kotlin_version",
"kotlin-stdlib"
) + "\n" +
"""
apply plugin: 'maven-publish'
android {
defaultPublishConfig 'flavor1Debug'
}
afterEvaluate {
publishing {
publications {
flavorDebug(MavenPublication) {
from components.flavor1Debug
group = 'com.example'
artifactId = 'flavor1Debug'
version = '1.0'
}
}
repositories {
maven {
url = "file://${'$'}buildDir/repo"
}
}
}
}
}
""".trimIndent()
""".trimIndent()
}
build(":Lib:assembleFlavor1Debug", ":Lib:uploadArchives") {
build(":Lib:assembleFlavor1Debug", ":Lib:publish") {
assertSuccessful()
assertTasksExecuted(":Lib:compileFlavor1DebugKotlin", ":Lib:uploadArchives")
val pomLines = File(projectDir, "Lib/build/repo/com/example/Lib/1.0/Lib-1.0.pom").readLines()
assertTasksExecuted(":Lib:compileFlavor1DebugKotlin", ":Lib:publishFlavorDebugPublicationToMavenRepository")
val pomLines = File(projectDir, "Lib/build/repo/com/example/flavor1Debug/1.0/flavor1Debug-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 }
@@ -387,15 +387,34 @@ class KotlinGradleIT : BaseGradleIT() {
project.setupWorkingDir()
File(project.projectDir, "build.gradle").modify {
it.replace("kotlin-stdlib:\$kotlin_version", "kotlin-stdlib").apply { check(!equals(it)) } + "\n" + """
apply plugin: 'maven'
install.repositories { maven { url "file://${'$'}buildDir/repo" } }
apply plugin: 'maven-publish'
group = "com.example"
version = "1.0"
publishing {
publications {
myLibrary(MavenPublication) {
from components.kotlin
}
}
repositories {
maven {
url = "${'$'}buildDir/repo"
}
}
}
""".trimIndent()
}
project.build("build", "install", options = defaultBuildOptions().copy(warningMode = WarningMode.Summary)) {
project.build(
"build",
"publishAllPublicationsToMavenRepository",
options = defaultBuildOptions().copy(warningMode = WarningMode.Summary)
) {
assertSuccessful()
assertTasksExecuted(":compileKotlin", ":compileTestKotlin")
val pomLines = File(project.projectDir, "build/poms/pom-default.xml").readLines()
val pomLines = File(project.projectDir, "build/publications/myLibrary/pom-default.xml").readLines()
val stdlibVersionLineNumber = pomLines.indexOfFirst { "<artifactId>kotlin-stdlib</artifactId>" in it } + 1
val versionLine = pomLines[stdlibVersionLineNumber]
assertTrue { "<version>${defaultBuildOptions().kotlinVersion}</version>" in versionLine }
@@ -1532,26 +1532,19 @@ class NewMultiplatformIT : BaseGradleIT() {
assertFileExists(groupDir + "mpp-lib-myjvm")
}
fun doTestPomRewriting(mppProjectDependency: Boolean, legacyPublishing: Boolean, keepPomIntact: Boolean? = null) {
fun doTestPomRewriting(mppProjectDependency: Boolean, keepPomIntact: Boolean? = null) {
val params = mutableListOf("clean", ":jvm-app:publish", ":js-app:publish").apply {
if (mppProjectDependency)
add("-PmppProjectDependency=true")
if (legacyPublishing)
add("-PlegacyPublishing=true")
if (keepPomIntact == true)
add("-Pkotlin.mpp.keepMppDependenciesIntactInPoms=true")
}.toTypedArray()
build(*params, options = defaultBuildOptions().copy(warningMode = WarningMode.Summary)) {
assertSuccessful()
if (legacyPublishing) {
assertTasksExecuted(":jvm-app:uploadArchives")
assertTasksExecuted(":js-app:uploadArchives")
} else {
assertTasksExecuted(":jvm-app:publishMainPublicationToMavenRepository")
assertTasksExecuted(":js-app:publishMainPublicationToMavenRepository")
}
assertTasksExecuted(":jvm-app:publishMainPublicationToMavenRepository")
assertTasksExecuted(":js-app:publishMainPublicationToMavenRepository")
val jvmModuleDir = groupDir + "jvm-app/1.0/"
val jsModuleDir = groupDir + "js-app/1.0/"
@@ -1584,16 +1577,14 @@ class NewMultiplatformIT : BaseGradleIT() {
}
}
doTestPomRewriting(mppProjectDependency = false, legacyPublishing = false)
doTestPomRewriting(mppProjectDependency = false, legacyPublishing = true)
doTestPomRewriting(mppProjectDependency = true, legacyPublishing = false)
doTestPomRewriting(mppProjectDependency = false)
doTestPomRewriting(mppProjectDependency = true)
// This case doesn't work and never did; TODO investigate KT-29975
// doTestPomRewriting(mppProjectDependency = true, legacyPublishing = true)
// Also check that the flag for keeping POMs intact works:
doTestPomRewriting(mppProjectDependency = false, legacyPublishing = false, keepPomIntact = true)
doTestPomRewriting(mppProjectDependency = false, legacyPublishing = true, keepPomIntact = true)
doTestPomRewriting(mppProjectDependency = false, keepPomIntact = true)
}
@Test
@@ -1,5 +1,6 @@
plugins {
id "kotlin2js"
id "maven-publish"
}
group = "com.example"
@@ -27,36 +28,13 @@ if (project.findProperty("mppProjectDependency") == "true") {
}
if (project.findProperty("legacyPublishing") == "true") {
apply plugin: 'maven'
uploadArchives {
repositories {
mavenDeployer {
repository(url: "file://${rootProject.buildDir}/repo")
}
publishing {
publications {
main(MavenPublication) {
from components.java
}
}
tasks.create("publish") {
dependsOn uploadArchives
repositories {
maven { setUrl("${rootProject.buildDir}/repo") }
}
} else {
apply plugin: 'maven-publish'
publishing {
publications {
main(MavenPublication) {
from components.java
}
}
repositories {
maven { setUrl("${rootProject.buildDir}/repo") }
}
}
}
}
@@ -1,5 +1,6 @@
plugins {
id "org.jetbrains.kotlin.jvm"
id "maven-publish"
}
group = "com.example"
@@ -27,36 +28,13 @@ if (project.findProperty("mppProjectDependency") == "true") {
}
if (project.findProperty("legacyPublishing") == "true") {
apply plugin: 'maven'
uploadArchives {
repositories {
mavenDeployer {
repository(url: "file://${rootProject.buildDir}/repo")
}
publishing {
publications {
main(MavenPublication) {
from components.java
}
}
tasks.create("publish") {
dependsOn uploadArchives
repositories {
maven { setUrl("${rootProject.buildDir}/repo") }
}
} else {
apply plugin: 'maven-publish'
publishing {
publications {
main(MavenPublication) {
from components.java
}
}
repositories {
maven { setUrl("${rootProject.buildDir}/repo") }
}
}
}
}