-
Notifications
You must be signed in to change notification settings - Fork 7
/
deploy.kts
61 lines (55 loc) · 1.85 KB
/
deploy.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
import java.io.FileWriter
import java.io.IOException
import java.util.*
import java.util.jar.JarEntry
import java.util.jar.JarFile
import java.util.jar.JarOutputStream
val version = "2.4.0-RELEASE"
val build = System.getenv("build_number") ?: "local"
val git = System.getenv("build_vcs_number") ?: "unknown"
val branch = System.getenv("branch")?.replace("refs/heads/", "") ?: "local"
File("start-scripts").listFiles()?.filter { it.extension == "sh" || it.extension == "bat" }?.forEach {
val lines = it.readLines()
.map { line ->
line.replace("%version%", version)
.replace("%branch%", branch.replace("/", "+"))
.replace("%build%", build)
}
it.writeText(lines.joinToString("\n"))
}
val outPutDirs = mutableListOf(
File("services/node-service/src/main/resources"),
)
File("connectors").listFiles()?.forEach {
if (it.isFile) return@forEach
if (it.name == "build" || it.name == "src") return@forEach
outPutDirs.add(File("connectors/${it.name}/src/main/resources"))
}
outPutDirs.forEach {
if (!it.exists()) it.mkdirs()
}
val props = createVersionProps()
outPutDirs.forEach {
val targetFile = File(it, "redicloud-version.properties")
if (targetFile.exists()) targetFile.delete()
targetFile.createNewFile()
targetFile.writeBytes(props.readBytes())
}
fun createVersionProps(): File {
val props = File("src/main/resources/redicloud-version.properties")
if (!props.parentFile.exists()) props.parentFile.mkdirs()
if (props.exists()) props.delete()
props.createNewFile()
val writer = FileWriter(props)
writer.write(
"version=$version\n"
+ "build=$build\n"
+ "git=$git\n"
+ "branch=$branch"
)
writer.close()
return props
}