Skip to content

Commit 9721cb8

Browse files
authored
Merge pull request #726 from web3j/feature/720-improve-build-script
#720: improve the build script to publish snapshots
2 parents fe8c359 + 1616748 commit 9721cb8

3 files changed

Lines changed: 20 additions & 14 deletions

File tree

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ hs_err_pid*
1919
*/build/
2020
*/out/
2121

22-
gradle.properties
23-
2422
# Ignore Gradle GUI config
2523
gradle-app.setting
2624

build.gradle

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
buildscript {
32
ext.bouncycastleVersion = '1.54'
43
ext.jacksonVersion = '2.8.5'
@@ -44,9 +43,6 @@ allprojects {
4443
sourceCompatibility = 1.8
4544
targetCompatibility = 1.8
4645

47-
group 'org.web3j'
48-
version '3.6.0'
49-
5046
apply plugin: 'java'
5147
apply plugin: 'jacoco'
5248
apply plugin: 'checkstyle'
@@ -92,11 +88,11 @@ subprojects {
9288

9389
dependencies {
9490
testCompile "junit:junit:$junitVersion",
95-
"org.mockito:mockito-core:$mockitoVersion"
91+
"org.mockito:mockito-core:$mockitoVersion"
9692
}
9793
}
9894

99-
configure(subprojects.findAll {it.name != 'integration-tests'}) {
95+
configure(subprojects.findAll { it.name != 'integration-tests' }) {
10096
// Required for Maven Nexus repository
10197
apply plugin: 'maven'
10298
apply plugin: 'signing'
@@ -127,6 +123,9 @@ configure(subprojects.findAll {it.name != 'integration-tests'}) {
127123
ext {
128124
ossrhUsername = project.hasProperty('ossrhUsername') ? project.property('ossrhUsername') : ''
129125
ossrhPassword = project.hasProperty('ossrhPassword') ? project.property('ossrhPassword') : ''
126+
bintrayUser = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
127+
bintrayKey = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
128+
isSnapshotVersion = project.version.endsWith("-SNAPSHOT")
130129
}
131130

132131
publishing {
@@ -150,7 +149,12 @@ configure(subprojects.findAll {it.name != 'integration-tests'}) {
150149
mavenDeployer {
151150
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
152151

153-
repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') {
152+
onlyIf {
153+
ossrhUsername != '' && ossrhPassword != ''
154+
}
155+
156+
String repoUrl = isSnapshotVersion ? "http://oss.sonatype.org/content/repositories/snapshots/" : "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
157+
repository(url: repoUrl) {
154158
authentication(
155159
userName: ossrhUsername,
156160
password: ossrhPassword
@@ -193,8 +197,8 @@ configure(subprojects.findAll {it.name != 'integration-tests'}) {
193197
}
194198

195199
bintray {
196-
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
197-
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
200+
user = bintrayUser
201+
key = bintrayKey
198202
publications = ['mavenJava']
199203
publish = true
200204
pkg {
@@ -214,10 +218,12 @@ configure(subprojects.findAll {it.name != 'integration-tests'}) {
214218
//TODO run clean & closeAndPromoteRepository once
215219
dependsOn 'build'
216220
dependsOn 'uploadArchives'
217-
dependsOn 'bintrayUpload'
218221

222+
if (!isSnapshotVersion && bintrayUser != '' && bintrayKey != '') {
223+
dependsOn 'bintrayUpload'
224+
tasks.findByName('bintrayUpload').mustRunAfter 'build'
225+
}
219226
tasks.findByName('uploadArchives').mustRunAfter 'build'
220-
tasks.findByName('bintrayUpload').mustRunAfter 'build'
221227
}
222228
}
223229

@@ -226,7 +232,7 @@ task jacocoRootTestReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
226232
dependsOn = subprojects.test
227233
additionalSourceDirs = files(subprojects.sourceSets.main.allSource.srcDirs)
228234
sourceDirectories = files(subprojects.sourceSets.main.allSource.srcDirs)
229-
classDirectories = files(subprojects.sourceSets.main.output)
235+
classDirectories = files(subprojects.sourceSets.main.output)
230236
executionData = files(subprojects.jacocoTestReport.executionData)
231237
reports {
232238
xml.enabled = true

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
group=org.web3j
2+
version=3.6.0-SNAPSHOT

0 commit comments

Comments
 (0)