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.
124 lines
4.3 KiB
124 lines
4.3 KiB
import org.gradle.util.VersionNumber
|
|
|
|
/*
|
|
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
|
|
*/
|
|
|
|
// Configures publishing of Maven artifacts to Bintray
|
|
|
|
apply plugin: 'maven'
|
|
apply plugin: 'maven-publish'
|
|
|
|
// ------------- tasks
|
|
|
|
def isMultiplatform = project.name == "kotlinx-coroutines-core"
|
|
def isBom = project.name == "kotlinx-coroutines-bom"
|
|
def isKotlin137x = VersionNumber.parse(kotlin_version) <= VersionNumber.parse("1.3.79")
|
|
|
|
if (!isBom) {
|
|
apply plugin: "com.github.johnrengelman.shadow"
|
|
|
|
// empty xxx-javadoc.jar
|
|
task javadocJar(type: Jar) {
|
|
archiveClassifier = 'javadoc'
|
|
}
|
|
}
|
|
|
|
if (!isMultiplatform && !isBom) {
|
|
// Regular java modules need 'java-library' plugin for proper publication
|
|
apply plugin: 'java-library'
|
|
|
|
// MPP projects pack their sources automatically, java libraries need to explicitly pack them
|
|
task sourcesJar(type: Jar) {
|
|
archiveClassifier = 'sources'
|
|
from sourceSets.main.allSource
|
|
}
|
|
}
|
|
|
|
publishing {
|
|
repositories {
|
|
maven {
|
|
def user = 'kotlin'
|
|
def repo = 'kotlinx'
|
|
def name = 'kotlinx.coroutines'
|
|
url = "https://api.bintray.com/maven/$user/$repo/$name/;publish=0"
|
|
|
|
credentials {
|
|
username = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
|
|
password = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!isMultiplatform && !isBom) {
|
|
// Configure java publications for regular non-MPP modules
|
|
publications {
|
|
maven(MavenPublication) {
|
|
if (project.name == "kotlinx-coroutines-debug") {
|
|
project.shadow.component(it)
|
|
} else {
|
|
from components.java
|
|
}
|
|
artifact sourcesJar
|
|
}
|
|
}
|
|
}
|
|
|
|
publications.all {
|
|
MavenCentralKt.configureMavenCentralMetadata(pom, project)
|
|
|
|
// add empty javadocs
|
|
if (!isBom && it.name != "kotlinMultiplatform") {
|
|
it.artifact(javadocJar)
|
|
}
|
|
|
|
// Rename MPP artifacts for backward compatibility
|
|
def type = it.name
|
|
switch (type) {
|
|
case 'kotlinMultiplatform':
|
|
// 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) {
|
|
apply from: "$rootDir/gradle/publish-mpp-root-module-in-platform.gradle"
|
|
publishPlatformArtifactsInRootModule(publications["jvm"])
|
|
}
|
|
break
|
|
case '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
|
|
case 'jvm':
|
|
it.artifactId = isKotlin137x ? project.name : "$project.name-jvm"
|
|
break
|
|
case 'js':
|
|
case 'native':
|
|
it.artifactId = "$project.name-$type"
|
|
break
|
|
}
|
|
// 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
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
tasks.matching { it.name == "generatePomFileForKotlinMultiplatformPublication"}.configureEach {
|
|
dependsOn(tasks["generatePomFileForJvmPublication"])
|
|
}
|
|
|
|
task publishDevelopSnapshot() {
|
|
def branch = System.getenv('currentBranch')
|
|
if (branch == "develop") {
|
|
dependsOn(":publish")
|
|
}
|
|
}
|
|
|
|
// Compatibility with old TeamCity configurations that perform :kotlinx-coroutines-core:bintrayUpload
|
|
task bintrayUpload(dependsOn: publish)
|