-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.gradle
More file actions
484 lines (427 loc) · 16.1 KB
/
build.gradle
File metadata and controls
484 lines (427 loc) · 16.1 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
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
import java.time.format.DateTimeFormatter
buildscript{
ext.kotlin_version = '1.6.0'
ext{
def properties = new Properties().with{ p -> p.load(file('gradle.properties').newReader()); return p }
mindustryVersion = properties["mindustryVersion"]
jparcerVersion = properties["jparcerVersion"]
jabelVersion = properties["jabelVersion"]
parserVersion = properties["parserVersion"]
aciVersion = properties["aciVersion"]
modCoreVersion = properties["modCoreVersion"]
arcLibVersion = properties["arcLibVersion"]
kotlin_version = kotlinVersion = properties["kotlinVersion"]
// kotlinVersion = "1.5.31"
sdkRoot = System.getenv("ANDROID_HOME") ?: System.getenv("ANDROID_SDK_ROOT")
mindustryModule = { String name ->
//skip to last submodule
if(name.contains(':')) name = name.split(':').last()
return "com.github.Anuken.Mindustry:$name:$mindustryVersion"
}
arcModule = { String name ->
//skip to last submodule
if(name.contains(':')) name = name.split(':').last()
return "com.github.Anuken.Arc:$name:$mindustryVersion"
}
coreModule = { String name ->
//skip to last submodule
if(name.contains(':')) name = name.split(':').last()
return "com.github.Zelaux.ZelauxModCore:$name:$modCoreVersion"
}
arcLibModule = { String name ->
//skip to last submodule
if(name.contains(':')) name = name.split(':').last()
return "com.github.Zelaux.ZelauxArcLib:$name:$arcLibVersion"
}
}
repositories{
mavenLocal()
mavenCentral()
google()
maven{ url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven{ url 'https://jitpack.io' }
}
dependencies{
classpath arcModule("arc-core")
classpath mindustryModule("core")
classpath arcModule("packer")
classpath coreModule("annotations")
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
plugins{
id 'org.jetbrains.kotlin.jvm' version "$kotlinVersion"
id "org.jetbrains.kotlin.kapt" version "$kotlinVersion"
}
ext{
//the build number that this mod is made for
//version of SDK you will be using
sdkVersion = '30'
sdkRoot = System.getenv("ANDROID_HOME")
doExec = { cmd ->
def proc = cmd.execute(null, new File("$buildDir/libs"))
proc.waitForProcessOutput(System.out, System.err)
}
}
version '1.0'
allprojects{
apply plugin: 'groovy'
apply plugin: "kotlin"
// version = 'release'
group = 'com.github.Zelaux'
ext{
writeProcessors = {
new File(rootDir, "annotations/src/main/resources/META-INF/services/").mkdirs()
def processorFile = new File(rootDir, "annotations/src/main/resources/META-INF/services/javax.annotation.processing.Processor")
def text = new StringBuilder()
def files = new File(rootDir, "annotations/src/main/java")
files.eachFileRecurse(
groovy.io.FileType.FILES
){ file ->
boolean isProcessor = file.text.contains(" extends ModBaseProcessor") ||
(file.text.contains(" extends AbstractProcessor") && !file.text.contains("abstract class")) ||
file.text.contains("@ModAnnotations.AnnotationProcessor");
if(file.name.endsWith(".java") && isProcessor){
text.append(file.path.substring(files.path.length() + 1)).append("\n")
}
}
processorFile.text = text.toString().replace(".java", "").replace("/", ".").replace("\\", ".")
}
}
apply plugin: 'maven-publish'
repositories{
mavenLocal()
google()
mavenCentral()
maven{ url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven{ url "https://oss.sonatype.org/content/repositories/releases/" }
maven{ url 'https://jitpack.io' }
}
compileKotlin{
sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks.withType(JavaCompile){
targetCompatibility = 8
sourceCompatibility = JavaVersion.VERSION_16
options.encoding = "UTF-8"
// options.encoding = "windows-1251"
options.compilerArgs += ["-Xlint:deprecation"]
options.forkOptions.jvmArgs.addAll([
'--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED',
'--add-opens=java.base/sun.reflect.annotation=ALL-UNNAMED'
])
}
}
configure(project(":annotations")){
tasks.withType(JavaCompile){
targetCompatibility = 8
sourceCompatibility = 8
options.fork = true
}
}
//compile with java 8 compatibility for everything except the annotation project
configure(subprojects - project(":annotations")){
tasks.withType(JavaCompile){
options.compilerArgs.addAll(['--release', '8'])
}
tasks.withType(Javadoc){
options{
addStringOption('Xdoclint:none', '-quiet')
addStringOption('-release', '16')
}
}
}
//project(":core")
[":core:original", ":core"].collect{
project(it){
apply plugin: "java-library"
apply plugin: "kotlin"
apply plugin: "kotlin-kapt"
kapt{
javacOptions{
option("-source", "17")
option("-target", "1.8")
}
}
compileJava.options.fork = true
task preGen{
outputs.upToDateWhen{ false }
// generateLocales()
// writeVersion()
writeProcessors()
// writePlugins()
}
task sourcesJar(type: Jar, dependsOn: classes){
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
archiveClassifier = 'sources'
from sourceSets.main.allSource
}
task assetsJar(type: Jar, dependsOn: ":tools:pack"){
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
archiveClassifier = 'assets'
from files("assets"){
exclude "config", "cache", "music", "sounds"
}
}
artifacts{
archives sourcesJar
archives assetsJar
}
repositories{
mavenCentral()
}
compileKotlin{
kotlinOptions{
jvmTarget = "1.8"
}
}
compileTestKotlin{
kotlinOptions{
jvmTarget = "1.8"
}
}
dependencies{
compileJava.dependsOn(preGen)
implementation arcLibModule("defaults")
implementation arcLibModule("utils")
implementation arcLibModule("tooltips")
implementation arcLibModule("components")
implementation arcLibModule("listeners")
implementation coreModule("tiledStructures")
implementation coreModule("core")
implementation coreModule("utils")
implementation coreModule("graphics")
compileOnly "org.lz4:lz4-java:1.7.1"
compileOnly arcModule("arc-core")
compileOnly arcModule("extensions:flabel")
compileOnly arcModule("extensions:freetype")
compileOnly arcModule("extensions:g3d")
compileOnly arcModule("extensions:fx")
compileOnly arcModule("extensions:arcnet")
compileOnly mindustryModule("core")
// implementation "com.github.Zelaux:AdvancedContentInfo:$aciVersion"
annotationProcessor 'com.github.Anuken:jabel:34e4c172e65b3928cd9eabe1993654ea79c409cd'
compileOnly coreModule("annotations")
compileOnly project(":annotations")
// println "it is ${project.displayName}"
if(project.name == "core"){
kapt(
coreModule("annotations"), project(":annotations"))
// kapt project(":annotations")
}
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
// annotationProcessor 'com.github.Anuken:jabel:34e4c172e65b3928cd9eabe1993654ea79c409cd'
}
afterEvaluate{
task mergedJavadoc(type: Javadoc){
if(true) return null;
def blacklist = [project(":annotations")]
if(findProject(":android") != null){
blacklist += project(":android")
}
source rootProject.subprojects.collect{ project ->
if(!blacklist.contains(project) && project.hasProperty("sourceSets")){
return project.sourceSets.main.allJava
}
}
classpath = files(rootProject.subprojects.collect{ project ->
if(!blacklist.contains(project) && project.hasProperty("sourceSets")){
return project.sourceSets.main.compileClasspath
}
})
destinationDir = new File(buildDir, 'javadoc')
}
}
jar{
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
exclude("bytelogic/entities/comp/**")
exclude("bytelogic/entities/compByAnuke/**")
}
}
}
project(":tools"){
apply plugin: "java"
dependencies{
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'commons-io:commons-io:2.5'
implementation("org.apache.xmlgraphics:batik-svgrasterizer:1.9")
implementation project(":core")
implementation 'com.github.javaparser:javaparser-symbol-solver-core:3.22.1'
implementation mindustryModule("core")
implementation arcModule("natives:natives-desktop")
implementation arcModule("natives:natives-freetype-desktop")
implementation arcModule("backends:backend-headless")
implementation arcModule("backends:backend-sdl")
implementation coreModule("core")
implementation 'com.github.sterlp:svg2png:1.0.0'
implementation coreModule("tools")
implementation arcModule(":extensions:packer")
}
}
project(":annotations"){
apply plugin: "java-library"
dependencies{
implementation 'com.squareup:javapoet:1.12.1'
implementation arcModule('arc-core')
implementation mindustryModule("core")
implementation "com.github.javaparser:javaparser-symbol-solver-core:$jparcerVersion"
implementation "com.github.Zelaux.ZelauxModCore:core:$modCoreVersion"
implementation "com.github.Zelaux.ZelauxModCore:tools:$modCoreVersion"
implementation "com.github.Zelaux.ZelauxModCore:annotations:$modCoreVersion"
}
}
configure([project(":core")]){
java{
withJavadocJar()
withSourcesJar()
}
publishing{
publications{
maven(MavenPublication){
from components.java
}
}
}
}
task jarAndroid{
dependsOn "jar"
doLast{
//collect dependencies needed for desugaring
def files = (
project(":core").configurations.compileClasspath.asList() +
project(":core").configurations.runtimeClasspath.asList() +
configurations.runtimeClasspath.asList() +
[new File("$sdkRoot/platforms/android-$sdkVersion/android.jar")]
)
def dependencies = files.collect{ "--classpath $it.path" }.join(" ")
//dex and desugar files - this requires d8 in your PATH
doExec("d8 $dependencies --min-api 14 --output ${project.archivesBaseName}Android.jar ${project.archivesBaseName}Desktop.jar")
}
}
jar{
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
dependsOn "core:jar"
archiveFileName = "${project.archivesBaseName}Desktop.jar"
// if (!file(rootDir+"/core/assets/sprites").exists())dependsOn "tools:pack"
from{
// configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
project(":core").fileTree("build/libs/core.jar").collect{ it.isDirectory() ? it : zipTree(it) }
}
from{
project(":core").configurations.runtimeClasspath.collect{ it.isDirectory() ? it : zipTree(it) }
// project(":core").fileTree("build/libs/core.jar").collect { it.isDirectory() ? it : zipTree(it) }
}
from(rootDir){
include "mod.hjson"
include "mod.json"
include "icon.png"
}
from("core/assets/"){
include "**"
}
}
task deploy(type: Jar){
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
dependsOn jarAndroid
dependsOn jar
archiveFileName = "${project.archivesBaseName}.jar"
from{ [zipTree("$buildDir/libs/${project.archivesBaseName}Desktop.jar"), zipTree("$buildDir/libs/${project.archivesBaseName}Android.jar")] }
doLast{
delete{ delete "$buildDir/libs/${project.archivesBaseName}Desktop.jar" }
delete{ delete "$buildDir/libs/${project.archivesBaseName}Android.jar" }
}
}
task resolveDependencies{
doLast{
rootProject.allprojects{ project ->
Set<Configuration> configurations = project.buildscript.configurations + project.configurations
configurations.findAll{ c -> c.canBeResolved }.forEach{ c -> c.resolve() }
}
}
}
publishToMavenLocal{
dependsOn("tools:pack")
dependsOn("jar")
}
def os(){ //Returns OS name
String s = System.getProperty("os.name");
return s == null ? "" : s;
}
def getdatadir(){ //Returns Mindustry data directory path
def ret = System.getenv("MINDUSTRY_DATA_DIR")
if(ret == null){
def os = os()
if(os.contains("Windows")){
return System.getenv("AppData") + "\\Mindustry\\"
}else if(os.contains("Linux") || os.contains("BSD")){
if(System.getenv("XDG_DATA_HOME") != null){
String dir = System.getenv("XDG_DATA_HOME")
if(!dir.endsWith("/")) dir += "/"
return dir + "Mindustry/"
}
return System.getProperty("user.home") + "/.local/share/Mindustry/"
}else if(os.contains("Mac")){
return System.getProperty("user.home") + "/Library/Application Support/Mindustry/";
}
}
return ret
}
task mjar(){
dependsOn "jar"
doFirst{}
ext{
acopy = { String intoPath ->
delete{
delete "${intoPath}/${project.archivesBaseName}Desktop.jar"
}
copy{
from "$buildDir/libs/${project.archivesBaseName}Desktop.jar"
into intoPath
}
println "Moved to ${intoPath}"
}
}
doLast{
def modsDirectories = [];
def file = new File(rootDir, "modsDirectories.txt");
if(file.exists()){
BufferedReader reader = new BufferedReader(new FileReader(file));
reader.lines().forEach(line -> modsDirectories.add(line))
reader.close();
}else{
modsDirectories.add("classic");
}
for(String directory : modsDirectories){
if(directory.startsWith("//") || directory.startsWith("#")){
println "Directory \"$directory\" skipped"
continue
}
if(directory.equals("classic")){
directory = getdatadir() + "mods";
}
acopy(directory);
}
def time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"));
println "Build ended at: ${time}"
}
}
repositories{
mavenCentral()
}
compileKotlin{
kotlinOptions{
jvmTarget = "1.8"
}
}
compileTestKotlin{
kotlinOptions{
jvmTarget = "1.8"
}
}