-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild.gradle
272 lines (227 loc) · 7.92 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
buildscript {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
}
}
// Read build properties
ext {
buildProperties = new Properties()
file("assets/version").withReader { reader ->
buildProperties.load(reader)
buildProperties.version = buildProperties.major + "." + buildProperties.minor + "." + buildProperties.point
println "VERSION: " + buildProperties.version
}
build = ""
hash = ""
if (hasGit()) {
build = shell("git rev-list HEAD --count").text.trim()
hash = shell("git rev-parse HEAD").text.trim()
println "BUILD: " + build
println "HASH: " + hash
} else {
println "Git was not found in path!"
file("assets/build").delete()
}
localProperties = new Properties()
if (file("build.properties").exists()) {
file("build.properties").withReader { reader ->
localProperties.load(reader)
}
}
def defaultProperties = [
ANDROID_KEYSTORE_FILE: "keystore",
ANDROID_KEYSTORE_PASSWORD: "password",
ANDROID_KEYSTORE_KEY_ALIAS: "android",
ANDROID_KEYSTORE_KEY_PASSWORD: "password",
MAVEN_REPO_PATH: "https://ethanjones.me/maven/",
MAVEN_REPO_USERNAME: "",
MAVEN_REPO_PASSWORD: ""
]
defaultProperties.each {key, defaultValue ->
def env = System.getenv(key)
if (env) {
localProperties.setProperty(key, env)
} else if (!localProperties.getProperty(key)) {
localProperties.setProperty(key, defaultValue)
}
}
println "REPO: " + localProperties.MAVEN_REPO_PATH
}
// Write build file
afterEvaluate {
if (hash != "") {
file("assets/build").write("build=" + ext.build + "\nhash=" + ext.hash + "\nisRelease=" + isRelease + "\nbuildDate=" + getDateString() + "\n", 'UTF-8')
}
}
// Delete build file
project.getGradle().buildFinished {
file("assets/build").delete()
}
// Set general properties
allprojects {
version = System.getenv("BUILD_NUMBER")
ext {
appName = 'Cubes'
gdxVersion = '1.9.10'
androidBuildToolsVersion = '29.0.2'
androidSdkVersion = 29
dataVersion = '2.2'
byteBuddyVersion = '1.6.13'
buildProperties = getRootProject().buildProperties
build = getRootProject().build
localProperties = getRootProject().localProperties
isRelease = false
}
repositories {
mavenLocal()
jcenter()
google()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
maven { url "https://ethanjones.me/maven/snapshots/" }
maven { url "https://ethanjones.me/maven/releases/" }
}
}
// Individual subprojects plugins & dependencies
project(":core") {
apply plugin: "java"
apply plugin: "maven-publish"
sourceCompatibility = 1.7
dependencies {
compile 'com.eclipsesource.minimal-json:minimal-json:0.9.4'
compile 'org.luaj:luaj-jse:3.0.1'
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile "ethanjones:data:$dataVersion"
compile "net.bytebuddy:byte-buddy:$byteBuddyVersion"
}
}
project(":desktop") {
apply plugin: "java"
sourceCompatibility = 1.8
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
}
}
project(":client") {
apply plugin: "java"
apply plugin: "maven-publish"
sourceCompatibility = 1.8
dependencies {
compile project(":desktop")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
}
}
project(":server") {
apply plugin: "java"
apply plugin: "maven-publish"
sourceCompatibility = 1.8
dependencies {
compile project(":desktop")
compile "com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion"
}
}
project(":android") {
apply plugin: "android"
apply plugin: "maven-publish"
configurations { natives }
dependencies {
implementation project(":core")
implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
implementation("net.bytebuddy:byte-buddy-android:$byteBuddyVersion") {
exclude group:"com.jakewharton.android.repackaged"
}
implementation "ethanjones.repackaged.android:dx:7.1.2_r33"
}
}
// Setup java subprojects
subprojects {
if (project.plugins.hasPlugin('org.gradle.java')) {
apply plugin: "idea"
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceSets.main.java.srcDirs = ["src/"]
compileJava {
options.fork = true
options.incremental = true
}
idea {
module {
scopes.PROVIDED.minus += [configurations.compile]
scopes.COMPILE.plus += [configurations.compile]
}
}
}
}
// Aliases
task buildAll(dependsOn: ['core:jar', 'core:sourcesJar', 'client:dist', 'client:createExe', 'server:dist', 'android:assembleDebug'], description: "Build everything", group: "Alias") {
}
task ci(dependsOn: ['core:jar', 'client:dist', 'client:createExe', 'server:dist', 'android:assembleDebug']) {
}
task ciPublish(dependsOn: ['core:publish', 'client:publish', 'server:publish', 'android:publish']) {
}
// Deletes intellij & eclipse project files
//task deleteProject(type: Delete, description: "Delete intellij & eclipse project files", group: "IDE") {
// delete fileTree(dir: project.rootDir, include: '**/*.iml')
// delete fileTree(dir: project.rootDir, include: '**/*.ipr')
// delete fileTree(dir: project.rootDir, include: '**/*.iws')
// delete fileTree(dir: project.rootDir, include: '**/*.project')
// delete fileTree(dir: project.rootDir, include: '**/*.classpath')
//
// allprojects.each { p ->
// new File(p.projectDir, '.idea/').deleteDir()
// new File(p.projectDir, '.settings/').deleteDir()
// }
//}
// Helper functions
String getMavenVersionString() {
def str = buildProperties.version
if (!isRelease) {
str = str + "-SNAPSHOT"
}
return str
}
String getMavenRepo() {
def str = localProperties.MAVEN_REPO_PATH
if (isRelease) {
str = str + "releases"
} else {
str = str + "snapshots"
}
return str
}
String getDateString() {
TimeZone tz = TimeZone.getTimeZone("UTC");
java.text.DateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
df.setTimeZone(tz);
return df.format(new Date());
}
boolean hasGit() {
try {
def proc = "git rev-parse --short HEAD".execute()
proc.waitFor()
return proc.exitValue() == 0
} catch (Throwable t) {
return false
}
}
Process shell(String str) {
def proc = str.execute()
proc.waitFor()
return proc
}