forked from Anuken/Mindustry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
359 lines (296 loc) · 12.1 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
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
buildscript{
ext{
getArcHash = {
return new Properties().with{ p -> p.load(file('gradle.properties').newReader()); return p }["archash"]
}
arcHash = getArcHash()
}
repositories{
mavenLocal()
mavenCentral()
google()
maven{ url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
maven{ url 'https://jitpack.io' }
}
dependencies{
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.8'
classpath "com.github.anuken:packr:-SNAPSHOT"
classpath "com.github.Anuken.Arc:packer:$arcHash"
classpath "com.github.Anuken.Arc:arc-core:$arcHash"
}
}
allprojects{
apply plugin: 'maven'
version = 'release'
group = 'com.github.Anuken'
ext{
versionNumber = '6'
if(!project.hasProperty("versionModifier")) versionModifier = 'pre-alpha'
if(!project.hasProperty("versionType")) versionType = 'official'
appName = 'Mindustry'
steamworksVersion = '891ed912791e01fe9ee6237a6497e5212b85c256'
rhinoVersion = 'eeb327d141146663ff3924bd20d2a5da8a6439cc'
loadVersionProps = {
return new Properties().with{p -> p.load(file('../core/assets/version.properties').newReader()); return p }
}
debugged = {
return new File(projectDir.parent, '../Mindustry-Debug').exists() && !project.hasProperty("release") && project.hasProperty("args")
}
localArc = {
return !project.hasProperty("release") && new File(projectDir.parent, '../Arc').exists()
}
arcModule = { String name ->
if(localArc()){
return project(":Arc:$name")
}else{
//skip to last submodule
if(name.contains(':')) name = name.split(':').last()
return "com.github.Anuken.Arc:$name:${getArcHash()}"
}
}
generateDeployName = { String platform ->
if(platform == "windows"){
platform += "64"
}
platform = platform.capitalize()
if(platform.endsWith("64") || platform.endsWith("32")){
platform = "${platform.substring(0, platform.length() - 2)}-${platform.substring(platform.length() - 2)}bit"
}
return "[${platform}]${getModifierString()}[${getNeatVersionString()}]${appName}"
}
getVersionString = {
String buildVersion = getBuildVersion()
return "$versionNumber-$versionModifier-$buildVersion"
}
getNeatVersionString = {
String buildVersion = getBuildVersion()
return "v$buildVersion"
}
getModifierString = {
if(versionModifier != "release"){
return "[${versionModifier.toUpperCase()}]"
}
return ""
}
getBuildVersion = {
if(!project.hasProperty("buildversion")) return "custom build"
return project.getProperties()["buildversion"]
}
getPackage = {
return project.ext.mainClassName.substring(0, project.ext.mainClassName.indexOf("desktop") - 1)
}
generateLocales = {
def output = 'en\n'
def bundles = new File(project(':core').projectDir, 'assets/bundles/')
bundles.listFiles().each{ other ->
if(other.name == "bundle.properties") return
output += other.name.substring("bundle".length() + 1, other.name.lastIndexOf('.')) + "\n"
}
new File(project(':core').projectDir, 'assets/locales').text = output
new File(project(':core').projectDir, 'assets/basepartnames').text = new File(project(':core').projectDir, 'assets/baseparts/').list().join("\n")
}
writeVersion = {
def pfile = new File(project(':core').projectDir, 'assets/version.properties')
def props = new Properties()
try{
pfile.createNewFile()
}catch(Exception ignored){
}
if(pfile.exists()){
props.load(new FileInputStream(pfile))
String buildid = getBuildVersion()
println("Compiling with build: '$buildid'")
props["type"] = versionType
props["number"] = versionNumber
props["modifier"] = versionModifier
props["build"] = buildid
props.store(pfile.newWriter(), "Autogenerated file. Do not modify.")
}
}
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 ->
if(file.name.endsWith(".java") && (file.text.contains(" extends BaseProcessor") || (file.text.contains(" extends AbstractProcessor") && !file.text.contains("abstract class")))){
text.append(file.path.substring(files.path.length() + 1)).append("\n")
}
}
processorFile.text = text.toString().replace(".java", "").replace("/", ".").replace("\\", ".")
}
writePlugins = {
new File(rootDir, "annotations/src/main/resources/META-INF/services/").mkdirs()
def processorFile = new File(rootDir, "annotations/src/main/resources/META-INF/services/com.sun.source.util.Plugin")
def text = new StringBuilder()
def files = new File(rootDir, "annotations/src/main/java")
files.eachFileRecurse(groovy.io.FileType.FILES){ file ->
if(file.name.endsWith(".java") && (file.text.contains(" implements Plugin"))){
text.append(file.path.substring(files.path.length() + 1)).append("\n")
}
}
processorFile.text = text.toString().replace(".java", "").replace("/", ".").replace("\\", ".")
}
}
repositories{
mavenLocal()
mavenCentral()
maven{ url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven{ url "https://oss.sonatype.org/content/repositories/releases/" }
maven{ url 'https://jitpack.io' }
jcenter()
}
tasks.withType(JavaCompile){
sourceCompatibility = 1.8
targetCompatibility = 1.8
options.encoding = "UTF-8"
options.compilerArgs += ["-Xlint:deprecation"]
}
}
project(":desktop"){
apply plugin: "java"
compileJava.options.fork = true
dependencies{
implementation project(":core")
implementation arcModule("natives:natives-box2d-desktop")
implementation arcModule("natives:natives-desktop")
implementation arcModule("natives:natives-freetype-desktop")
implementation 'com.github.MinnDevelopment:java-discord-rpc:v2.0.1'
if(debugged()) implementation project(":debug")
implementation "com.github.Anuken:steamworks4j:$steamworksVersion"
implementation arcModule("backends:backend-sdl")
}
}
project(":ios"){
apply plugin: "java"
apply plugin: "robovm"
task incrementConfig{
def vfile = file('robovm.properties')
def props = new Properties()
if(vfile.exists()){
props.load(new FileInputStream(vfile))
}else{
props['app.id'] = 'io.anuke.mindustry'
props['app.version'] = '5.0'
props['app.mainclass'] = 'mindustry.IOSLauncher'
props['app.executable'] = 'IOSLauncher'
props['app.name'] = 'Mindustry'
}
props['app.build'] = (!props.containsKey("app.build") ? 40 : props['app.build'].toInteger() + 1) + ""
props.store(vfile.newWriter(), null)
}
dependencies{
implementation project(":core")
implementation arcModule("natives:natives-ios")
implementation arcModule("natives:natives-freetype-ios")
implementation arcModule("natives:natives-box2d-ios")
implementation arcModule("backends:backend-robovm")
compileOnly project(":annotations")
}
}
project(":core"){
apply plugin: "java-library"
task preGen{
outputs.upToDateWhen{ false }
generateLocales()
writeVersion()
writeProcessors()
writePlugins()
}
task copyChangelog{
doLast{
def props = loadVersionProps()
def androidVersion = props['androidBuildCode'].toInteger() - 2
def buildVersion = props["build"]
def loglines = file("../changelog").text.split("\n")
def maxLength = 460
def androidLogList = loglines.findAll{ line -> !line.endsWith("]") || line.endsWith("[Mobile]") || line.endsWith("[Android]")}
def result = ""
androidLogList.forEach{line ->
if(result.length() + line.length() + 1 < maxLength){
result += line + "\n"
}
}
def changelogs = file("../fastlane/metadata/android/en-US/changelogs/")
new File(changelogs, buildVersion + ".txt").text = (result)
new File(changelogs, androidVersion + ".txt").text = (result)
}
}
dependencies{
compileJava.dependsOn(preGen)
api "org.lz4:lz4-java:1.4.1"
api arcModule("arc-core")
api arcModule("extensions:freetype")
api arcModule("extensions:box2d")
api arcModule("extensions:g3d")
api arcModule("extensions:fx")
api arcModule("extensions:arcnet")
api "com.github.Anuken:rhino:$rhinoVersion"
if(localArc() && debugged()) api arcModule("extensions:recorder")
compileOnly project(":annotations")
annotationProcessor project(":annotations")
}
}
project(":server"){
apply plugin: "java"
dependencies{
implementation project(":core")
implementation arcModule("natives:natives-box2d-desktop")
implementation arcModule("backends:backend-headless")
}
}
project(":tests"){
apply plugin: "java"
dependencies{
testImplementation project(":core")
testImplementation "org.junit.jupiter:junit-jupiter-params:5.3.1"
testImplementation "org.junit.jupiter:junit-jupiter-api:5.3.1"
testImplementation arcModule("backends:backend-headless")
testImplementation arcModule("natives:natives-box2d-desktop")
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.3.1"
}
test{
useJUnitPlatform()
workingDir = new File("../core/assets")
testLogging {
exceptionFormat = 'full'
}
}
}
project(":tools"){
apply plugin: "java"
dependencies{
implementation project(":core")
implementation arcModule("natives:natives-desktop")
implementation arcModule("natives:natives-freetype-desktop")
implementation arcModule("natives:natives-box2d-desktop")
implementation arcModule("backends:backend-headless")
}
}
project(":annotations"){
apply plugin: "java-library"
dependencies{
implementation 'com.squareup:javapoet:1.12.1'
implementation "com.github.Anuken.Arc:arc-core:$arcHash"
implementation files("${System.getProperty('java.home')}/../lib/tools.jar")
}
}
task deployAll{
task cleanDeployOutput{
doFirst{
if(getBuildVersion() == "custom build" || getBuildVersion() == "") throw new IllegalArgumentException("----\n\nSET A BUILD NUMBER FIRST!\n\n----")
if(!project.hasProperty("release")) throw new IllegalArgumentException("----\n\nSET THE RELEASE PROJECT PROPERTY FIRST!\n\n----")
delete{
delete "deploy/"
}
}
}
dependsOn cleanDeployOutput
dependsOn "desktop:packrLinux64"
dependsOn "desktop:packrWindows64"
dependsOn "desktop:packrWindows32"
dependsOn "desktop:packrMacOS"
dependsOn "server:deploy"
dependsOn "android:deploy"
}