1/* 2 * Copyright 2017-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. 3 */ 4 5// Configures publishing of Maven artifacts to Bintray 6 7apply plugin: 'maven' 8apply plugin: 'maven-publish' 9apply plugin: 'signing' 10 11// todo: figure out how we can check it in a generic way 12def isMultiplatform = project.name == 'atomicfu' 13 14if (!isMultiplatform) { 15 // Regular java modules need 'java-library' plugin for proper publication 16 apply plugin: 'java-library' 17 18 // MPP projects pack their sources automtically, java libraries need to explicitly pack them 19 task sourcesJar(type: Jar) { 20 archiveClassifier = 'sources' 21 from "src/main/kotlin" 22 } 23} 24 25// empty xxx-javadoc.jar 26task javadocJar(type: Jar) { 27 archiveClassifier = 'javadoc' 28} 29 30def bintrayUpload = System.getenv("libs.bintray.upload") != null 31 32publishing { 33 repositories { // this: closure 34 if (bintrayUpload) { 35 PublishingKt.configureBintrayPublication(delegate, project) 36 } else { 37 PublishingKt.configureMavenPublication(delegate, project) 38 } 39 } 40 41 if (!isMultiplatform) { 42 // Configure java publications for non-MPP projects 43 publications { 44 // plugin configures its own publication pluginMaven 45 if (project.name == 'atomicfu-gradle-plugin') { 46 pluginMaven(MavenPublication) { 47 artifact sourcesJar 48 } 49 } else { 50 maven(MavenPublication) { 51 from components.java 52 artifact sourcesJar 53 54 if (project.name.endsWith("-maven-plugin")) { 55 pom.packaging = 'maven-plugin' 56 } 57 } 58 } 59 } 60 } 61 62 publications.all { 63 PublishingKt.configureMavenCentralMetadata(pom, project) 64 if (!bintrayUpload) { 65 PublishingKt.signPublicationIfKeyPresent(project, it) 66 } 67 68 // add empty javadocs 69 if (it.name != "kotlinMultiplatform") { // The root module gets the JVM's javadoc JAR 70 it.artifact(javadocJar) 71 } 72 } 73} 74