From 9ca54dfd3f2477d5da9d37b6de07791541af0899 Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Fri, 19 Feb 2016 19:49:17 -0800 Subject: Add Artifactory publishing for snapshots --- .travis.yml | 2 +- publish.gradle | 39 ++++++++++++++++++++++++++++++++++++--- sshlib/build.gradle | 11 +++-------- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3981a62..e3caf10 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ before_cache: - find $HOME/.gradle -name "*.lock" -exec rm {} \; - rm -rf $HOME/.gradle/caches/[1-9]* after_success: -- "./gradlew bintrayUpload" +- "./gradlew bintrayUpload artifactoryPublish" env: global: - bintrayUser=kruton diff --git a/publish.gradle b/publish.gradle index d5c69e1..348265c 100644 --- a/publish.gradle +++ b/publish.gradle @@ -1,4 +1,5 @@ apply plugin: 'maven' +apply plugin: 'maven-publish' task sourcesJar(type: Jar, dependsOn: classes) { classifier = 'sources' @@ -11,7 +12,20 @@ task javadocJar(type: Jar, dependsOn: javadoc) { } artifacts { - archives sourcesJar, javadocJar + archives jar, sourcesJar, javadocJar +} + +ext.isSnapshot = (VersionNumber.parse(rootProject.version).qualifier == "SNAPSHOT") +ext.isOfficialSdk = (System.env.TRAVIS_JDK_VERSION == officialJdk) +ext.isMainline = (System.env.TRAVIS_PULL_REQUEST == "false") + +publishing { + publications { + Sshlib(MavenPublication) { + from components.java + groupId 'org.connectbot' + } + } } uploadArchives { @@ -81,7 +95,26 @@ bintray { } } +//Bintray is for official releases bintrayUpload.onlyIf { - System.env.TRAVIS_JDK_VERSION == officialJdk && - !(version ==~ /.*SNAPSHOT/) + project.isOfficialSdk && !project.isSnapshot && project.isMainline } + +artifactory { + contextUrl = 'http://oss.jfrog.org/artifactory' + publish { + repository { + repoKey = 'oss-snapshot-local' + username = bintrayUser + password = bintrayApiKey + } + defaults { + publications('Sshlib') + } + } +} + +//Artifactory is for publishing snapshots +artifactoryPublish.onlyIf { + project.isOfficialSdk && project.isSnapshot && project.isMainline +} \ No newline at end of file diff --git a/sshlib/build.gradle b/sshlib/build.gradle index 5949330..1c36976 100644 --- a/sshlib/build.gradle +++ b/sshlib/build.gradle @@ -1,14 +1,9 @@ -buildscript { - repositories { - jcenter() - } - dependencies { - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1' - } +plugins { + id 'com.jfrog.artifactory' version '4.0.0' + id 'com.jfrog.bintray' version '1.1' } apply plugin: 'java' -apply plugin: 'com.jfrog.bintray' apply from: "${rootDir}/publish.gradle" dependencies { -- cgit v1.2.3