Skip to content

Commit 7a4fa73

Browse files
author
Karl Rieb
committed
- Fix release.gradle build script to properly sign and upload archives
- Update dependencies - Fix misconfigured releaseTest task Fixes T98011
1 parent 8a50510 commit 7a4fa73

3 files changed

Lines changed: 52 additions & 40 deletions

File tree

build.gradle

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
apply plugin: 'java'
22
apply plugin: 'osgi'
33
apply plugin: 'maven'
4+
apply plugin: 'com.github.ben-manes.versions' // dependencyUpdates task
45

56
description = 'Official Java client library for the Dropbox API.'
67
group = 'com.dropbox.core'
@@ -13,13 +14,15 @@ targetCompatibility = JavaVersion.VERSION_1_6
1314
conf2ScopeMappings.addMapping(1, configurations.compileOnly, 'provided')
1415

1516
ext {
17+
mavenName = 'Official Dropbox Java SDK'
1618
generatedSources = file("$buildDir/generated-sources")
1719
generatedResources = file("$buildDir/generated-resources")
1820
authInfoPropertyName = 'com.dropbox.test.authInfoFile'
1921
basePom = pom {
20-
name = 'Official Dropbox Java SDK'
22+
name = mavenName
2123
artifactId = archivesBaseName
2224
project {
25+
description = description
2326
packaging 'jar'
2427
url 'https://www.dropbox.com/developers/core'
2528

@@ -54,6 +57,7 @@ buildscript {
5457
jcenter()
5558
mavenCentral()
5659
}
60+
5761
dependencies {
5862
classpath 'com.github.ben-manes:gradle-versions-plugin:0.12.0'
5963
}
@@ -72,7 +76,7 @@ dependencies {
7276
compileOnly 'com.squareup.okhttp:okhttp:2.7.5'
7377
compileOnly 'com.google.android:android:4.1.1.4'
7478

75-
testCompile 'org.testng:testng:6.9.10'
79+
testCompile 'org.testng:testng:6.9.11'
7680
testCompile 'org.mockito:mockito-core:1.10.19'
7781
testCompile 'org.openjdk.jmh:jmh-core:1.12'
7882
testCompile 'org.openjdk.jmh:jmh-generator-annprocess:1.12'
@@ -174,7 +178,7 @@ task integrationTest(type: Test) {
174178
}
175179

176180
javadoc {
177-
title "${project.name} ${project.version} API"
181+
title "${project.mavenName} ${project.version} API"
178182
failOnError true
179183

180184
// JDK 8's javadoc has an on-by-default lint called "missing", which requires that everything
@@ -238,6 +242,20 @@ if (project.sourceCompatibility == JavaVersion.VERSION_1_6) {
238242
}
239243
}
240244

245+
// reject dependencyUpdates candidates with alpha or beta in their names:
246+
dependencyUpdates.resolutionStrategy = {
247+
componentSelection { rules ->
248+
rules.all { ComponentSelection selection ->
249+
boolean rejected = ['alpha', 'beta', 'rc'].any { qualifier ->
250+
selection.candidate.version ==~ /(?i).*[.-]${qualifier}[.\d-]*/
251+
}
252+
if (rejected) {
253+
selection.reject('Release candidate')
254+
}
255+
}
256+
}
257+
}
258+
241259
/* BEGIN PRIVATE REPO ONLY */
242260

243261
apply from: 'stone.gradle'

proguard/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ repositories {
2929
dependencies {
3030
//compile group: 'com.dropbox.core', name: 'dropbox-core-sdk', version: '0-SNAPSHOT', changing: true
3131
compile rootProject
32-
compile 'org.testng:testng:6.9.10'
32+
compile 'org.testng:testng:6.9.11'
3333
}
3434

3535
compileJava {

release.gradle

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,10 @@ apply plugin: 'java'
22
apply plugin: 'java-library-distribution'
33
apply plugin: 'signing'
44
apply plugin: 'maven'
5-
apply plugin: 'com.github.ben-manes.versions' // dependencyUpdates task
6-
7-
task releaseTest() {
8-
dependsOn ':proguard:testProguard'
9-
dependsOn test
10-
dependsOn integrationTest
11-
}
12-
13-
signing {
14-
required {
15-
// don't sign for installing in local maven
16-
gradle.taskGraph.hasTask("uploadArchives") && !project.version.contains("SNAPSHOT")
17-
}
18-
sign configurations.archives
19-
}
205

216
def getPassword(prop, description) {
227
if (project.hasProperty(prop)) {
23-
return prop
8+
return project.getProperty(prop)
249
}
2510

2611
def console = System.console()
@@ -37,10 +22,23 @@ def getPassword(prop, description) {
3722
)
3823
}
3924

40-
gradle.taskGraph.whenReady { graph ->
41-
if (graph.hasTask(signArchives) && signArchives.required) {
42-
['signing.keyId', 'signing.secretKeyRingFile'].each { prop ->
43-
def dropboxProp = "com.dropbox.api.${prop}"
25+
task releaseTest() {
26+
dependsOn ':proguard:proguardTest'
27+
dependsOn test
28+
dependsOn integrationTest
29+
}
30+
31+
task signingCredentials() {
32+
ext {
33+
dbxPropPrefix = 'com.dropbox.api'
34+
keyIdProp = 'signing.keyId'
35+
keyRingProp = 'signing.secretKeyRingFile'
36+
passwordProp = 'signing.password'
37+
}
38+
39+
doLast {
40+
[keyIdProp, keyRingProp].each { prop ->
41+
def dropboxProp = "${dbxPropPrefix}.${prop}"
4442
if (!project.hasProperty(dropboxProp)) {
4543
throw new GradleException(
4644
"Missing required property for signing: ${dropboxProp}. " +
@@ -50,13 +48,23 @@ gradle.taskGraph.whenReady { graph ->
5048
project.ext.set(prop, project.getProperty(dropboxProp))
5149
}
5250

53-
project.ext."signing.password" = getPassword(
54-
'com.dropbox.api.signing.password',
51+
project.ext."${passwordProp}" = getPassword(
52+
"${dbxPropPrefix}.${passwordProp}",
5553
'PGP Private Key Password'
5654
)
5755
}
5856
}
5957

58+
signing {
59+
required {
60+
// don't sign for installing in local maven
61+
gradle.taskGraph.hasTask("uploadArchives") && !project.version.contains("SNAPSHOT")
62+
}
63+
sign configurations.archives
64+
}
65+
66+
tasks.signArchives.dependsOn signingCredentials
67+
6068
// Remember to upload binary with releases on GitHub. Some 3rd party developers still rely on
6169
// manually downloading and managing their dependencies.
6270
distributions {
@@ -108,17 +116,3 @@ uploadArchives {
108116
}
109117
}
110118

111-
// reject dependencyUpdates candidates with alpha or beta in their names:
112-
dependencyUpdates.resolutionStrategy = {
113-
componentSelection { rules ->
114-
rules.all { ComponentSelection selection ->
115-
boolean rejected = ['alpha', 'beta', 'rc'].any { qualifier ->
116-
selection.candidate.version ==~ /(?i).*[.-]${qualifier}[.\d-]*/
117-
}
118-
if (rejected) {
119-
selection.reject('Release candidate')
120-
}
121-
}
122-
}
123-
}
124-

0 commit comments

Comments
 (0)