From 317968372fbc58e9d4f7f6af66d9d1ce9e2b9a12 Mon Sep 17 00:00:00 2001 From: Vsevolod Tolstopyatov Date: Mon, 12 Nov 2018 14:49:41 +0300 Subject: [PATCH] Ability to publish develop branch to oss.jfrog --- build.gradle | 1 + gradle.properties | 1 + gradle/publish-bintray.gradle | 41 +++++++++++++++++++++++++++++++++-- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 9013e17cdc..52ad4ab282 100644 --- a/build.gradle +++ b/build.gradle @@ -31,6 +31,7 @@ buildscript { } } dependencies { + classpath "org.jfrog.buildinfo:build-info-extractor-gradle:$artifactory_plugin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$kotlin_native_version" classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version" diff --git a/gradle.properties b/gradle.properties index f64a0c0731..df587f53ea 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,6 +11,7 @@ html_version=0.6.8 lincheck_version=1.9 dokka_version=0.9.16-rdev-2-mpp-hacks bintray_version=1.8.2-SNAPSHOT +artifactory_plugin_version=4.7.3 # JS gradle_node_version=1.2.0 diff --git a/gradle/publish-bintray.gradle b/gradle/publish-bintray.gradle index 0493a1015c..f0018eeeb9 100644 --- a/gradle/publish-bintray.gradle +++ b/gradle/publish-bintray.gradle @@ -7,6 +7,7 @@ apply plugin: 'maven' apply plugin: 'maven-publish' apply plugin: 'com.jfrog.bintray' +apply plugin: 'com.jfrog.artifactory' apply from: project.rootProject.file('gradle/maven-central.gradle') @@ -16,6 +17,8 @@ def coroutines_core = platformLib("kotlinx-coroutines-core", platform) // ------------- tasks def isNative = project.name.endsWith("native") +def bUser = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER') +def bKey = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') task sourcesJar(type: Jar) { classifier = 'sources' @@ -46,9 +49,43 @@ publishing { } } +artifactory { + contextUrl = 'https://oss.jfrog.org/artifactory' + publish { + repository { + repoKey = 'oss-snapshot-local' + username = bUser + password = bKey + } + + publications { + maven(MavenPublication) { + if (!isNative) { + from components.java + artifact javadocJar + artifact sourcesJar + } + pom.withXml(configureMavenCentralMetadata) + } + } + + defaults { + publications('maven') + } + } +} + +task publishDevelopSnapshot() { + def branch = System.getenv('currentBranch') + println "Current branch: $branch" + if (branch == "develop") { + dependsOn(":artifactoryPublish") + } +} + bintray { - user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER') - key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') + user = bUser + key = bKey override = true // for multi-platform Kotlin/Native publishing publications = ['maven'] pkg {