Skip to content

Commit d2a5962

Browse files
committed
Auto-deploy snapshots from Travis CI to Sonatype.
1 parent 5b8d1c8 commit d2a5962

File tree

4 files changed

+57
-18
lines changed

4 files changed

+57
-18
lines changed

.buildscript/deploy_snapshot.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
#
3+
# Deploy a jar, source jar, and javadoc jar to Sonatype's snapshot repo.
4+
#
5+
# Adapted from https://coderwall.com/p/9b_lfq and
6+
# http://benlimmer.com/2013/12/26/automatically-publish-javadoc-to-gh-pages-with-travis-ci/
7+
8+
SLUG="square/assertj-android"
9+
JDK="oraclejdk8"
10+
BRANCH="master"
11+
12+
set -e
13+
14+
if [ "$TRAVIS_REPO_SLUG" != "$SLUG" ]; then
15+
echo "Skipping snapshot deployment: wrong repository. Expected '$SLUG' but was '$TRAVIS_REPO_SLUG'."
16+
elif [ "$TRAVIS_JDK_VERSION" != "$JDK" ]; then
17+
echo "Skipping snapshot deployment: wrong JDK. Expected '$JDK' but was '$TRAVIS_JDK_VERSION'."
18+
elif [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
19+
echo "Skipping snapshot deployment: was pull request."
20+
elif [ "$TRAVIS_BRANCH" != "$BRANCH" ]; then
21+
echo "Skipping snapshot deployment: wrong branch. Expected '$BRANCH' but was '$TRAVIS_BRANCH'."
22+
else
23+
echo "Deploying snapshot..."
24+
./gradlew clean uploadArchives
25+
echo "Snapshot deployed!"
26+
fi

.travis.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,33 @@ android:
99
licenses:
1010
- android-sdk-license-5be876d5
1111

12+
jdk:
13+
- oraclejdk7
14+
- oraclejdk8
15+
16+
before_install:
17+
- ./check-missing-assertions.sh
18+
19+
script:
20+
- ./gradlew clean check
21+
22+
after_success:
23+
- .buildscript/deploy_snapshot.sh
24+
25+
env:
26+
global:
27+
- secure: "Z09ZjFkdbvkqpqwzeqz1W9/yPo5IKtsPeRDjplXVeNSZGBLm/YOyzKHZ2htROIrck31Edl/k79fC9P9jaL98VrI4EfzeAg1pXWeQWjqpPoBsyI8kYIf5OmJecOqxFhcE7hTJNI7XxmfzMpMkK8946oegWna9Bf1WWDgW/7iHHgo="
28+
- secure: "icw0oEYt9x2BJ5f1m3nFVV+QkBfDAYs/H6toNeqf/jFuPSbyl+TNTCKTUJj4BKCwmMjLsDSsR3TZi4iKfTQu6x1A8w+2u7gw/wQrFY2tzPqW7/BlOMFEGS/tWpRmw1sLwqQEFd+Fa2Redy2xQywcwFAgjN0zFTfFOQU4UBIcAQo="
29+
1230
branches:
1331
except:
1432
- gh-pages
1533

1634
notifications:
1735
email: false
1836

19-
before_install:
20-
- ./check-missing-assertions.sh
37+
sudo: false
2138

22-
script:
23-
- ./gradlew clean check
39+
cache:
40+
directories:
41+
- $HOME/.gradle

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ pallete-v7 module:
191191
androidTestCompile 'com.squareup.assertj:assertj-android-pallete-v7:1.0.0'
192192
```
193193

194+
Snapshots of the development version are available in [Sonatype's `snapshots` repository][snap].
195+
194196

195197

196198
License
@@ -215,3 +217,4 @@ License
215217

216218
[1]: http://joel-costigliola.github.io/assertj/
217219
[2]: http://joel-costigliola.github.io/assertj/assertj-core-custom-assertions.html
220+
[snap]: https://oss.sonatype.org/content/repositories/snapshots/

gradle/gradle-mvn-push.gradle

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,12 @@ def isReleaseBuild() {
2121
return VERSION_NAME.contains("SNAPSHOT") == false
2222
}
2323

24-
def getReleaseRepositoryUrl() {
25-
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
26-
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
27-
}
28-
29-
def getSnapshotRepositoryUrl() {
30-
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
31-
: "https://oss.sonatype.org/content/repositories/snapshots/"
32-
}
33-
3424
def getRepositoryUsername() {
35-
return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
25+
return hasProperty('SONATYPE_NEXUS_USERNAME') ? SONATYPE_NEXUS_USERNAME : ""
3626
}
3727

3828
def getRepositoryPassword() {
39-
return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
29+
return hasProperty('SONATYPE_NEXUS_PASSWORD') ? SONATYPE_NEXUS_PASSWORD : ""
4030
}
4131

4232
afterEvaluate { project ->
@@ -49,10 +39,10 @@ afterEvaluate { project ->
4939
pom.artifactId = POM_ARTIFACT_ID
5040
pom.version = VERSION_NAME
5141

52-
repository(url: getReleaseRepositoryUrl()) {
42+
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
5343
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
5444
}
55-
snapshotRepository(url: getSnapshotRepositoryUrl()) {
45+
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
5646
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
5747
}
5848

@@ -95,6 +85,8 @@ afterEvaluate { project ->
9585
task androidJavadocs(type: Javadoc) {
9686
source = android.sourceSets.main.java.srcDirs
9787
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
88+
89+
options.addStringOption('Xdoclint:none', '-quiet')
9890
}
9991

10092
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {

0 commit comments

Comments
 (0)