mirror of
https://github.com/mamoe/mirai.git
synced 2025-04-02 21:30:18 +08:00
New MPP publishing (#489)
This commit is contained in:
parent
370e139221
commit
ad74673e7f
11
.github/workflows/bintray.yml
vendored
11
.github/workflows/bintray.yml
vendored
@ -28,13 +28,10 @@ jobs:
|
|||||||
run: ./gradlew build # if test's failed, don't publish
|
run: ./gradlew build # if test's failed, don't publish
|
||||||
- name: Check keys
|
- name: Check keys
|
||||||
run: ./gradlew :mirai-core:ensureBintrayAvailable :mirai-core-qqandroid:ensureBintrayAvailable -Dbintray_user=${{ secrets.BINTRAY_USER }} -Pbintray_user=${{ secrets.BINTRAY_USER }} -Dbintray_key=${{ secrets.BINTRAY_KEY }} -Pbintray_key=${{ secrets.BINTRAY_KEY }}
|
run: ./gradlew :mirai-core:ensureBintrayAvailable :mirai-core-qqandroid:ensureBintrayAvailable -Dbintray_user=${{ secrets.BINTRAY_USER }} -Pbintray_user=${{ secrets.BINTRAY_USER }} -Dbintray_key=${{ secrets.BINTRAY_KEY }} -Pbintray_key=${{ secrets.BINTRAY_KEY }}
|
||||||
- name: Gradle :mirai-core:bintrayUpload
|
- name: Gradle :mirai-core:publish
|
||||||
run: ./gradlew :mirai-core:bintrayUpload -Dbintray_user=${{ secrets.BINTRAY_USER }} -Pbintray_user=${{ secrets.BINTRAY_USER }} -Dbintray_key=${{ secrets.BINTRAY_KEY }} -Pbintray_key=${{ secrets.BINTRAY_KEY }}
|
run: ./gradlew :mirai-core:publish -Dbintray_user=${{ secrets.BINTRAY_USER }} -Pbintray_user=${{ secrets.BINTRAY_USER }} -Dbintray_key=${{ secrets.BINTRAY_KEY }} -Pbintray_key=${{ secrets.BINTRAY_KEY }}
|
||||||
- name: Gradle :mirai-core-qqandroid:bintrayUpload
|
- name: Gradle :mirai-core-qqandroid:publish
|
||||||
run: ./gradlew :mirai-core-qqandroid:bintrayUpload -Dbintray_user=${{ secrets.BINTRAY_USER }} -Pbintray_user=${{ secrets.BINTRAY_USER }} -Dbintray_key=${{ secrets.BINTRAY_KEY }} -Pbintray_key=${{ secrets.BINTRAY_KEY }}
|
run: ./gradlew :mirai-core-qqandroid:publish -Dbintray_user=${{ secrets.BINTRAY_USER }} -Pbintray_user=${{ secrets.BINTRAY_USER }} -Dbintray_key=${{ secrets.BINTRAY_KEY }} -Pbintray_key=${{ secrets.BINTRAY_KEY }}
|
||||||
- name: Gradle :mirai-serialization:bintrayUpload
|
|
||||||
run: ./gradlew :mirai-serialization:bintrayUpload -Dbintray_user=${{ secrets.BINTRAY_USER }} -Pbintray_user=${{ secrets.BINTRAY_USER }} -Dbintray_key=${{ secrets.BINTRAY_KEY }} -Pbintray_key=${{ secrets.BINTRAY_KEY }}
|
|
||||||
|
|
||||||
|
|
||||||
# - name: Upload artifact
|
# - name: Upload artifact
|
||||||
# uses: actions/upload-artifact@v1.0.0
|
# uses: actions/upload-artifact@v1.0.0
|
||||||
|
@ -7,3 +7,5 @@ org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=512m -Dfile.encoding=UTF-8
|
|||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
|
|
||||||
#kotlin.mpp.enableGranularSourceSetsMetadata=true
|
#kotlin.mpp.enableGranularSourceSetsMetadata=true
|
||||||
|
|
||||||
|
systemProp.org.gradle.internal.publish.checksums.insecure=true
|
12
gradle/bintray.gradle
Normal file
12
gradle/bintray.gradle
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
publishing {
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
url = "https://api.bintray.com/maven/mamoe/mirai/mirai-core/;publish=0"
|
||||||
|
|
||||||
|
credentials {
|
||||||
|
username = upload.Bintray.getUser(project)
|
||||||
|
password = upload.Bintray.getKey(project)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,56 +1,21 @@
|
|||||||
import upload.Bintray
|
|
||||||
|
|
||||||
// 部分源码来自 kotlinx.coroutines
|
// 部分源码来自 kotlinx.coroutines
|
||||||
// Source code from kotlinx.coroutines
|
// Source code from kotlinx.coroutines
|
||||||
|
|
||||||
task ensureBintrayAvailable() {
|
tasks.register("ensureBintrayAvailable") {
|
||||||
doLast {
|
doLast {
|
||||||
if (!Bintray.isBintrayAvailable(project)) {
|
if (!upload.Bintray.isBintrayAvailable(project)) {
|
||||||
throw new IllegalStateException("bintray isn't available. ")
|
throw new IllegalStateException("bintray isn't available. ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Bintray.isBintrayAvailable(project)) {
|
def vcs = "https://github.com/mamoe/mirai"
|
||||||
println("bintray isn't available. NO PUBLICATIONS WILL BE SET")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
def miraiGitHubUrl = "https://github.com/mamoe/mirai"
|
def pomConfig = {
|
||||||
|
|
||||||
bintray {
|
|
||||||
user = Bintray.getUser(project)
|
|
||||||
key = Bintray.getKey(project)
|
|
||||||
|
|
||||||
pkg {
|
|
||||||
repo = 'mirai'
|
|
||||||
name = "mirai-core"
|
|
||||||
licenses = ['AGPL']
|
|
||||||
vcsUrl = miraiGitHubUrl
|
|
||||||
websiteUrl = miraiGitHubUrl
|
|
||||||
githubRepo = miraiGitHubUrl
|
|
||||||
issueTrackerUrl = "$miraiGitHubUrl/issues"
|
|
||||||
/* version {
|
|
||||||
name = project.version
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
afterEvaluate {
|
|
||||||
project.publishing.publications.forEach { publication ->
|
|
||||||
publication.pom.withXml {
|
|
||||||
def root = asNode()
|
|
||||||
//root.appendNode('groupId', project.group)
|
|
||||||
//root.appendNode('artifactId', project.name)
|
|
||||||
//root.appendNode('version', project.version)
|
|
||||||
root.appendNode('name', project.name)
|
|
||||||
root.appendNode('description', project.description)
|
|
||||||
root.appendNode('url', miraiGitHubUrl)
|
|
||||||
root.children().last() + {
|
|
||||||
licenses {
|
licenses {
|
||||||
license {
|
license {
|
||||||
name "AGPL-V3"
|
name "AGPLv3 with Mamoe Exceptions"
|
||||||
url "https://www.gnu.org/licenses/agpl-3.0.txt"
|
url "https://github.com/mamoe/mirai/blob/master/LICENSE"
|
||||||
distribution "repo"
|
distribution "repo"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,26 +27,16 @@ afterEvaluate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
scm {
|
scm {
|
||||||
url miraiGitHubUrl
|
url vcs
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bintrayUpload.doFirst {
|
project.ext.configureMavenCentralMetadata = { pom ->
|
||||||
publications = project.publishing.publications
|
def root = asNode()
|
||||||
}
|
root.appendNode('name', project.name)
|
||||||
|
root.appendNode('description', project.description)
|
||||||
bintrayUpload.dependsOn {
|
root.appendNode('url', vcs)
|
||||||
def list = new LinkedList<Task>()
|
root.children().last() + pomConfig
|
||||||
list.add(tasks.getByName("build"))
|
|
||||||
|
|
||||||
list.addAll(tasks.findAll { task -> task.name.contains('Jar') })
|
|
||||||
list.addAll(tasks.findAll { task -> task.name.startsWith('generateMetadataFileFor') })
|
|
||||||
list.addAll(tasks.findAll { task -> task.name.startsWith('generatePomFileFor') })
|
|
||||||
|
|
||||||
list
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -90,40 +45,117 @@ try {
|
|||||||
task javadocJar(type: Jar) {
|
task javadocJar(type: Jar) {
|
||||||
archiveClassifier = 'javadoc'
|
archiveClassifier = 'javadoc'
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
|
|
||||||
}
|
}
|
||||||
publishing {
|
|
||||||
publications.all {
|
try {
|
||||||
// add empty javadocs (no need for MPP root publication which publishes only pom file)
|
task stubJavadoc(type: Jar) {
|
||||||
if (it.name != 'kotlinMultiplatform') {
|
archiveClassifier = 'javadoc'
|
||||||
it.artifact(javadocJar)
|
}
|
||||||
|
}catch (Exception ignored) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rename MPP artifacts for backward compatibility
|
/**
|
||||||
|
* 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
|
||||||
|
* (see details in https://youtrack.jetbrains.com/issue/KT-39184#focus=streamItem-27-4115233.0-0)
|
||||||
|
*/
|
||||||
|
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"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def isKotlin137x = false
|
||||||
|
|
||||||
|
afterEvaluate {
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
def variantName = "${project.name}"
|
||||||
|
|
||||||
|
// Rename artifacts for backward compatibility
|
||||||
|
publications.all {
|
||||||
def type = it.name
|
def type = it.name
|
||||||
|
logger.info("Configuring $type")
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'kotlinMultiplatform':
|
case 'kotlinMultiplatform':
|
||||||
it.artifactId = "$project.name-native"
|
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"])
|
||||||
|
}
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'metadata':
|
case 'metadata':
|
||||||
it.artifactId = "$project.name-common"
|
it.artifactId = isKotlin137x ? "$variantName-common" : "$variantName-metadata"
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'jvm':
|
case 'jvm':
|
||||||
it.artifactId = "$project.name"
|
it.artifactId = isKotlin137x ? "$variantName" : "$variantName-jvm"
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'js':
|
case 'js':
|
||||||
case 'native':
|
it.artifactId = "$variantName-$type"
|
||||||
it.artifactId = "$project.name-$type"
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
logger.info("Artifact id = ${it.artifactId}")
|
||||||
|
|
||||||
// disable metadata everywhere, but in native modules
|
pom.withXml(configureMavenCentralMetadata)
|
||||||
if (type == 'maven' || type == 'metadata' || type == 'jvm' || type == 'js') {
|
|
||||||
moduleDescriptorGenerator = null
|
// The 'root' module publishes the JVM module's Javadoc JAR as per publishPlatformArtifactsInRootModule, and
|
||||||
|
|
||||||
|
if (name != "kotlinMultiplatform")
|
||||||
|
artifact stubJavadoc
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isKotlin137x) {
|
||||||
|
disableMetadataPublication()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// bintrayUpload.dependsOn publishToMavenLocal
|
|
||||||
|
if (upload.Bintray.isBintrayAvailable(project)) {
|
||||||
|
apply from: rootProject.file("gradle/bintray.gradle")
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
task bintrayUpload(dependsOn: publish)
|
||||||
|
|
||||||
|
// This is required for K/N publishing
|
||||||
|
bintrayUpload.dependsOn publishToMavenLocal
|
||||||
|
|
||||||
|
|
||||||
|
bintrayUpload.dependsOn generatePomFileForKotlinMultiplatformPublication
|
||||||
|
*/
|
129
gradle/publishOld.gradle
Normal file
129
gradle/publishOld.gradle
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
import upload.Bintray
|
||||||
|
|
||||||
|
// 部分源码来自 kotlinx.coroutines
|
||||||
|
// Source code from kotlinx.coroutines
|
||||||
|
|
||||||
|
task ensureBintrayAvailable() {
|
||||||
|
doLast {
|
||||||
|
if (!Bintray.isBintrayAvailable(project)) {
|
||||||
|
throw new IllegalStateException("bintray isn't available. ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Bintray.isBintrayAvailable(project)) {
|
||||||
|
println("bintray isn't available. NO PUBLICATIONS WILL BE SET")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
def miraiGitHubUrl = "https://github.com/mamoe/mirai"
|
||||||
|
|
||||||
|
bintray {
|
||||||
|
user = Bintray.getUser(project)
|
||||||
|
key = Bintray.getKey(project)
|
||||||
|
|
||||||
|
pkg {
|
||||||
|
repo = 'mirai'
|
||||||
|
name = "mirai-core"
|
||||||
|
licenses = ['AGPL']
|
||||||
|
vcsUrl = miraiGitHubUrl
|
||||||
|
websiteUrl = miraiGitHubUrl
|
||||||
|
githubRepo = miraiGitHubUrl
|
||||||
|
issueTrackerUrl = "$miraiGitHubUrl/issues"
|
||||||
|
/* version {
|
||||||
|
name = project.version
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
afterEvaluate {
|
||||||
|
project.publishing.publications.forEach { publication ->
|
||||||
|
publication.pom.withXml {
|
||||||
|
def root = asNode()
|
||||||
|
//root.appendNode('groupId', project.group)
|
||||||
|
//root.appendNode('artifactId', project.name)
|
||||||
|
//root.appendNode('version', project.version)
|
||||||
|
root.appendNode('name', project.name)
|
||||||
|
root.appendNode('description', project.description)
|
||||||
|
root.appendNode('url', miraiGitHubUrl)
|
||||||
|
root.children().last() + {
|
||||||
|
licenses {
|
||||||
|
license {
|
||||||
|
name "AGPL-V3"
|
||||||
|
url "https://www.gnu.org/licenses/agpl-3.0.txt"
|
||||||
|
distribution "repo"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
developers {
|
||||||
|
developer {
|
||||||
|
id "mamoe"
|
||||||
|
name "Mamoe Technologies"
|
||||||
|
email "support@mamoe.net"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
scm {
|
||||||
|
url miraiGitHubUrl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bintrayUpload.doFirst {
|
||||||
|
publications = project.publishing.publications
|
||||||
|
}
|
||||||
|
|
||||||
|
bintrayUpload.dependsOn {
|
||||||
|
def list = new LinkedList<Task>()
|
||||||
|
list.add(tasks.getByName("build"))
|
||||||
|
|
||||||
|
list.addAll(tasks.findAll { task -> task.name.contains('Jar') })
|
||||||
|
list.addAll(tasks.findAll { task -> task.name.startsWith('generateMetadataFileFor') })
|
||||||
|
list.addAll(tasks.findAll { task -> task.name.startsWith('generatePomFileFor') })
|
||||||
|
|
||||||
|
list
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
// empty xxx-javadoc.jar
|
||||||
|
task javadocJar(type: Jar) {
|
||||||
|
archiveClassifier = 'javadoc'
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
|
||||||
|
}
|
||||||
|
publishing {
|
||||||
|
publications.all {
|
||||||
|
// add empty javadocs (no need for MPP root publication which publishes only pom file)
|
||||||
|
if (it.name != 'kotlinMultiplatform') {
|
||||||
|
it.artifact(javadocJar)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rename MPP artifacts for backward compatibility
|
||||||
|
def type = it.name
|
||||||
|
switch (type) {
|
||||||
|
case 'kotlinMultiplatform':
|
||||||
|
it.artifactId = "$project.name-native"
|
||||||
|
break
|
||||||
|
case 'metadata':
|
||||||
|
it.artifactId = "$project.name-common"
|
||||||
|
break
|
||||||
|
case 'jvm':
|
||||||
|
it.artifactId = "$project.name"
|
||||||
|
break
|
||||||
|
case 'js':
|
||||||
|
case 'native':
|
||||||
|
it.artifactId = "$project.name-$type"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
// disable metadata everywhere, but in native modules
|
||||||
|
if (type == 'maven' || type == 'metadata' || type == 'jvm' || type == 'js') {
|
||||||
|
moduleDescriptorGenerator = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// bintrayUpload.dependsOn publishToMavenLocal
|
@ -114,3 +114,19 @@ kotlin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
apply(from = rootProject.file("gradle/publish.gradle"))
|
apply(from = rootProject.file("gradle/publish.gradle"))
|
||||||
|
|
||||||
|
|
||||||
|
tasks.withType<com.jfrog.bintray.gradle.tasks.BintrayUploadTask> {
|
||||||
|
doFirst {
|
||||||
|
publishing.publications
|
||||||
|
.filterIsInstance<MavenPublication>()
|
||||||
|
.forEach { publication ->
|
||||||
|
val moduleFile = buildDir.resolve("publications/${publication.name}/module.json")
|
||||||
|
if (moduleFile.exists()) {
|
||||||
|
publication.artifact(object : org.gradle.api.publish.maven.internal.artifact.FileBasedMavenArtifact(moduleFile) {
|
||||||
|
override fun getDefaultExtension() = "module"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -51,6 +51,7 @@ kotlin {
|
|||||||
languageSettings.useExperimentalAnnotation("kotlin.experimental.ExperimentalTypeInference")
|
languageSettings.useExperimentalAnnotation("kotlin.experimental.ExperimentalTypeInference")
|
||||||
languageSettings.useExperimentalAnnotation("kotlin.time.ExperimentalTime")
|
languageSettings.useExperimentalAnnotation("kotlin.time.ExperimentalTime")
|
||||||
languageSettings.useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
|
languageSettings.useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
|
||||||
|
languageSettings.useExperimentalAnnotation("kotlinx.serialization.ExperimentalSerializationApi")
|
||||||
|
|
||||||
languageSettings.progressiveMode = true
|
languageSettings.progressiveMode = true
|
||||||
}
|
}
|
||||||
@ -132,3 +133,18 @@ kotlin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
apply(from = rootProject.file("gradle/publish.gradle"))
|
apply(from = rootProject.file("gradle/publish.gradle"))
|
||||||
|
|
||||||
|
tasks.withType<com.jfrog.bintray.gradle.tasks.BintrayUploadTask> {
|
||||||
|
doFirst {
|
||||||
|
publishing.publications
|
||||||
|
.filterIsInstance<MavenPublication>()
|
||||||
|
.forEach { publication ->
|
||||||
|
val moduleFile = buildDir.resolve("publications/${publication.name}/module.json")
|
||||||
|
if (moduleFile.exists()) {
|
||||||
|
publication.artifact(object : org.gradle.api.publish.maven.internal.artifact.FileBasedMavenArtifact(moduleFile) {
|
||||||
|
override fun getDefaultExtension() = "module"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user