-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
66 lines (54 loc) · 1.89 KB
/
build.gradle
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
plugins {
id("fabric-loom").version("1.3-SNAPSHOT").apply(false)
id("io.github.juuxel.loom-vineflower").version("1.11.0").apply(false)
id("net.kyori.blossom").version("1.3.1").apply(false)
id("org.ajoberstar.grgit").version("5.2.0")
id("maven-publish")
id("com.replaymod.preprocess").version("SNAPSHOT")
}
preprocess {
def mc1204 = createNode("1.20.4", 1_20_04, "mojang") // root
}
ext {
def environmentMap = System.getenv()
getVersionGit = { List paths ->
if (grgit == null) {
return "nogit"
}
List latestCommits = paths.isEmpty() ? grgit.log(maxCommits: 1) : grgit.log(paths: paths, maxCommits: 1)
return latestCommits.isEmpty() ? "uncommited" : "${latestCommits.get(0).id.substring(0, 7)}"
}
getBuildNumber = {
return environmentMap.GITHUB_RUN_NUMBER ? environmentMap.GITHUB_RUN_NUMBER : Integer.MAX_VALUE
}
getVersionType = {
switch (environmentMap.BUILD_TYPE) {
case "RELEASE":
return "stable"
case "BETA":
return "beta"
default:
return "dev"
}
}
getVersionPatch = { List paths ->
if (grgit == null) {
return 0
}
List latestCommits = paths.isEmpty() ? grgit.log() : grgit.log(paths: paths)
return latestCommits.size()
}
getMavenArtifactVersion = {
return ext.getVersionType() == "stable" ? "${project.mod_version}.${ext.getVersionPatch([])}" : project.version
}
}
setVersion("${project.mod_version}.${project.getVersionPatch([])}+${project.getVersionGit([])}-${project.getVersionType()}")
tasks.register("cleanPreprocessSources") {
it.group("${project.mod_id}")
doFirst {
subprojects {
def path = project.projectDir.toPath().resolve("build/preprocessed")
path.toFile().deleteDir()
}
}
}