You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.6 KiB
37 lines
1.6 KiB
/*
|
|
* Copyright 2014-2020 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
|
|
*/
|
|
|
|
|
|
/** Publish the platform JAR and POM so that consumers who depend on this module and can't read Gradle module
|
|
metadata can still get the platform artifact and transitive dependencies from the POM: */
|
|
project.ext.publishPlatformArtifactsInRootModule = { platformPublication ->
|
|
afterEvaluate {
|
|
def platformPomBuilder = null
|
|
|
|
platformPublication.pom.withXml { platformPomBuilder = asString() }
|
|
|
|
publishing.publications.kotlinMultiplatform {
|
|
platformPublication.artifacts.forEach {
|
|
artifact(it)
|
|
}
|
|
|
|
pom.withXml {
|
|
def pomStringBuilder = asString()
|
|
pomStringBuilder.setLength(0)
|
|
// The platform POM needs its artifact ID replaced with the artifact ID of the root module:
|
|
def platformPomString = platformPomBuilder.toString()
|
|
platformPomString.eachLine { line ->
|
|
if (!line.contains("<!--")) { // Remove the Gradle module metadata marker as it will be added anew
|
|
pomStringBuilder.append(line.replace(platformPublication.artifactId, artifactId))
|
|
pomStringBuilder.append("\n")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks.matching { it.name == "generatePomFileForKotlinMultiplatformPublication"}.configureEach {
|
|
dependsOn(tasks["generatePomFileFor${platformPublication.name.capitalize()}Publication"])
|
|
}
|
|
}
|
|
} |