forked from Nyan-Work/oh-my-minecraft-client
-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.gradle
171 lines (142 loc) · 5.97 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import com.replaymod.gradle.preprocess.Node
plugins {
id("dev.architectury.loom").version("${architectury_loom_version}").apply(false)
id("org.ajoberstar.grgit").version("${grgit_version}")
id("com.replaymod.preprocess").version("${preprocessor_version}")
id("me.fallenbreath.yamlang").version("${yamlang_version}").apply(false)
}
preprocess {
// Fabric
Node mc11404_fabric = createNode("1.14.4-fabric", 1_14_04, "mojang")
Node mc11502_fabric = createNode("1.15.2-fabric", 1_15_02, "mojang")
Node mc11605_fabric = createNode("1.16.5-fabric", 1_16_05, "mojang")
Node mc11701_fabric = createNode("1.17.1-fabric", 1_17_01, "mojang")
Node mc11802_fabric = createNode("1.18.2-fabric", 1_18_02, "mojang")
Node mc11902_fabric = createNode("1.19.2-fabric", 1_19_02, "mojang")
Node mc11903_fabric = createNode("1.19.3-fabric", 1_19_03, "mojang")
Node mc11904_fabric = createNode("1.19.4-fabric", 1_19_04, "mojang")
Node mc12001_fabric = createNode("1.20.1-fabric", 1_20_01, "mojang")
Node mc12002_fabric = createNode("1.20.2-fabric", 1_20_02, "mojang")
Node mc12004_fabric = createNode("1.20.4-fabric", 1_20_04, "mojang")
Node mc12006_fabric = createNode("1.20.6-fabric", 1_20_06, "mojang")
Node mc12101_fabric = createNode("1.21.1-fabric", 1_21_01, "mojang")
mc11404_fabric.link(mc11502_fabric, null)
mc11502_fabric.link(mc11605_fabric, file("versions/mapping-1.15.2-1.16.5.txt"))
mc11605_fabric.link(mc11701_fabric, null)
mc11701_fabric.link(mc11802_fabric, null)
mc11802_fabric.link(mc11902_fabric, file("versions/mapping-1.18.2-1.19.2.txt"))
mc11902_fabric.link(mc11903_fabric, file("versions/mapping-1.19.2-1.19.3.txt"))
mc11903_fabric.link(mc11904_fabric, null)
mc11904_fabric.link(mc12001_fabric, null)
mc12001_fabric.link(mc12002_fabric, null)
mc12002_fabric.link(mc12004_fabric, null)
mc12004_fabric.link(mc12006_fabric, null)
mc12006_fabric.link(mc12101_fabric, null)
}
ext {
Map env = System.getenv()
File localPropsFile = file("${rootDir}/local.properties")
if (localPropsFile.exists()) {
Properties p = new Properties()
p.load(new FileInputStream(localPropsFile))
p.each { key, value ->
ext[key as String] = value
}
}
getEnv = {
return env
}
getOrDefault = { String key, String defaultValue ->
String value
(value = project.findProperty(key)) && !value.isEmpty() ? value : defaultValue
}
isGithubCI = {
return env.get("GITHUB_ACTION") != null
}
isJitpack = {
return env.get("JITPACK") != null
}
getBuildNumber = {
return env.GITHUB_RUN_NUMBER ? env.GITHUB_RUN_NUMBER : 0
}
getVersionGit = { List paths ->
if (grgit == null || grgit.head() == 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)}"
}
getVersionType = {
String type = getOrDefault("ow.build.environment.buildType", null)
if (type != null) {
return type
}
if (isJitpack()) {
return "jitpack"
}
type = env.BUILD_TYPE
switch (type) {
case "RELEASE":
return "stable"
case "BETA":
return "beta"
case "PULL_REQUEST":
return "pull_request"
default:
return "dev"
}
}
getVersionPatch = { List paths ->
if (grgit == null || grgit.head() == null) {
return 0
}
List latestCommits = paths.isEmpty() ? grgit.log() : grgit.log(paths: paths)
return latestCommits.size()
}
getVersion = { Project proj ->
return "${proj.property("mod.version")}.${getVersionPatch(proj == rootProject ? [] : [proj.projectDir.name])}"
}
getVersionWithCommitHash = { Project proj ->
return "${getVersion(proj)}+${getVersionGit(proj == rootProject ? [] : [proj.projectDir.name])}-${getVersionType()}"
}
getModVersion = { Project proj ->
return "${getVersion(proj)}-${getVersionType()}"
}
getMavenArtifactVersion = { Project proj ->
return project.getVersionType() == "stable" ? "${getVersion(proj)}" : "${getModVersion(proj)}"
}
}
tasks.register("genLocalProperties") {
it.group("${project.property("mod.id")}")
doFirst {
File localPropsFile = file("${rootDir}/local.properties")
if (localPropsFile.exists()) {
throw new IllegalStateException("local.properties file already generated. If you want to regenerate it, please delete it manually first")
} else {
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(localPropsFile))
bufferedWriter.writeLine("# Secrets")
bufferedWriter.writeLine("secrets.gpg.signingKey=")
bufferedWriter.writeLine("secrets.gpg.signingPassword=")
bufferedWriter.writeLine("secrets.mavenCentral.username=")
bufferedWriter.writeLine("secrets.mavenCentral.password=")
bufferedWriter.writeLine("")
bufferedWriter.writeLine("# Overwritten configurations")
bufferedWriter.writeLine("ow.build.environment.local=")
bufferedWriter.writeLine("ow.build.environment.buildType=")
bufferedWriter.writeLine("ow.game.window.width=")
bufferedWriter.writeLine("ow.game.window.height=")
bufferedWriter.writeLine("ow.game.window.username=")
bufferedWriter.close()
project.getLogger().info("local.properties generated successfully!")
}
}
}
tasks.register("cleanPreprocessSources") {
it.group("${project.mod_id}")
doFirst {
subprojects {
def path = project.projectDir.toPath().resolve("build/preprocessed")
path.toFile().deleteDir()
}
}
}