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 30publishing { 31 repositories { // this: closure 32 PublishingKt.configureMavenPublication(delegate, project) 33 } 34 35 if (!isMultiplatform) { 36 // Configure java publications for non-MPP projects 37 publications { 38 // plugin configures its own publication pluginMaven 39 if (project.name == 'atomicfu-gradle-plugin') { 40 pluginMaven(MavenPublication) { 41 artifact sourcesJar 42 } 43 } else { 44 maven(MavenPublication) { 45 from components.java 46 artifact sourcesJar 47 48 if (project.name.endsWith("-maven-plugin")) { 49 pom.packaging = 'maven-plugin' 50 } 51 } 52 } 53 } 54 } 55 56 publications.all { 57 PublishingKt.configureMavenCentralMetadata(pom, project) 58 PublishingKt.signPublicationIfKeyPresent(project, it) 59 60 // add empty javadocs 61 if (it.name != "kotlinMultiplatform") { // The root module gets the JVM's javadoc JAR 62 it.artifact(javadocJar) 63 } 64 } 65} 66