Skip to content

Commit b5a43df

Browse files
committed
Add deployment stage
1 parent 2e85d9c commit b5a43df

File tree

2 files changed

+43
-9
lines changed

2 files changed

+43
-9
lines changed

.travis.yml

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,45 @@ addons:
1010
before_cache:
1111
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
1212
- rm -rf $HOME/.gradle/caches/*/plugin-resolution/
13+
- rm -f $HOME/.gradle/caches/*/fileHashes/fileHashes.bin
14+
- rm -f $HOME/.gradle/caches/*/fileHashes/fileHashes.lock
1315

1416
cache:
1517
directories:
1618
- $HOME/.gradle/caches/
1719
- $HOME/.gradle/wrapper/
1820

19-
matrix:
20-
fast_finish: true
21-
include:
22-
- jdk: oraclejdk8
23-
after_success: "./gradlew jacocoRootReport coveralls sonarqube"
24-
- jdk: oraclejdk11
21+
stages:
22+
- test
23+
- deploy
2524

26-
script: "./gradlew clean check install"
25+
env:
26+
- JOB=check
27+
28+
jobs:
29+
fast_finish: true
30+
31+
allow_failures:
32+
- env: JOB=sonatype
33+
34+
include:
35+
# JDK 8
36+
- name: "Java 8"
37+
stage: test
38+
jdk: oraclejdk8
39+
script: ./gradlew check install jacocoRootReport
40+
after_success: ./gradlew coveralls sonarqube
41+
42+
# JDK 11
43+
- name: "Java 11"
44+
stage: test
45+
jdk: oraclejdk11
46+
script: ./gradlew check install
47+
48+
- name: "Publish to Sonatype"
49+
stage: deploy
50+
jdk: oraclejdk8
51+
env: JOB=sonatype
52+
if: branch = master AND type = push
53+
# Only automate the publication of SNAPSHOTS
54+
script: if [[ $(./gradlew -q getVersion) == *SNAPSHOT* ]]; then ./gradlew publish ; fi

build.gradle

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ subprojects { subproj ->
207207
}
208208
repositories {
209209
maven {
210-
def sonatypeUsername = project.hasProperty('ossrhUsername') ? ossrhUsername : ""
211-
def sonatypePassword = project.hasProperty('ossrhPassword') ? ossrhPassword : ""
210+
def sonatypeUsername = project.hasProperty('ossrhUsername') ? ossrhUsername : System.getenv("SONATYPE_USERNAME") ?: ""
211+
def sonatypePassword = project.hasProperty('ossrhPassword') ? ossrhPassword : System.getenv("SONATYPE_PASSWORD") ?: ""
212212
if (version.endsWith("SNAPSHOT")) {
213213
url "https://oss.sonatype.org/content/repositories/snapshots/"
214214
} else {
@@ -369,4 +369,10 @@ configure(rootProject) {
369369
tasks.coveralls {
370370
dependsOn 'jacocoRootReport'
371371
}
372+
373+
task getVersion {
374+
doLast {
375+
println project.version
376+
}
377+
}
372378
}

0 commit comments

Comments
 (0)