-
Notifications
You must be signed in to change notification settings - Fork 61
/
build.gradle.kts
74 lines (60 loc) · 2.02 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import java.nio.file.Paths
import kotlin.io.path.moveTo
import kotlin.io.path.ExperimentalPathApi
plugins {
java
kotlin("jvm") version "1.7.20"
}
repositories {
mavenCentral()
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
}
subprojects {
apply(plugin = "java")
}
var modVersion: String = project.property("global_version").toString()
//var modVersion: String = providers.gradleProperty("global_version")
var mcCore = project(":mccore")
var mcInterfaceForge1122 = project(":mcinterfaceforge1122")
var mcInterfaceForge1165 = project(":mcinterfaceforge1165")
tasks.register("buildCore") {
dependsOn(mcCore.tasks.build)
doLast {
moveToOut(mcCore, "core")
}
}
tasks.register("buildForge1122") {
doFirst { preBuild() }
doLast {
moveToOut(mcInterfaceForge1122, "1.12.2")
}
dependsOn(mcInterfaceForge1122.tasks.build)
}
tasks.register("buildForge1165") {
doFirst { preBuild() }
doLast {
moveToOut(mcInterfaceForge1165, "1.16.5")
}
dependsOn(mcInterfaceForge1165.tasks.build)
}
tasks.register("buildForgeAll") {
dependsOn(tasks.getByName("buildForge1122"))
dependsOn(tasks.getByName("buildForge1165"))
}
@OptIn(ExperimentalPathApi::class)
fun moveToOut(subProject: Project, versionStr: String) {
val jarName = "Immersive Vehicles-${subProject.version}.jar"
Paths.get("${subProject.projectDir.canonicalPath}/build/libs/$jarName")
.moveTo(Paths.get("${project.projectDir.canonicalPath}/out/$jarName"), true)
}
fun preBuild() {
// Could probably be better somehow, but I'm not sure how
project.projectDir.canonicalFile.walk()
.filter { it.name == "gradle.properties" || it.name == "mcmod.info" || it.name == "InterfaceLoader.java" }
.forEach { it.writeText(it.readText()
.replace(Regex("mod_version=(.+)"), "mod_version=$modVersion")
.replace(Regex("\"version\": \"[^\"]*\""), "\"version\": \"$modVersion\"")
.replace(Regex("MODVER = \"[^\"]*\";"), "MODVER = \"$modVersion\";")) }
}