blob: 01c74b3411045dd0b839b587cbda02f065cfa14b [file] [log] [blame]
/*
* Copyright 2017-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-publish'
apply plugin: 'signing'
// todo: figure out how we can check it in a generic way
def isMultiplatform = project.name == 'atomicfu'
if (!isMultiplatform) {
// Regular java modules need 'java-library' plugin for proper publication
apply plugin: 'java-library'
// MPP projects pack their sources automtically, java libraries need to explicitly pack them
task sourcesJar(type: Jar) {
archiveClassifier = 'sources'
from "src/main/kotlin"
}
}
// empty xxx-javadoc.jar
task javadocJar(type: Jar) {
archiveClassifier = 'javadoc'
}
publishing {
repositories { // this: closure
PublishingKt.configureMavenPublication(delegate, project)
}
if (!isMultiplatform) {
// Configure java publications for non-MPP projects
publications {
// plugin configures its own publication pluginMaven
if (project.name == 'atomicfu-gradle-plugin') {
pluginMaven(MavenPublication) {
artifact sourcesJar
}
} else {
maven(MavenPublication) {
from components.java
artifact sourcesJar
if (project.name.endsWith("-maven-plugin")) {
pom.packaging = 'maven-plugin'
}
}
}
}
}
publications.all {
PublishingKt.configureMavenCentralMetadata(pom, project)
PublishingKt.signPublicationIfKeyPresent(project, it)
// add empty javadocs
if (it.name != "kotlinMultiplatform") { // The root module gets the JVM's javadoc JAR
it.artifact(javadocJar)
}
}
tasks.withType(AbstractPublishToMaven).configureEach {
dependsOn(tasks.withType(Sign))
}
// NOTE: This is a temporary WA, see KT-61313.
tasks.withType(Sign).configureEach { signTask ->
def pubName = name.takeBetween("sign", "Publication")
// Task ':linkDebugTest<platform>' uses this output of task ':sign<platform>Publication' without declaring an explicit or implicit dependency
tasks.findByName("linkDebugTest$pubName")?.configure {
mustRunAfter(signTask)
}
// Task ':compileTestKotlin<platform>' uses this output of task ':sign<platform>Publication' without declaring an explicit or implicit dependency
tasks.findByName("compileTestKotlin$pubName")?.configure {
mustRunAfter(signTask)
}
}
}