@@ -11,7 +11,11 @@ apply plugin: 'maven'
1111group = ' com.datamaio'
1212sourceCompatibility = 1.8
1313targetCompatibility = 1.8
14- version = buildVersion()
14+ version = buildVersionName()
15+
16+ println " ***********************************"
17+ println " **** Building version '$version ' ****"
18+ println " ***********************************\n "
1519
1620jar {
1721 manifest {
@@ -81,21 +85,13 @@ compileGroovy.doLast {
8185
8286// --------- publish to bintray config -----------
8387
84- gradle. taskGraph. whenReady { graph ->
85- if (graph. hasTask(' :bintrayUpload' )) {
86- version = buildVersion(1 )
87- println " ************************************************"
88- println " **** Publishing version '$version ' to Bintray ****"
89- println " ************************************************"
90- }
91- }
92-
9388bintray {
9489 user = project. hasProperty(' bintray_user' ) ? bintray_user : ' '
9590 key = project. hasProperty(' bintray_api_key' ) ? bintray_api_key : ' '
9691 configurations = [' archives' ]
9792 publish = true
9893 pkg {
94+ name = version
9995 repo = ' maven'
10096 name = ' SCD4J'
10197 desc = ' Simple Continuous Delivery for Java and Groovy Developers'
@@ -108,33 +104,46 @@ bintray {
108104 attributes= [' gradle-plugin' : ' com.datamaio.scd4j:com.datamaio:scd4j' ]
109105
110106 version {
111- desc = " Simple Continuous Delivery for Java and Groovy Developers - version $p roject . version "
107+ desc = " Simple Continuous Delivery for Java and Groovy Developers"
112108 released = new java.util.Date ()
113109 attributes = [' gradle-plugin' : ' com.datamaio.scd4j:com.datamaio:scd4j' ]
114110 }
115111 }
116112}
117113
114+ bintrayUpload. doLast {
115+ println " \n ************************************************"
116+ println " **** Published version '$version ' to Bintray ****"
117+ println " ************************************************"
118+
119+ incrementDeployNumber()
120+ }
121+
118122// --------- Utility --------
119123
120- def buildVersion ( increment ) {
124+ def buildVersionName ( ) {
121125 def f = file(' version.properties' )
122126 if (f. canRead()) {
123- def Properties props = new Properties ()
124- props. load(new FileInputStream (f))
125- def deployNumber = props[' DEPLOY_NUMBER' ]. toInteger()
126- if (increment) {
127- deployNumber++ ;
128- props[' DEPLOY_NUMBER' ] = deployNumber. toString()
129- props. store(f. newWriter(), null )
130- }
131-
132- return " ${ props['VERSION_NAME']} .${ deployNumber} "
127+ def props = new Properties ()
128+ props. load(new FileInputStream (f))
129+ return " ${ props['VERSION_NAME']} .${ props['BINTRAY_DEPLOY_NUMBER']} "
133130 } else {
134131 throw new GradleException (" Could not read version.properties!" )
135132 }
136133}
137134
135+ def incrementDeployNumber () {
136+ def f = file(' version.properties' )
137+ if (f. canWrite()) {
138+ def props = new Properties ()
139+ props. load(new FileInputStream (f))
140+ props[' BINTRAY_DEPLOY_NUMBER' ] = " " + (props[' BINTRAY_DEPLOY_NUMBER' ]. toInteger() + 1 )
141+ props. store(f. newWriter(), null )
142+ } else {
143+ throw new GradleException (" Could not write version.properties!" )
144+ }
145+ }
146+
138147
139148// --------- Create DEB and RPM packages --------
140149
0 commit comments