Skip to content

Commit

Permalink
Merge pull request hyperledger-web3j#726 from web3j/feature/720-impro…
Browse files Browse the repository at this point in the history
…ve-build-script

hyperledger-web3j#720: improve the build script to publish snapshots
  • Loading branch information
snazha-blkio authored Oct 3, 2018
2 parents fe8c359 + 1616748 commit 9721cb8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ hs_err_pid*
*/build/
*/out/

gradle.properties

# Ignore Gradle GUI config
gradle-app.setting

Expand Down
30 changes: 18 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

buildscript {
ext.bouncycastleVersion = '1.54'
ext.jacksonVersion = '2.8.5'
Expand Down Expand Up @@ -44,9 +43,6 @@ allprojects {
sourceCompatibility = 1.8
targetCompatibility = 1.8

group 'org.web3j'
version '3.6.0'

apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'checkstyle'
Expand Down Expand Up @@ -92,11 +88,11 @@ subprojects {

dependencies {
testCompile "junit:junit:$junitVersion",
"org.mockito:mockito-core:$mockitoVersion"
"org.mockito:mockito-core:$mockitoVersion"
}
}

configure(subprojects.findAll {it.name != 'integration-tests'}) {
configure(subprojects.findAll { it.name != 'integration-tests' }) {
// Required for Maven Nexus repository
apply plugin: 'maven'
apply plugin: 'signing'
Expand Down Expand Up @@ -127,6 +123,9 @@ configure(subprojects.findAll {it.name != 'integration-tests'}) {
ext {
ossrhUsername = project.hasProperty('ossrhUsername') ? project.property('ossrhUsername') : ''
ossrhPassword = project.hasProperty('ossrhPassword') ? project.property('ossrhPassword') : ''
bintrayUser = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
bintrayKey = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
isSnapshotVersion = project.version.endsWith("-SNAPSHOT")
}

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

repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') {
onlyIf {
ossrhUsername != '' && ossrhPassword != ''
}

String repoUrl = isSnapshotVersion ? "http://oss.sonatype.org/content/repositories/snapshots/" : "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
repository(url: repoUrl) {
authentication(
userName: ossrhUsername,
password: ossrhPassword
Expand Down Expand Up @@ -193,8 +197,8 @@ configure(subprojects.findAll {it.name != 'integration-tests'}) {
}

bintray {
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
user = bintrayUser
key = bintrayKey
publications = ['mavenJava']
publish = true
pkg {
Expand All @@ -214,10 +218,12 @@ configure(subprojects.findAll {it.name != 'integration-tests'}) {
//TODO run clean & closeAndPromoteRepository once
dependsOn 'build'
dependsOn 'uploadArchives'
dependsOn 'bintrayUpload'

if (!isSnapshotVersion && bintrayUser != '' && bintrayKey != '') {
dependsOn 'bintrayUpload'
tasks.findByName('bintrayUpload').mustRunAfter 'build'
}
tasks.findByName('uploadArchives').mustRunAfter 'build'
tasks.findByName('bintrayUpload').mustRunAfter 'build'
}
}

Expand All @@ -226,7 +232,7 @@ task jacocoRootTestReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
dependsOn = subprojects.test
additionalSourceDirs = files(subprojects.sourceSets.main.allSource.srcDirs)
sourceDirectories = files(subprojects.sourceSets.main.allSource.srcDirs)
classDirectories = files(subprojects.sourceSets.main.output)
classDirectories = files(subprojects.sourceSets.main.output)
executionData = files(subprojects.jacocoTestReport.executionData)
reports {
xml.enabled = true
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
group=org.web3j
version=3.6.0-SNAPSHOT

0 comments on commit 9721cb8

Please sign in to comment.