forked from Anuken/Mindustry
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
336 lines (273 loc) · 10.4 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
buildscript{
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.badlogicgames.gdx:gdx-tools:1.9.10"
classpath "com.github.anuken:packr:-SNAPSHOT"
}
}
allprojects{
version = 'release'
apply plugin: 'maven'
group = 'com.github.Anuken'
ext{
versionNumber = '5'
if(!project.hasProperty("versionModifier")) versionModifier = 'release'
if(!project.hasProperty("versionType")) versionType = 'official'
appName = 'Mindustry'
gdxVersion = '1.9.10'
roboVMVersion = '2.3.8'
steamworksVersion = '891ed912791e01fe9ee6237a6497e5212b85c256'
arcHash = null
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()
}
getArcHash = {
return new Properties().with{ p -> p.load(file('gradle.properties').newReader()); return p }["archash"]
}
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
}
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.")
}
}
}
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(Javadoc).all{ enabled = false }
}
project(":desktop"){
apply plugin: "java"
dependencies{
compile project(":core")
if(debugged()) compile project(":debug")
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
compile "com.github.Anuken:steamworks4j:$steamworksVersion"
compile arcModule("backends:backend-sdl")
compile 'com.github.MinnDevelopment:java-discord-rpc:v2.0.1'
}
}
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'] = 'io.anuke.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{
compile project(":core")
compileOnly project(":annotations")
compile arcModule("backends:backend-robovm")
compile "com.mobidevelop.robovm:robovm-rt:$roboVMVersion"
compile "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"
}
}
project(":core"){
apply plugin: "java"
task preGen{
outputs.upToDateWhen{ false }
generateLocales()
writeVersion()
}
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{
if(System.properties["user.name"] == "anuke"){
task cleanGen{
doFirst{
delete{
delete "../core/src/io/anuke/mindustry/gen/"
}
}
}
task copyGen{
doLast{
copy{
from("../core/build/generated/sources/annotationProcessor/java/main/io/anuke/mindustry/gen"){
include "**/*.java"
}
into "../core/src/io/anuke/mindustry/gen"
}
}
}
compileJava.dependsOn(cleanGen)
compileJava.finalizedBy(copyGen)
}
compileJava.dependsOn(preGen)
compile "org.lz4:lz4-java:1.4.1"
compile arcModule("arc-core")
compile arcModule("extensions:freetype")
compile arcModule("extensions:arcnet")
compile "org.mozilla:rhino:1.7.11"
if(localArc() && debugged()) compile arcModule("extensions:recorder")
compileOnly project(":annotations")
annotationProcessor project(":annotations")
}
}
project(":server"){
apply plugin: "java"
dependencies{
compile project(":core")
compile 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"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.3.1"
compile arcModule("backends:backend-headless")
}
test{
useJUnitPlatform()
workingDir = new File("../core/assets")
}
}
project(":tools"){
apply plugin: "java"
dependencies{
compile project(":core")
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
compile "org.reflections:reflections:0.9.11"
compile arcModule("backends:backend-sdl")
}
}
project(":annotations"){
apply plugin: "java"
dependencies{
compile 'com.squareup:javapoet:1.11.0'
compile 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"
}