forked from MightyPirates/OpenComputers
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathbuild.gradle
More file actions
372 lines (324 loc) · 11 KB
/
build.gradle
File metadata and controls
372 lines (324 loc) · 11 KB
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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
plugins {
id 'scala'
id 'maven-publish'
id 'net.minecraftforge.gradle' version '5.1.64'
id 'wtf.gofancy.fancygradle' version '1.1.+'
id "com.matthewprenger.cursegradle" version "1.4.0"
id 'com.modrinth.minotaur' version '2.8.7'
}
fancyGradle {
patches {
resources
}
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
file "build.properties" withReader {
def prop = new Properties()
prop.load(it)
ext.config = new ConfigSlurper().parse prop
}
if (project.hasProperty("release_tag")) {
def rtag = project.getProperty("release_tag");
def verIdx = rtag.indexOf("/");
if (verIdx <= 0 || verIdx >= rtag.length() - 1) throw new Error("malformed release tag " + rtag);
def baseVer = rtag.substring(0, verIdx);
def ldrIdx = baseVer.indexOf("-");
if (ldrIdx <= 0 || ldrIdx >= baseVer.length() - 1) throw new Error("malformed base version " + baseVer);
if (baseVer.substring(0, ldrIdx) != config.minecraft.version)
{
throw new Error("incorrect minecraft version " + baseVer.substring(0, ldrIdx) + ", expected " + config.minecraft.version);
}
if (baseVer.substring(ldrIdx + 1) != "forge")
{
throw new Error("incorrect mod loader " + baseVer.substring(ldrIdx + 1) + ", expected forge");
}
ext.mod_version = rtag.substring(verIdx + 1);
}
else if (!project.hasProperty("mod_version")) {
ext.mod_version = config.mod.version
}
version = "${mod_version}"
if (version.endsWith("-snapshot")) {
version += "-" + (new Date().format('yyyyMMdd'))
}
group = config.mod.group
archivesBaseName = config.mod.name
def getGitRef() {
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim()
} catch (Throwable e) {
return "unknown"
}
}
version += "+" + getGitRef()
ext.simpleVersion = version
version = "MC${config.minecraft.version}-${project.version}"
minecraft {
mappings channel: "${config.minecraft.mappings_channel}", version: "${config.minecraft.mappings_version}"
runs {
client {
workingDirectory project.file("run")
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'forge.logging.console.level', 'info'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
mods {
opencomputers {
source sourceSets.main
}
}
}
server {
workingDirectory project.file("run")
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'forge.logging.console.level', 'info'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
mods {
opencomputers {
source sourceSets.main
}
}
}
}
accessTransformer = file("src/main/resources/META-INF/accesstransformer.cfg")
}
task replaceSourceTokensScala(type: Sync) {
from sourceSets.main.scala
filteringCharset = 'UTF-8'
filter { line -> line
.replaceAll('@VERSION@', "${mod_version}")
.replaceAll('@MCVERSION@', "${config.minecraft.version}") }
into "$buildDir/srcReplaced/scala"
}
/* Do not pull this in on IDEA, as it changes the compiler's source path, making navigating to errors harder */
if (!System.getProperty('idea.active')) {
compileScala {
source = replaceSourceTokensScala.outputs
}
}
compileScala {
configure(scalaCompileOptions.forkOptions) {
memoryMaximumSize = '1g'
}
}
repositories {
maven {
name "MightyPirates"
url "https://maven.cil.li/"
metadataSources {
mavenPom()
artifact()
}
}
maven {
name "SquidDev" /* CC: Tweaked */
url "https://squiddev.cc/maven/"
}
ivy {
name 'asie dependency mirror'
artifactPattern "https://asie.pl/javadeps/[module]-[revision](-[classifier]).[ext]"
content {
includeModule '', 'OC-LuaJ'
includeModule '', 'OC-JNLua'
includeModule '', 'OC-JNLua-Natives'
}
metadataSources {
artifact()
}
}
maven {
url "https://api.modrinth.com/maven"
content {
includeGroup "maven.modrinth"
}
}
maven {
url "https://cursemaven.com"
content {
includeGroup "curse.maven"
}
}
maven {
url "https://modmaven.dev"
content {
includeGroup "mezz.jei"
}
}
maven {
url "https://chickenbones.net/maven/"
content {
includeGroup "codechicken"
includeGroup "mrtjp"
}
}
maven {
url "https://modmaven.dev/"
content {
includeGroup "appeng"
includeGroup "mekanism"
}
}
maven {
url "https://proxy-maven.covers1624.net/"
content {
includeModule "net.minecraftforge", "Scorge"
}
}
mavenCentral()
}
configurations {
embedded
compileOnly.extendsFrom provided
implementation.extendsFrom embedded
}
dependencies {
def jeiSlug = "jei-${config.minecraft.version}"
minecraft "net.minecraftforge:forge:${config.minecraft.version}-${config.forge.version}"
// required for tests but cannot use implementation as that would clash with scorge at runtime
compileOnly "org.scala-lang:scala-library:2.13.4"
implementation "net.minecraftforge:Scorge:${config.scorge.version}"
embedded "com.typesafe:config:1.2.1"
compileOnly fg.deobf("li.cil.tis3d:tis3d-1.16.5-forge:${config.tis3d.version}")
compileOnly fg.deobf("curse.maven:hwyla-${config.hwyla.projectId}:${config.hwyla.fileId}")
compileOnly fg.deobf("org.squiddev:cc-tweaked-${config.minecraft.version}:${config.cct.version}")
compileOnly fg.deobf("curse.maven:cofh-core-69162:4022663") /* CoFHCore */
compileOnly fg.deobf("curse.maven:thermal-foundation-222880:4022666") /* Thermal Foundation */
runtimeOnly fg.deobf("maven.modrinth:modernfix:${config.modernfix.version}")
provided fg.deobf("appeng:appliedenergistics2:${config.ae2.version}:api") {
transitive = false
}
provided fg.deobf("mekanism:Mekanism:${config.mekanism.version}:api") {
transitive = false
}
provided fg.deobf("codechicken:CBMultipart:${config.cbmultipart.version}:universal") {
exclude module: jeiSlug
exclude module: "CodeChickenLib"
}
provided fg.deobf("codechicken:ChickenASM:${config.casm.version}")
provided fg.deobf("mezz.jei:${jeiSlug}:${config.jei.version}")
provided fg.deobf("codechicken:CodeChickenLib:${config.ccl.version}:universal")
provided fg.deobf("mrtjp:ProjectRed:${config.projred.version}:core") {
exclude module: "CodeChickenLib"
exclude module: jeiSlug
exclude module: "CBMultipart"
}
provided fg.deobf("mrtjp:ProjectRed:${config.projred.version}:integration") {
exclude module: "NotEnoughItems"
exclude module: "CodeChickenLib"
exclude module: "jei_1.12"
exclude module: "ForgeMultipart"
}
embedded name: 'OC-LuaJ', version: '20220907.1', ext: 'jar'
embedded name: 'OC-JNLua', version: '20230530.0', ext: 'jar'
embedded name: 'OC-JNLua-Natives', version: '20220928.1', ext: 'jar'
testImplementation "org.scala-lang:scala-library:2.13.4"
testImplementation "junit:junit:4.13.2"
testImplementation "org.mockito:mockito-core:3.4.0"
testImplementation "org.scalactic:scalactic_2.13:3.2.6"
testImplementation "org.scalatest:scalatest_2.13:3.2.6"
testImplementation "org.scalatestplus:junit-4-13_2.13:3.2.6.+"
testImplementation "org.scalatestplus:mockito-3-4_2.13:3.2.6.+"
provided fg.deobf("codechicken:EnderStorage:${config.enderstorage.version}:universal")
}
processResources {
def reducedScorgeVer = config.scorge.version.replaceAll(/(\d+\.\d+)(\.\d+)/, "\$1")
inputs.property "version", "${mod_version}"
inputs.property "mcversion", config.minecraft.version
inputs.property "sversion", reducedScorgeVer
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
filesMatching(['META-INF/mods.toml']) {
expand 'version':"${mod_version}", 'mcversion':config.minecraft.version, 'sversion':reducedScorgeVer
}
filesMatching(['application.conf']) {
filter { line ->
line.replaceAll("@VERSION@", "${mod_version}")
}
}
}
jar {
configurations.embedded.each { dep ->
from(project.zipTree(dep)) {
exclude '*', 'META-INF', 'META-INF/**'
}
}
manifest {
attributes([
"Specification-Title": "opencomputers",
"Specification-Vendor": "li.cil.oc",
"Specification-Version": "1",
"Implementation-Title": project.name,
"Implementation-Version": version,
"Implementation-Vendor": config.mod.group,
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
javadoc {
include 'li/cil/oc/api/**'
}
task apiJar(type: Jar) {
from sourceSets.main.allSource
from sourceSets.main.output
classifier = 'api'
include 'li/cil/oc/api/**'
}
task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
classifier 'javadoc'
}
artifacts {
archives apiJar
archives javadocJar
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId = project.group
artifactId = project.name
version = mod_version
artifact jar
artifact apiJar
artifact javadocJar
}
}
repositories {
maven {
name = "GitHubPackages"
url = System.getenv("GITHUB_MAVEN_URL") ?: ""
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
curseforge {
apiKey = System.getenv('CURSEFORGE_API_KEY') ?: ""
project {
id = config.curse.project.id
releaseType = System.getenv('CURSEFORGE_RELEASE_TYPE') ?: "alpha"
changelogType = "markdown"
changelog = System.getenv("CHANGELOG") ?: "Changelog not available."
addGameVersion config.minecraft.version
addGameVersion "Java 8"
addGameVersion "Forge"
}
}
modrinth {
token = System.getenv("MODRINTH_API_KEY") ?: ""
projectId = config.modrinth.project.id
changelog = System.getenv("CHANGELOG") ?: "Changelog not available."
versionNumber = mod_version
versionName = "${rootProject.name}-${version}"
versionType = System.getenv('MODRINTH_RELEASE_TYPE') ?: "alpha"
uploadFile = jar
gameVersions = [config.minecraft.version]
loaders = ["forge"]
}