@@ -10,6 +10,7 @@ plugins {
1010 id ' java-library'
1111 id ' net.ltgt.errorprone' version ' 1.1.1'
1212 id ' net.minecrell.licenser' version ' 0.4.1'
13+ id ' com.palantir.git-version' version ' 0.12.3'
1314}
1415
1516repositories {
@@ -39,8 +40,38 @@ googleJavaFormat {
3940 exclude ' **/.idea/**'
4041}
4142
42- group = ' io.temporal'
43- version = ' 0.10.0-SNAPSHOT'
43+ // v0.20.0-2-g000a42a -> 0.20.0-2-g000a42a
44+ ext. getTag = { ->
45+ def stdout = new ByteArrayOutputStream ()
46+ exec {
47+ commandLine ' git' , ' describe' , ' --tags'
48+ standardOutput = stdout
49+ }
50+ return stdout. toString(). trim(). substring(1 )
51+ }
52+
53+ // 0.20.0-2-g000a42a -> 0.20.0-SNAPSHOT
54+ // 0.20.0 -> 0.20.0
55+ // Used to name jar files
56+ ext. getVersionName = { ->
57+ def split = getTag(). split(' -' )
58+ if (split. size() > 1 ) {
59+ return split[0 ] + ' -SNAPSHOT'
60+ }
61+ return split[0 ]
62+ }
63+
64+ // 0.20.0-SNAPSHOT -> 0.20.0
65+ // 0.20.0 -> 0.20.0
66+ // Stored int version.properties which is loaded
67+ // and used as a value of temporal-client-version gRPC header.
68+ ext. getClientVersionName = { ->
69+ def split = getVersionName(). split(' -' )
70+ return split[0 ]
71+ }
72+
73+ group= ' io.temporal'
74+ version = getVersionName()
4475archivesBaseName= " temporal-sdk"
4576
4677description = ''' Temporal Workflow Java SDK'''
@@ -138,13 +169,13 @@ compileTestJava {
138169// Generation version.properties for value to be included into the request header
139170task createProperties (dependsOn : processResources) {
140171 doLast {
141- def subdir = new File (' $buildDir/resources/main/io/temporal/' )
172+ def subdir = new File (" $buildDir /resources/main/io/temporal/" )
142173 if (! subdir. exists()) {
143174 subdir. mkdirs()
144175 }
145- new File (' $buildDir/resources/main/io/temporal/version.properties' ). withWriter { w ->
176+ new File (" $buildDir /resources/main/io/temporal/version.properties" ). withWriter { w ->
146177 Properties p = new Properties ()
147- p[' temporal-client-version' ] = project . version . toString ()
178+ p[' temporal-client-version' ] = getClientVersionName ()
148179 p. store w, null
149180 }
150181 }
0 commit comments