Skip to content
This repository has been archived by the owner on Sep 12, 2019. It is now read-only.

Commit

Permalink
Auto-deploy snapshots from Travis CI to Sonatype.
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeWharton committed Dec 20, 2014
1 parent 6281692 commit 84d397f
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 17 deletions.
26 changes: 26 additions & 0 deletions .buildscript/deploy_snapshot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
#
# Deploy a jar, source jar, and javadoc jar to Sonatype's snapshot repo.
#
# Adapted from https://coderwall.com/p/9b_lfq and
# http://benlimmer.com/2013/12/26/automatically-publish-javadoc-to-gh-pages-with-travis-ci/

SLUG="JakeWharton/kotterknife"
JDK="oraclejdk8"
BRANCH="master"

set -e

if [ "$TRAVIS_REPO_SLUG" != "$SLUG" ]; then
echo "Skipping snapshot deployment: wrong repository. Expected '$SLUG' but was '$TRAVIS_REPO_SLUG'."
elif [ "$TRAVIS_JDK_VERSION" != "$JDK" ]; then
echo "Skipping snapshot deployment: wrong JDK. Expected '$JDK' but was '$TRAVIS_JDK_VERSION'."
elif [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo "Skipping snapshot deployment: was pull request."
elif [ "$TRAVIS_BRANCH" != "$BRANCH" ]; then
echo "Skipping snapshot deployment: wrong branch. Expected '$BRANCH' but was '$TRAVIS_BRANCH'."
else
echo "Deploying snapshot..."
./gradlew clean uploadArchives
echo "Snapshot deployed!"
fi
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,36 @@ android:
licenses:
- android-sdk-license-5be876d5

jdk:
- oraclejdk7
- oraclejdk8

before_script:
- echo no | android create avd --force -n test -t android-21 --abi armeabi-v7a
- emulator -avd test -no-skin -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &

script:
- ./gradlew clean check

after_success:
- .buildscript/deploy_snapshot.sh

env:
global:
- secure: "amz+2SCRt5S3FaDiqq6WhgdFW0lLjaAJWs8NmmUa1EX4/qU2NsLAFgTUPQmGMu7wqyLgGDcnloyYZTqvSl9d0g0KO10btrtZAFnRXR8GbXA9ca9jqASt2mIQQ4UCKw6zsqyToEsjkaEy+IrYdq7En1EKvgF9W7sxae5HiI+bijw="
- secure: "YcF37d5xm9jFqKeueXLPHAgve2DPxk3IaXqJ1bBVyufVHBlXsc1vs7WatQwPgtyfX5ZBdrh0APW1PaFz3XRzlee+82iRL5R6iUHJnZVaZzT8a/OkAZsriMHXGsmB0VW2fs1eomV7kapqP8Zff/yCvEbp3JmLWVlhJUK4M+9FSFk="

branches:
except:
- gh-pages

notifications:
email: false

sudo: false

cache:
directories:
- $HOME/.gradle
26 changes: 9 additions & 17 deletions gradle/gradle-mvn-push.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,12 @@ def isReleaseBuild() {
return VERSION_NAME.contains("SNAPSHOT") == false
}

def getReleaseRepositoryUrl() {
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}

def getSnapshotRepositoryUrl() {
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
: "https://oss.sonatype.org/content/repositories/snapshots/"
}

def getRepositoryUsername() {
return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
return hasProperty('SONATYPE_NEXUS_USERNAME') ? SONATYPE_NEXUS_USERNAME : ""
}

def getRepositoryPassword() {
return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
return hasProperty('SONATYPE_NEXUS_PASSWORD') ? SONATYPE_NEXUS_PASSWORD : ""
}

afterEvaluate { project ->
Expand All @@ -49,10 +39,10 @@ afterEvaluate { project ->
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION_NAME

repository(url: getReleaseRepositoryUrl()) {
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
snapshotRepository(url: getSnapshotRepositoryUrl()) {
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}

Expand Down Expand Up @@ -93,18 +83,20 @@ afterEvaluate { project ->
}

//task androidJavadocs(type: Javadoc) {
// source = android.sourceSets.main.java
// source = android.sourceSets.main.java.srcDirs
// classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
//}
//
// options.addStringOption('Xdoclint:none', '-quiet')
//}

//task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
// classifier = 'javadoc'
// from androidJavadocs.destinationDir
//}

//task androidSourcesJar(type: Jar) {
// classifier = 'sources'
// from android.sourceSets.main.java
// from android.sourceSets.main.java.sourceFiles
//}

artifacts {
Expand Down

0 comments on commit 84d397f

Please sign in to comment.