Skip to content

Commit 3324cca

Browse files
committed
Add sonatype publishing
1 parent 54fcc91 commit 3324cca

File tree

2 files changed

+40
-7
lines changed

2 files changed

+40
-7
lines changed

.travis.yml

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +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:
21+
stages:
22+
- test
23+
- deploy
24+
25+
env:
26+
- JOB=check
27+
28+
jobs:
2029
fast_finish: true
2130

31+
allow_failures:
32+
- env: JOB=sonatype
33+
2234
include:
23-
- jdk: oraclejdk8
24-
after_success: ./gradlew jacocoTestReport coveralls sonarqube
25-
- jdk: oraclejdk11
35+
# JDK 8
36+
- name: "Java 8"
37+
stage: test
38+
jdk: oraclejdk8
39+
script: ./gradlew check install jacocoTestReport
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
2647

27-
script: ./gradlew clean check install
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
@@ -155,8 +155,8 @@ signing {
155155

156156
uploadArchives {
157157
repositories.mavenDeployer {
158-
def sonatypeUsername = project.hasProperty('ossrhUsername') ? ossrhUsername : ""
159-
def sonatypePassword = project.hasProperty('ossrhPassword') ? ossrhPassword : ""
158+
def sonatypeUsername = project.hasProperty('ossrhUsername') ? ossrhUsername : System.getenv("SONATYPE_USERNAME") ?: ""
159+
def sonatypePassword = project.hasProperty('ossrhPassword') ? ossrhPassword : System.getenv("SONATYPE_PASSWORD") ?: ""
160160
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
161161

162162
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
@@ -265,6 +265,12 @@ task docs(type: Javadoc) {
265265
}
266266
}
267267

268+
task getVersion {
269+
doLast {
270+
println project.version
271+
}
272+
}
273+
268274
afterReleaseBuild.dependsOn uploadArchives
269275
afterReleaseBuild.dependsOn docs
270276

0 commit comments

Comments
 (0)