Skip to content

Commit f39e7d6

Browse files
author
Marcel Schnelle
committed
Allow publishing of Snapshots to Sonatype OSS
1 parent ce3332b commit f39e7d6

File tree

7 files changed

+63
-98
lines changed

7 files changed

+63
-98
lines changed

.idea/runConfigurations/Publish_Release.xml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.idea/runConfigurations/Publish_Snapshot.xml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ env:
44
global:
55
- bintrayUser=aurae
66
- 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+
- sonatypeUser=aurae
8+
- secure: C6eYUpK0VYvnJ7FGvGP+2EhqHvUxLAslY6rgjewUihagWxh4Yn8pY2jeDEXvuQHoErkyhOSyEHvUqfzdVa+SuQdo1Ldn9Pzm90wvatWAyQCIkrg9bCyqYgz1Fx2GpwJJCyrqOQVpeR8aYFi0gUh+YbsHiiquwvIMLxpNmtVLYnauDsLcy36nEsixWWAJBPRBchwW3+hukv2ZjvS8VVktxWa1WhknAlVSxDaYhgMRBFbOXZcneP4I2VOYIz4zKAS1tqXF72EEQf74+1Zray/DSbm+LFvLy0eiq3JptxLVk2w5DV3BzeQKQLW0vr2tULzOO8XnTJcwiBHHzMGeSCjRgLDqj6D4wbXAh8YDWVfTHkjWYMMGfSXpS6TWkJhtg3nsmqa7LcH3uyZHxhTrJF4JTjmNlF4XaXrTOZVlAhKgfojMqlEexFW/C1RZxoMry/K5d1N/Pm4/ayFyNHHQ6wpMxXsO8IWEGIU5mkVigpq+9UIhN/HtH6tZ+1UQKsE7bcAfoQcDnrBoeDxAHNetkkueSRt3GpaVMlil2+EzgdBkl6c3ns5GV06m9e9Y4JRW05M+q38o9NV/pbUaljIJ8WPHtIfbGw8L8jwrka/HtI6+7z8ev61Ot/A8DNEmoZb/kUtk2KgD0E5aQYBaQzhxy9EImQiIM5UY6qrcNuqjnZBf3qk=
79

810
android:
911
components:
@@ -16,7 +18,7 @@ jdk:
1618
- oraclejdk8
1719

1820
before_install:
19-
- echo "sdk.dir=$ANDROID_HOME" > local.properties
21+
- echo "sdk.dir=$ANDROID_HOME" > local.properties
2022

2123
script: ./gradlew clean check --info --stacktrace
2224

android-junit5/build.gradle

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ apply plugin: "idea"
33
apply plugin: "maven"
44
apply plugin: "maven-publish"
55
apply plugin: "com.jfrog.bintray"
6-
apply plugin: "com.jfrog.artifactory"
76

87
sourceCompatibility = JavaVersion.VERSION_1_6
98
targetCompatibility = JavaVersion.VERSION_1_6
@@ -90,7 +89,7 @@ dependencies {
9089
// ------------------------------------------------------------------------------------------------
9190
// Deployment Setup
9291
//
93-
// Releases are pushed to jcenter via Bintray, and snapshots are pushed to OJO Artifactory.
92+
// Releases are pushed to jcenter via Bintray, while snapshots are pushed to Sonatype OSS.
9493
// This section defines the necessary tasks to push new releases and snapshots using Gradle tasks.
9594
// ------------------------------------------------------------------------------------------------
9695

@@ -141,40 +140,42 @@ task copyPom(type: Copy) {
141140

142141
publish.dependsOn copyPom
143142

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
143+
project.configure(project) {
144+
if (project.version.endsWith("-SNAPSHOT")) {
145+
// Configure deployment of snapshot versions to Sonatype OSS
146+
project.publishing {
147+
repositories {
148+
maven {
149+
name "snapshot"
150+
credentials {
151+
username project.ext.sonatypeUser
152+
password project.ext.sonatypePass
153+
}
154+
url "https://oss.sonatype.org/content/repositories/snapshots"
155+
}
156+
}
161157
}
162-
}
163-
}
164158

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")
159+
} else {
160+
// Configure deployment of release versions to Bintray
161+
project.bintray {
162+
user = project.ext.bintrayUser
163+
key = project.ext.bintrayKey
164+
configurations = ["archives"]
165+
dryRun = false
166+
pkg {
167+
repo = "maven"
168+
name = ARTIFACT_ID
169+
userOrg = project.ext.bintrayUser
170+
licenses = ["EPL-1.0"]
171+
publish = true
172+
publicDownloadNumbers = true
173+
vcsUrl = VCS_URL
174+
version {
175+
name = VERSION_NAME
176+
desc = DESCRIPTION
177+
}
178+
}
178179
}
179180
}
180181
}

build.gradle

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,45 @@ buildscript {
22
repositories {
33
google()
44
jcenter()
5-
maven { url "https://plugins.gradle.org/m2/" }
65
}
76
dependencies {
87
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$BINTRAY_PLUGIN_VERSION"
9-
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:$JFROG_PLUGIN_VERSION"
108
}
119
}
1210

1311
// Populate deployment credentials:
1412
// * Local development - stored in properties file
1513
// * CI Server - stored in environment variables
16-
def deploymentUser = ""
17-
def deploymentPass = ""
14+
def bintrayUser = ""
15+
def bintrayKey = ""
16+
def sonatypeUser = ""
17+
def sonatypePass = ""
1818

1919
def credentialsFile = new File(project.rootDir, "local.properties")
2020
if (credentialsFile.exists()) {
2121
Properties properties = new Properties()
2222
credentialsFile.withReader { properties.load(it) }
23-
deploymentUser = properties.get("BINTRAY_USER")
24-
deploymentPass = properties.get("BINTRAY_API_KEY")
23+
bintrayUser = properties.get("BINTRAY_USER")
24+
bintrayKey = properties.get("BINTRAY_KEY")
25+
sonatypeUser = properties.get("SONATYPE_USER")
26+
sonatypePass = properties.get("SONATYPE_PASS")
2527

2628
} else {
27-
deploymentUser = System.getenv("bintrayUser")
28-
deploymentPass = System.getenv("bintrayKey")
29+
bintrayUser = System.getenv("bintrayUser")
30+
bintrayKey = System.getenv("bintrayKey")
31+
sonatypeUser = System.getenv("sonatypeUser")
32+
sonatypePass = System.getenv("sonatypePass")
2933
}
3034

3135
allprojects {
3236
repositories {
3337
google()
3438
jcenter()
3539
}
36-
ext {
37-
bintrayUser = deploymentUser
38-
bintrayKey = deploymentPass
39-
}
40+
41+
// Store deployment credentials
42+
ext.bintrayUser = bintrayUser
43+
ext.bintrayKey = bintrayKey
44+
ext.sonatypeUser = sonatypeUser
45+
ext.sonatypePass = sonatypePass
4046
}

gradle.properties

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ VCS_URL = https://github.com/aurae/android-junit5
1010
# Dependency versions (plugins)
1111
ANDROID_PLUGIN_VERSION_2X = 2.3.2
1212
ANDROID_PLUGIN_VERSION_3X = 3.0.0-alpha5
13-
BINTRAY_PLUGIN_VERSION = 1.3.1
14-
JFROG_PLUGIN_VERSION = 4.1.1
13+
BINTRAY_PLUGIN_VERSION = 1.7.3
1514

1615
# Dependency versions
1716
SEMVER_VERSION = 0.9.0

scripts/deploy_snapshot.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#!/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/
27

38
SLUG="aurae/android-junit5"
49
JDK="oraclejdk8"
@@ -16,6 +21,6 @@ elif [ "$TRAVIS_BRANCH" != "$BRANCH" ]; then
1621
echo "Skipping snapshot deployment: wrong branch. Expected '$BRANCH' but was '$TRAVIS_BRANCH'."
1722
else
1823
echo "Deploying snapshot..."
19-
./gradlew artifactoryPublish
24+
./gradlew publishLibraryPublicationToSnapshotRepository
2025
echo "Snapshot deployed!"
2126
fi

0 commit comments

Comments
 (0)