-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild.gradle.kts
55 lines (46 loc) · 1.5 KB
/
build.gradle.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
allprojects {
group = "net.axay"
version = "0.5.2"
description = "An easy-to-use Minecraft package manager and launcher"
}
extra["kotlin.code.style"] = "official"
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("commons-codec:commons-codec:1.15")
}
}
val githubUrl = "https://github.com/jakobkmar/pacmc"
fun requestHash(extension: String): String {
val url = "${githubUrl}/releases/download/${version}/pacmc-${version}.${extension}"
println("Requesting $extension sha256 hash of $url")
return org.apache.commons.codec.digest.DigestUtils.sha256Hex(java.net.URL(url).openStream())
.also { println("The hash is $it") }
}
val expandProps by lazy {
mapOf(
"tarHashSha256" to requestHash("tar"),
"zipHashSha256" to requestHash("zip"),
"javaVersion" to "11",
"version" to version,
"description" to description,
"githubUrl" to githubUrl,
"license" to "AGPL-3.0-or-later",
"licenseArchFormat" to "AGPL3 or any later version",
)
}
tasks {
register<Copy>("copyPackages") {
group = "packaging"
from(layout.projectDirectory.dir("packages"))
into(layout.buildDirectory.dir("packages"))
filesMatching("**") {
expandProps.forEach { (propertyName, propertyValue) ->
val regex = Regex("""\$\{${propertyName}\}""")
filter { regex.replace(it, propertyValue.toString()) }
}
}
}
}