1/* 2 * Copyright 2017-2018 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' 9 10apply from: project.rootProject.file('gradle/maven-central.gradle') 11 12// todo: figure out how we can check it in a generic way 13def isMultiplatform = project.name == 'atomicfu' 14 15if (!isMultiplatform) { 16 // Regular java modules need 'java-library' plugin for proper publication 17 apply plugin: 'java-library' 18 19 // MPP projects pack their sources automtically, java libraries need to explicitly pack them 20 task sourcesJar(type: Jar) { 21 archiveClassifier = 'sources' 22 from "src/main/kotlin" 23 } 24} 25 26// empty xxx-javadoc.jar 27task javadocJar(type: Jar) { 28 archiveClassifier = 'javadoc' 29} 30 31publishing { 32 repositories { 33 maven { 34 def user = 'kotlin' 35 def repo = 'kotlinx' 36 def name = 'kotlinx.atomicfu' 37 url = "https://api.bintray.com/maven/$user/$repo/$name/;publish=0;override=0" 38 39 credentials { 40 username = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER') 41 password = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') 42 } 43 } 44 } 45 46 if (!isMultiplatform) { 47 // Configure java publications for non-MPP projects 48 publications { 49 // plugin configures its own publication pluginMaven 50 if (project.name == 'atomicfu-gradle-plugin') { 51 pluginMaven(MavenPublication) { 52 artifact sourcesJar 53 } 54 } else { 55 maven(MavenPublication) { 56 from components.java 57 artifact sourcesJar 58 59 if (project.name.endsWith("-maven-plugin")) { 60 pom.packaging = 'maven-plugin' 61 } 62 } 63 } 64 } 65 } 66 67 publications.all { 68 pom.withXml(configureMavenCentralMetadata) 69 70 // add empty javadocs 71 if (it.name != "kotlinMultiplatform") { // The root module gets the JVM's javadoc JAR 72 it.artifact(javadocJar) 73 } 74 } 75} 76