Add SNAPSHOT archives upload

This commit is contained in:
Marcin Zajaczkowski
2016-05-14 00:06:43 +02:00
parent fb60a10f0e
commit 430bcd0162
4 changed files with 48 additions and 3 deletions

View File

@@ -9,8 +9,15 @@ before_install:
- "cp -r stub-runner/stub-runner-spring/src/test/resources/m2repo/repository/io/codearte/accurest/stubs $HOME/.m2/repository/io/codearte/accurest/"
jdk:
- oraclejdk7
- oraclejdk8
install: ./gradlew assemble -s
script: ./gradlew check funcTest install -s --continue && jdk_switcher use oraclejdk8 && ./scripts/runTests.sh
script: ./gradlew check funcTest install -s --continue && jdk_switcher use oraclejdk8 && ./scripts/runTests.sh && jdk_switcher use $TRAVIS_JDK_VERSION && ./gradlew uploadSnapshotArchives -s
matrix:
include:
# Automatic snapshot release only in Java 7 build
- jdk: oraclejdk7
env:
- DO_RELEASE=true

View File

@@ -36,6 +36,8 @@ nexusStaging {
stagingProfileId = '93c08fdebde1ff'
}
apply from: "$rootDir/gradle/releaseRoot.gradle"
subprojects {
apply plugin: 'groovy'
apply from: "$rootDir/gradle/release.gradle"
@@ -211,4 +213,5 @@ buildscript {
}
}
apply plugin: "com.palantir.idea-test-fix"
apply plugin: "com.palantir.idea-test-fix"

View File

@@ -38,3 +38,22 @@ modifyPom {
uploadArchives.dependsOn { check }
task uploadSnapshotArchives {
if (shouldUploadSnapshotArchives) {
dependsOn { uploadArchives }
}
onlyIf { shouldUploadSnapshotArchives }
}
//for Travis to leverage secure variables
project.ext {
if (!hasProperty('nexusUsername') && System.env.NEXUS_USERNAME) {
nexusUsername = System.env.NEXUS_USERNAME
}
if (!hasProperty('nexusPassword') && System.env.NEXUS_PASSWORD) {
nexusPassword = System.env.NEXUS_PASSWORD
}
}

16
gradle/releaseRoot.gradle Normal file
View File

@@ -0,0 +1,16 @@
assert project == rootProject
project.ext {
isSnapshot = project.version.endsWith("-SNAPSHOT")
currentBranch = System.env.TRAVIS_BRANCH
isPr = !isNullOrFalse(System.env.TRAVIS_PULL_REQUEST)
doRelease = !isNullOrFalse(System.env.DO_RELEASE)
shouldUploadSnapshotArchives = isSnapshot && currentBranch == 'master' && !isPr && doRelease
}
logger.lifecycle("Automatic snapshot release: {} (isSnapshot: {}, currentBranch: {}, isPr: {}, doRelease: {})", shouldUploadSnapshotArchives, isSnapshot, currentBranch, isPr, doRelease)
private boolean isNullOrFalse(def env) {
env == null || env == "false" || (env instanceof Boolean && !env)
}