Skip to content

Commit 9797259

Browse files
authored
Connected to Travis CI (#12)
Connected to Travis CI deployment pipeline
1 parent a0152b3 commit 9797259

File tree

9 files changed

+206
-62
lines changed

9 files changed

+206
-62
lines changed

.idea/runConfigurations/Upload_to_Bintray.xml renamed to .idea/runConfigurations/Publish_Release.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/Publish_Snapshot.xml

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.travis.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
language: android
2+
3+
env:
4+
global:
5+
- bintrayUser=aurae
6+
- secure: VoY/zWE7itJmukAZt1Zw43jFzOk2ssWbpWhydYLiaRvplYVJvXTCSve4ZDpBhxPAlta2Kpfr9H8bwuaYCEtS+ovhi/q8Fo97YXiGdkHwEXJPal2n4O/XEj5hFr1BxIDTEwFBtGD/iQWZL/MVRaWFrfuMWajMZhDQkGz+DwRog4XCaw6UcEofW9kzfPG1T94C/bAIETrad4bfHKSbORVd2SbyPCFHkFH+YB/eWVqK2N5PuiPaet+EzcX/sxAFnwD6kF/uj3KxTlii/Yw8bM6LrPEWyyuMDglHN3LTevZ1CwT1oy8AUZaFzx246SL+Osn6t9WHoL1p3ltTS9O7sNL6WSyCP+JFYXF8iaF9USaINy/vcZFPsKdcCpgLPjSF/4mgXcjPc5KRao3tZOoamyvXuiGg7lfwUBl82t73ItlnSGgInAyUSesVrQ2gJNsVHdRqvOmVPBGXZ3lWb4GHksfQzLO210M7Tiu6leacWEbsYWmAsRER87qdUu7lY2b3wYJB7NhXX5AMZYINSzfCDVrThTWLXUU554D/3TmTKz/ROab2QxR/Qxh5i4ZJ/0MNdcM+qp8ORq6WlwGTUhCmD83XtiuBF3s/JW1WybsqC4Ppo23YuItqgfmMZWk75xLqpi48078vNgtEE/1YE2tvxd7ddfeT3eNLt7qrfj7Hu+r3L5A=
7+
8+
android:
9+
components:
10+
- tools
11+
- platform-tools
12+
- build-tools-26.0.0
13+
- android-26
14+
15+
jdk:
16+
- oraclejdk8
17+
18+
before_install:
19+
- echo "sdk.dir=$ANDROID_HOME" > local.properties
20+
21+
script: ./gradlew clean check --info --stacktrace
22+
23+
after_success:
24+
- ./scripts/deploy_snapshot.sh
25+
26+
deploy:
27+
provider: script
28+
script: ./scripts/deploy_release.sh
29+
on:
30+
tags: true
31+
repo: aurae/android-junit5

android-junit5/build.gradle

Lines changed: 94 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1-
apply plugin: 'groovy'
2-
apply plugin: 'idea'
3-
apply plugin: 'maven'
4-
apply plugin: 'maven-publish'
5-
apply plugin: 'com.jfrog.bintray'
1+
apply plugin: "groovy"
2+
apply plugin: "idea"
3+
apply plugin: "maven"
4+
apply plugin: "maven-publish"
5+
apply plugin: "com.jfrog.bintray"
6+
apply plugin: "com.jfrog.artifactory"
67

78
sourceCompatibility = JavaVersion.VERSION_1_6
89
targetCompatibility = JavaVersion.VERSION_1_6
910

11+
// ------------------------------------------------------------------------------------------------
12+
// Test Setup
13+
//
14+
// We run our unit tests against multiple versions of the Android Gradle Plugin,
15+
// in order to support logical & structural intricacies of both the 2.x & 3.x line of plugins.
16+
// To achieve this, several new source sets & configurations for each branch are created here,
17+
// which are derived from the common "test" scope.
18+
// ------------------------------------------------------------------------------------------------
19+
1020
configurations {
1121
testAgp2xCompile {
1222
extendsFrom configurations.testCompile
@@ -40,6 +50,28 @@ idea {
4050
}
4151
}
4252

53+
// Run Unit Tests against Android Gradle Plugin version 2.x
54+
task testAgp2x(type: Test) {
55+
testClassesDirs = sourceSets.testAgp2x.output.classesDirs
56+
classpath = sourceSets.main.runtimeClasspath + sourceSets.testAgp2x.runtimeClasspath
57+
}
58+
59+
// Run Unit Tests against Android Gradle Plugin version 3.x
60+
task testAgp3x(type: Test) {
61+
testClassesDirs = sourceSets.testAgp3x.output.classesDirs
62+
classpath = sourceSets.main.runtimeClasspath + sourceSets.testAgp3x.runtimeClasspath
63+
}
64+
65+
// Combine all tests when executing the main JUnit task
66+
tasks.getByName("test").dependsOn(
67+
testAgp2x,
68+
testAgp3x
69+
)
70+
71+
// ------------------------------------------------------------------------------------------------
72+
// Dependency Definitions
73+
// ------------------------------------------------------------------------------------------------
74+
4375
dependencies {
4476
compile gradleApi()
4577
compile localGroovy()
@@ -55,46 +87,32 @@ dependencies {
5587
testAgp3xCompile "com.android.tools.build:gradle:$ANDROID_PLUGIN_VERSION_3X"
5688
}
5789

58-
// Run Unit Tests against Android Gradle Plugin version 2.x
59-
task testAgp2x(type: Test) {
60-
testClassesDirs = sourceSets.testAgp2x.output.classesDirs
61-
classpath = sourceSets.main.runtimeClasspath + sourceSets.testAgp2x.runtimeClasspath
90+
// ------------------------------------------------------------------------------------------------
91+
// Deployment Setup
92+
//
93+
// Releases are pushed to jcenter via Bintray, and snapshots are pushed to OJO Artifactory.
94+
// This section defines the necessary tasks to push new releases and snapshots using Gradle tasks.
95+
// ------------------------------------------------------------------------------------------------
96+
97+
// Include sources.jar archive in each release
98+
task sourcesJar(type: Jar, dependsOn: classes) {
99+
classifier = "sources"
100+
from sourceSets.main.allSource
62101
}
63102

64-
// Run Unit Tests against Android Gradle Plugin version 3.x
65-
task testAgp3x(type: Test) {
66-
testClassesDirs = sourceSets.testAgp3x.output.classesDirs
67-
classpath = sourceSets.main.runtimeClasspath + sourceSets.testAgp3x.runtimeClasspath
103+
// Include javadoc.jar archive in each release
104+
task javadocJar(type: Jar, dependsOn: javadoc) {
105+
classifier = "javadoc"
106+
from javadoc.destinationDir
68107
}
69108

70-
// Combine all tests when executing the main JUnit task
71-
tasks.getByName("test").dependsOn(
72-
testAgp2x,
73-
testAgp3x
74-
)
109+
artifacts {
110+
archives sourcesJar
111+
archives javadocJar
112+
}
75113

76114
version = VERSION_NAME
77115

78-
bintray {
79-
user = project.ext.bintrayUser
80-
key = project.ext.bintrayApiKey
81-
configurations = ['archives']
82-
dryRun = false
83-
pkg {
84-
repo = 'maven'
85-
name = ARTIFACT_ID
86-
userOrg = properties.get("BINTRAY_USER")
87-
licenses = ["EPL-1.0"]
88-
publish = true
89-
publicDownloadNumbers = true
90-
vcsUrl = VCS_URL
91-
version {
92-
name = VERSION_NAME
93-
desc = DESCRIPTION
94-
}
95-
}
96-
}
97-
98116
publishing {
99117
publications {
100118
library(MavenPublication) {
@@ -114,25 +132,49 @@ publishing {
114132
}
115133
}
116134

135+
// Copy POM to location expected by Bintray
117136
task copyPom(type: Copy) {
118-
from 'build/publications/library'
119-
into 'build/poms'
120-
include 'pom-default.xml'
137+
from "build/publications/library"
138+
into "build/poms"
139+
include "pom-default.xml"
121140
}
122141

123142
publish.dependsOn copyPom
124143

125-
task sourcesJar(type: Jar, dependsOn: classes) {
126-
classifier = 'sources'
127-
from sourceSets.main.allSource
128-
}
129-
130-
task javadocJar(type: Jar, dependsOn: javadoc) {
131-
classifier = 'javadoc'
132-
from javadoc.destinationDir
144+
// Configure deployment of release versions to Bintray
145+
bintray {
146+
user = project.ext.bintrayUser
147+
key = project.ext.bintrayKey
148+
configurations = ["archives"]
149+
dryRun = false
150+
pkg {
151+
repo = "maven"
152+
name = ARTIFACT_ID
153+
userOrg = project.ext.bintrayUser
154+
licenses = ["EPL-1.0"]
155+
publish = true
156+
publicDownloadNumbers = true
157+
vcsUrl = VCS_URL
158+
version {
159+
name = VERSION_NAME
160+
desc = DESCRIPTION
161+
}
162+
}
133163
}
134164

135-
artifacts {
136-
archives sourcesJar
137-
archives javadocJar
165+
// Configure deployment of snapshots to Artifactory
166+
artifactory {
167+
contextUrl = "https://oss.jfrog.org/artifactory"
168+
publish {
169+
repository {
170+
repoKey = VERSION_NAME.endsWith("SNAPSHOT") ? "oss-snapshot-local" : "oss-release-local"
171+
username = project.ext.bintrayUser
172+
password = project.ext.bintrayKey
173+
maven = true
174+
}
175+
defaults {
176+
publishArtifacts = true
177+
publications("library")
178+
}
179+
}
138180
}

android-junit5/src/test/groovy/de/mannodermaus/gradle/plugins/android_junit5/AndroidJUnitPlatformSpec.groovy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import spock.lang.Specification
1515
*/
1616
abstract class AndroidJUnitPlatformSpec extends Specification {
1717

18-
protected static final COMPILE_SDK = 25
19-
protected static final BUILD_TOOLS = "25.0.2"
20-
protected static final MIN_SDK = 25
21-
protected static final TARGET_SDK = 25
18+
protected static final COMPILE_SDK = 26
19+
protected static final BUILD_TOOLS = "26.0.0"
20+
protected static final MIN_SDK = 26
21+
protected static final TARGET_SDK = 26
2222
protected static final VERSION_CODE = 1
2323
protected static final VERSION_NAME = "1.0"
2424
protected static final APPLICATION_ID = "org.junit.android.sample"

build.gradle

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,35 @@ buildscript {
66
}
77
dependencies {
88
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$BINTRAY_PLUGIN_VERSION"
9+
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:$JFROG_PLUGIN_VERSION"
910
}
1011
}
1112

12-
Properties properties = new Properties()
13-
properties.load(new FileInputStream(new File(rootProject.projectDir, "local.properties")))
13+
// Populate deployment credentials:
14+
// * Local development - stored in properties file
15+
// * CI Server - stored in environment variables
16+
def deploymentUser = ""
17+
def deploymentPass = ""
18+
19+
def credentialsFile = new File(project.rootDir, "local.properties")
20+
if (credentialsFile.exists()) {
21+
Properties properties = new Properties()
22+
credentialsFile.withReader { properties.load(it) }
23+
deploymentUser = properties.get("BINTRAY_USER")
24+
deploymentPass = properties.get("BINTRAY_API_KEY")
25+
26+
} else {
27+
deploymentUser = System.getenv("bintrayUser")
28+
deploymentPass = System.getenv("bintrayKey")
29+
}
30+
1431
allprojects {
1532
repositories {
1633
google()
1734
jcenter()
1835
}
1936
ext {
20-
bintrayUser = properties.get('BINTRAY_USER')
21-
bintrayApiKey = properties.get('BINTRAY_API_KEY')
37+
bintrayUser = deploymentUser
38+
bintrayKey = deploymentPass
2239
}
2340
}

gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
# Artifact configuration
44
GROUP_ID = de.mannodermaus.gradle.plugins
55
ARTIFACT_ID = android-junit5
6-
VERSION_NAME = 1.0.0-M4-rev3
6+
VERSION_NAME = 1.0.0-M5-SNAPSHOT
77
DESCRIPTION = Unit Testing with JUnit 5 for Android.
88
VCS_URL = https://github.com/aurae/android-junit5
99

1010
# Dependency versions (plugins)
1111
ANDROID_PLUGIN_VERSION_2X = 2.3.2
1212
ANDROID_PLUGIN_VERSION_3X = 3.0.0-alpha5
1313
BINTRAY_PLUGIN_VERSION = 1.3.1
14+
JFROG_PLUGIN_VERSION = 4.1.1
1415

1516
# Dependency versions
1617
SEMVER_VERSION = 0.9.0

scripts/deploy_release.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
../gradlew clean build generatePomFileForLibraryPublication publish bintrayUpload -PbintrayUser=$bintrayUser -PbintrayKey=$bintrayKey -PdryRun=false

scripts/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="aurae/android-junit5"
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 artifactoryPublish
25+
echo "Snapshot deployed!"
26+
fi

0 commit comments

Comments
 (0)