|
@@ -1,5 +1,5 @@
|
|
/*
|
|
/*
|
|
- * Copyright 2019-2020 Mamoe Technologies and contributors.
|
|
|
|
|
|
+ * Copyright 2019-2021 Mamoe Technologies and contributors.
|
|
*
|
|
*
|
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
|
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
|
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
|
@@ -12,42 +12,12 @@
|
|
|
|
|
|
tasks.register("ensureBintrayAvailable") {
|
|
tasks.register("ensureBintrayAvailable") {
|
|
doLast {
|
|
doLast {
|
|
- if (!upload.Bintray.isBintrayAvailable(project)) {
|
|
|
|
|
|
+ if (!Bintray.isBintrayAvailable(project)) {
|
|
throw new IllegalStateException("bintray isn't available. ")
|
|
throw new IllegalStateException("bintray isn't available. ")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-def vcs = "https://github.com/mamoe/mirai"
|
|
|
|
-
|
|
|
|
-def pomConfig = {
|
|
|
|
- licenses {
|
|
|
|
- license {
|
|
|
|
- name "AGPLv3 with Mamoe Exceptions"
|
|
|
|
- url "https://github.com/mamoe/mirai/blob/master/LICENSE"
|
|
|
|
- distribution "repo"
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- developers {
|
|
|
|
- developer {
|
|
|
|
- id "mamoe"
|
|
|
|
- name "Mamoe Technologies"
|
|
|
|
- email "support@mamoe.net"
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- scm {
|
|
|
|
- url vcs
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-project.ext.configureMavenCentralMetadata = { pom ->
|
|
|
|
- def root = asNode()
|
|
|
|
- root.appendNode('name', project.name)
|
|
|
|
- root.appendNode('description', project.description)
|
|
|
|
- root.appendNode('url', vcs)
|
|
|
|
- root.children().last() + pomConfig
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
try {
|
|
try {
|
|
|
|
|
|
// empty xxx-javadoc.jar
|
|
// empty xxx-javadoc.jar
|
|
@@ -72,33 +42,32 @@ try {
|
|
* (see details in https://youtrack.jetbrains.com/issue/KT-39184#focus=streamItem-27-4115233.0-0)
|
|
* (see details in https://youtrack.jetbrains.com/issue/KT-39184#focus=streamItem-27-4115233.0-0)
|
|
*/
|
|
*/
|
|
project.ext.publishPlatformArtifactsInRootModule = { platformPublication ->
|
|
project.ext.publishPlatformArtifactsInRootModule = { platformPublication ->
|
|
- afterEvaluate {
|
|
|
|
- def platformPomBuilder = null
|
|
|
|
|
|
+ def platformPomBuilder = null
|
|
|
|
|
|
- platformPublication.pom.withXml { platformPomBuilder = asString() }
|
|
|
|
|
|
+ platformPublication.pom.withXml { platformPomBuilder = asString() }
|
|
|
|
|
|
- publishing.publications.kotlinMultiplatform {
|
|
|
|
- platformPublication.artifacts.forEach {
|
|
|
|
- artifact(it)
|
|
|
|
- }
|
|
|
|
|
|
+ publishing.publications.kotlinMultiplatform {
|
|
|
|
+ platformPublication.artifacts.forEach {
|
|
|
|
+ println("Adding artiface to root: $it")
|
|
|
|
+ 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")
|
|
|
|
- }
|
|
|
|
|
|
+ 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"])
|
|
|
|
- }
|
|
|
|
|
|
+ tasks.matching { it.name == "generatePomFileForKotlinMultiplatformPublication" }.configureEach {
|
|
|
|
+ dependsOn(tasks["generatePomFileFor${platformPublication.name.capitalize()}Publication"])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -111,47 +80,43 @@ afterEvaluate {
|
|
|
|
|
|
// Rename artifacts for backward compatibility
|
|
// Rename artifacts for backward compatibility
|
|
publications.all {
|
|
publications.all {
|
|
|
|
+ // add empty javadocs
|
|
|
|
+ if (it.name != "kotlinMultiplatform") {
|
|
|
|
+ it.artifact(javadocJar)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Rename MPP artifacts for backward compatibility
|
|
def type = it.name
|
|
def type = it.name
|
|
- logger.info("Configuring $type")
|
|
|
|
switch (type) {
|
|
switch (type) {
|
|
case 'kotlinMultiplatform':
|
|
case 'kotlinMultiplatform':
|
|
- if (isKotlin137x) {
|
|
|
|
- it.artifactId = "$variantName-native"
|
|
|
|
- it.artifact sourcesJar
|
|
|
|
- } else {
|
|
|
|
- // With Kotlin 1.4.0, the root module ID has no suffix, but for compatibility with
|
|
|
|
- // the consumers who can't read Gradle module metadata, we publish the JVM artifacts in it
|
|
|
|
- it.artifactId = variantName
|
|
|
|
- // publishPlatformArtifactsInRootModule(publications["jvm"])
|
|
|
|
|
|
+ // With Kotlin 1.4 & HMPP, the root module should have no suffix in the ID, but for compatibility with
|
|
|
|
+ // the consumers who can't read Gradle module metadata, we publish the JVM artifacts in it, too
|
|
|
|
+ it.artifactId = isKotlin137x ? "$project.name-native" : project.name
|
|
|
|
+ if (!isKotlin137x) {
|
|
|
|
+ publishPlatformArtifactsInRootModule(publications["jvm"])
|
|
}
|
|
}
|
|
break
|
|
break
|
|
-
|
|
|
|
case 'metadata':
|
|
case 'metadata':
|
|
- it.artifactId = isKotlin137x ? "$variantName-common" : "$variantName-metadata"
|
|
|
|
|
|
+ // As the old -common dependencies will fail to resolve with Gradle module metadata, rename the module
|
|
|
|
+ // to '*-metadata' so that the resolution failure are more clear
|
|
|
|
+ it.artifactId = isKotlin137x ? "$project.name-common" : "$project.name-metadata"
|
|
break
|
|
break
|
|
-
|
|
|
|
case 'jvm':
|
|
case 'jvm':
|
|
- it.artifactId = isKotlin137x ? "$variantName" : "$variantName-jvm"
|
|
|
|
- /*
|
|
|
|
- def files = tasks.getByName("shadowJarMd5").outputs.files + tasks.getByName("shadowJvmJar").outputs.files
|
|
|
|
- for (f in files) {
|
|
|
|
- artifact f
|
|
|
|
- }
|
|
|
|
- */
|
|
|
|
|
|
+ it.artifactId = isKotlin137x ? project.name : "$project.name-jvm"
|
|
break
|
|
break
|
|
-
|
|
|
|
case 'js':
|
|
case 'js':
|
|
- it.artifactId = "$variantName-$type"
|
|
|
|
|
|
+ case 'native':
|
|
|
|
+ it.artifactId = "$project.name-$type"
|
|
break
|
|
break
|
|
}
|
|
}
|
|
- logger.info("Artifact id = ${it.artifactId}")
|
|
|
|
-
|
|
|
|
- pom.withXml(configureMavenCentralMetadata)
|
|
|
|
-
|
|
|
|
- // The 'root' module publishes the JVM module's Javadoc JAR as per publishPlatformArtifactsInRootModule, and
|
|
|
|
|
|
+ // Hierarchical project structures are not fully supported in 1.3.7x MPP
|
|
|
|
+ if (isKotlin137x) {
|
|
|
|
+ // disable metadata everywhere, but in native and js modules
|
|
|
|
+ if (type == 'maven' || type == 'metadata' || type == 'jvm') {
|
|
|
|
+ moduleDescriptorGenerator = null
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- if (name != "kotlinMultiplatform")
|
|
|
|
- artifact stubJavadoc
|
|
|
|
}
|
|
}
|
|
|
|
|
|
if (isKotlin137x) {
|
|
if (isKotlin137x) {
|
|
@@ -160,9 +125,13 @@ afterEvaluate {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+tasks.matching { it.name == "generatePomFileForKotlinMultiplatformPublication" }.configureEach {
|
|
|
|
+ dependsOn(tasks["generatePomFileForJvmPublication"])
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
|
|
-if (upload.Bintray.isBintrayAvailable(project)) {
|
|
|
|
- apply from: rootProject.file("gradle/bintray.gradle")
|
|
|
|
|
|
+if (Bintray.isBintrayAvailable(project)) {
|
|
|
|
+ project.configureBintray()
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|