Skip to content

Commit 18cd77f

Browse files
committed
fix versioning
1 parent d2a1db8 commit 18cd77f

1 file changed

Lines changed: 28 additions & 34 deletions

File tree

versioningHelper.gradle

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,35 @@ import java.nio.file.Path
22
import java.time.LocalDateTime
33
import java.time.format.DateTimeFormatter
44

5-
gradle.allprojects {
6-
ext.getCurrentVersion = {
7-
->
8-
def stdout = new ByteArrayOutputStream()
9-
String tagIsh
10-
try {
11-
exec {
12-
commandLine 'git', 'describe', '--tags', "--match=v*"
13-
standardOutput = stdout
14-
}
15-
tagIsh = stdout.toString().trim().toLowerCase()
16-
} catch (Exception e) {
17-
tagIsh = "dev-Unknown"
18-
}
19-
20-
// Dev tags: v2021.1.6-3-gf922466d
21-
// We're specifically looking to capture the middle -3-
22-
boolean isDev = tagIsh.matches(".*-[0-9]*-g[0-9a-f]*")
23-
if (isDev && !tagIsh.startsWith("dev-")) tagIsh = "dev-" + tagIsh
24-
println("Picked up version: " + tagIsh)
25-
return tagIsh
5+
ext.getCurrentVersion = {
6+
String tagIsh = "dev-unknown"
7+
try {
8+
tagIsh = providers.exec {
9+
commandLine 'git', 'describe', '--tags', '--match=v*'
10+
}.standardOutput.asText.get().trim().toLowerCase()
11+
} catch (Exception ignored) {
12+
tagIsh = "dev-unknown"
2613
}
2714

28-
if (!ext.has("versionString")) {
29-
ext.versionString = getCurrentVersion()
30-
}
15+
// Dev tags: v2021.1.6-3-gf922466d
16+
// We're specifically looking to capture the middle -3-
17+
boolean isDev = tagIsh.matches(".*-[0-9]*-g[0-9a-f]*")
18+
if (isDev && !tagIsh.startsWith("dev-")) tagIsh = "dev-" + tagIsh
19+
println("Picked up version: " + tagIsh)
20+
return tagIsh
21+
}
3122

32-
ext.writePhotonVersionFile = {File versionFileIn, Path path, String version ->
33-
println("Writing " + version + " to " + path.toAbsolutePath().toString())
34-
String date = DateTimeFormatter.ofPattern("yyyy-M-d hh:mm:ss").format(LocalDateTime.now())
35-
File versionFileOut = new File(path.toAbsolutePath().toString())
36-
versionFileOut.delete()
37-
def read = versionFileIn.text.replace('${version}', version).replace('${date}', date)
38-
if (!versionFileOut.parentFile.exists()) versionFileOut.parentFile.mkdirs()
39-
if (!versionFileOut.exists()) versionFileOut.createNewFile()
40-
versionFileOut.write(read)
41-
}
23+
if (!ext.has("versionString")) {
24+
ext.versionString = getCurrentVersion()
25+
}
26+
27+
ext.writePhotonVersionFile = {File versionFileIn, Path path, String version ->
28+
println("Writing " + version + " to " + path.toAbsolutePath().toString())
29+
String date = DateTimeFormatter.ofPattern("yyyy-M-d hh:mm:ss").format(LocalDateTime.now())
30+
File versionFileOut = new File(path.toAbsolutePath().toString())
31+
versionFileOut.delete()
32+
def read = versionFileIn.text.replace('${version}', version).replace('${date}', date)
33+
if (!versionFileOut.parentFile.exists()) versionFileOut.parentFile.mkdirs()
34+
if (!versionFileOut.exists()) versionFileOut.createNewFile()
35+
versionFileOut.write(read)
4236
}

0 commit comments

Comments
 (0)