forked from SilentChaos512/ScalingHealth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
314 lines (262 loc) · 9.02 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net/' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
}
}
plugins {
id 'eclipse'
id 'maven-publish'
id 'com.matthewprenger.cursegradle' version '1.4.0'
}
apply plugin: 'net.minecraftforge.gradle'
repositories {
maven { url = 'https://maven.minecraftforge.net/' }
mavenLocal()
}
archivesBaseName = project.archivesBaseName
ext {
VERSION_INFO = getModVersion()
VERSION_SHORT = "${VERSION_INFO['version_short']}"
}
System.out.println(VERSION_INFO)
version = "${VERSION_INFO['version']}"
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
minecraft {
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
mappings channel: 'official', version: '1.19.2'
runs {
client {
workingDirectory project.file('run')
//properties 'forge.logging.markers': 'SCAN,REGISTRIES,REGISTRYDUMP'
properties 'forge.logging.console.level': 'debug'
jvmArg("-Xmx6G")
mods { scalinghealth { source sourceSets.main} }
}
server {
workingDirectory project.file('run')
//properties 'forge.logging.markers': 'SCAN,REGISTRIES,REGISTRYDUMP'
properties 'forge.logging.console.level': 'debug'
mods { scalinghealth { source sourceSets.main} }
}
data {
workingDirectory project.file('run')
properties 'forge.logging.console.level': 'debug'
args '--mod', 'scalinghealth', '--all', '--output', file('src/generated/resources/'), '--existing', sourceSets.main.resources.srcDirs[0]
mods { scalinghealth { source sourceSets.main} }
}
}
}
sourceSets.main.resources { srcDir 'src/generated/resources' }
repositories {
mavenLocal()
mavenCentral() //Eval Ex
maven {
// location of the maven that hosts JEI files
name = "Progwml6 maven"
url = "https://dvs1.progwml6.com/files/maven/"
}
maven {
// location of a maven mirror for JEI files, as a fallback
name = "ModMaven"
url = "https://modmaven.k-4u.nl"
}
maven {
url "https://www.cursemaven.com"
content {
includeGroup "curse.maven"
}
}
}
configurations {
// Dependencies to pack into the jar
extraLibs
implementation.extendsFrom extraLibs
}
//add it to the classpath manually. forgegradle + modules shenanigans
minecraft.runs.all {
lazyToken('minecraft_classpath') {
configurations.extraLibs.copyRecursive().resolve().collect {it.absolutePath }.join(File.pathSeparator)
}
}
dependencies {
minecraft "net.minecraftforge:forge:${project.forge_version}"
extraLibs "com.udojava:EvalEx:2.1"
// compileOnly fg.deobf("mezz.jei:jei-${project.jei_version}:api")
// runtimeOnly fg.deobf("mezz.jei:jei-${project.jei_version}")
implementation fg.deobf("curse.maven:silentlib-242998:${project.sl_file}")
// implementation fg.deobf("curse.maven:configured-457570:3291560")
configurations.implementation.extendsFrom(configurations.extraLibs)
}
jar {
archiveAppendix = "${project.mc_version}"
manifest {
attributes(["Specification-Title": project.mod_id,
"Specification-Vendor": "SilentChaos512",
"Specification-Version": "${VERSION_INFO['version_simple']}",
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor" :"SilentChaos512",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")],)
}
from {
configurations.extraLibs.collect { it.isDirectory() ? it : zipTree(it) }
}
}
task deobfJar(type: Jar) {
archiveAppendix = "${project.mc_version}"
archiveClassifier = 'deobf'
from sourceSets.main.output
}
task sourcesJar(type: Jar) {
archiveAppendix = "${project.mc_version}"
archiveClassifier = 'sources'
from sourceSets.main.allJava
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveAppendix = "${project.mc_version}"
archiveClassifier = 'javadoc'
from javadoc.getDestinationDir()
}
artifacts {
if (project.hasProperty('doDeobfJar')) {
archives deobfJar
}
if (project.hasProperty('doSourceJar')) {
archives sourcesJar
}
if (project.hasProperty('doJavadocJar')) {
archives javadocJar
}
}
task zipUserStartPack(type: Zip) {
archiveBaseName = 'user_start_pack'
archiveVersion = '2'
destinationDirectory = file('build/zips')
from ('user_starter_pack')
}
class Secrets {
def data = null
def getProperty(String key) {
return data ? data[key] : ''
}
}
import com.matthewprenger.cursegradle.CurseExtension
import groovy.json.JsonSlurper
def secretFile = file 'secret.json'
project.ext.secret = new Secrets()
if (secretFile.exists()) {
secretFile.withReader {
project.ext.secret.data = new JsonSlurper().parse it
}
}
curseforge {
if (project.hasProperty('cf_project_id') && project.hasProperty('cf_release_type') && project.hasProperty('cf_changelog_filename') &&
((project.cf_release_type == 'alpha') || (project.cf_release_type == 'beta') || (project.cf_release_type == 'release'))) {
apiKey = secret.curseforgeAPIKey
project {
id = project.cf_project_id
addGameVersion(project.mc_version)
mainArtifact(jar) {
changelog = file(project.cf_changelog_filename)
changelogType = 'markdown'
releaseType = project.cf_release_type
relations {
requiredDependency 'silent-lib'
optionalDependency 'configured'
}
}
// addArtifact(zipUserStartPack) {
// releaseType = 'release'
// }
}
options {
debug = true
}
}
}
// Version stuff
def getModVersion() {
return getGitVersion()
}
def getGitVersion() {
// Call git command
def proc = "git describe --long".execute();
proc.waitFor();
def fullVersion = proc.text.trim();
def matcher = fullVersion =~ /(\d+).(\d+).(\d+)-(.*)/
def maj = matcher[0][1]
def min = matcher[0][2]
def rev = matcher[0][3]
def bn = getBuildNumber()
return makeVersionMap(maj, min, rev, bn, matcher[0][4])
}
static def makeVersionMap(maj, min, rev, bn, githash) {
def out = [:]
out['build.major.number'] = maj.toString()
out['build.minor.number'] = min.toString()
out['build.revision.number'] = rev.toString()
out['build.githash'] = githash
out['build.number'] = bn.toString()
out['version_simple'] = "${maj}.${min}".toString()
out['version_short'] = "${maj}.${min}.${rev}".toString()
out['version'] = "${maj}.${min}.${rev}+${bn}".toString()
return out
}
String getBuildNumber() {
def versionFile = file('version.properties')
if (versionFile.canRead()) {
Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionFile))
return versionProps['build_number'].toString()
}
return "1"
}
task incrementBuild {
doLast {
def versionFile = file('version.properties')
if (versionFile.canRead()) {
Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionFile))
def num = versionProps['build_number'].toInteger() + 1
println("Incrementing BuildNumber to: " + num)
versionProps['build_number'] = num.toString()
versionProps.store(versionFile.newWriter(), null)
} else {
println("version.properties file not found! Ignoring.")
}
}
}
import groovy.json.JsonOutput
def writeUpdateJson() {
def slurper = new JsonSlurper()
def file = new File('update.json')
def json = slurper.parse(file)
if (!json[project.mc_version].containsKey(VERSION_SHORT))
json[project.mc_version][VERSION_SHORT] = project.changelogUrl
json[project.mc_version] = json[project.mc_version].sort([compare: {a, b -> b.compareTo(a)}] as Comparator)
json['promos']["${project.mc_version}-latest"] = VERSION_SHORT
file.write(JsonOutput.prettyPrint(JsonOutput.toJson(json)))
}
task createUpdateJson {
doLast {
println('Updating update.json...')
writeUpdateJson()
}
}
tasks.configureEach { task ->
if (task.name == 'curseforge' + project.cf_project_id) {
if (!project.extensions.getByType(CurseExtension).curseGradleOptions.debug) {
task.finalizedBy {
incrementBuild
}
}
task.finalizedBy {
createUpdateJson
}
}
}