-
Notifications
You must be signed in to change notification settings - Fork 406
/
Copy pathbuild.gradle
339 lines (290 loc) · 10.2 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
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.1'
}
}
plugins {
id 'java'
id 'application'
id 'checkstyle'
id 'jacoco'
id 'com.github.ben-manes.versions' version '0.12.0'
id 'com.github.johnrengelman.shadow' version '1.2.3'
id 'com.install4j.gradle' version '7.0.1'
id 'de.undercouch.download' version '3.2.0'
id "net.ltgt.errorprone" version "0.0.11"
}
apply from: 'gradle/scripts/yaml.gradle'
apply plugin: 'org.junit.platform.gradle.plugin'
group = 'triplea'
description = 'TripleA is a free online turn based strategy game and board game engine, similar to such board games as Axis & Allies or Risk.'
mainClassName = "games.strategy.engine.framework.GameRunner"
ext {
artifactsDir = file("$buildDir/artifacts")
releasesDir = file("$buildDir/releases")
rootFilesDir = file("$buildDir/rootFiles")
schemasDir = file('config/triplea/schemas')
gameEnginePropertiesFile = file('game_engine.properties')
gameEnginePropertiesArtifactFile = file("$rootFilesDir/${gameEnginePropertiesFile.name}")
}
def getEngineVersion() {
if (project.hasProperty('engineVersion')) {
return project.engineVersion
}
def props = new Properties()
gameEnginePropertiesFile.withInputStream { props.load(it) }
def devEngineVersion = props.getProperty('engine_version')
if (devEngineVersion) {
return "${devEngineVersion}.dev"
}
throw new GradleException("unable to determine engine version: "
+ "you must define either the project property 'engineVersion' or the game engine property 'engine_version'")
}
version = getEngineVersion()
sourceSets {
integTest {
java.srcDir 'src/integ_test/java'
resources.srcDir 'src/integ_test/resources'
compileClasspath = sourceSets.main.output + sourceSets.test.output + configurations.testRuntime + configurations.junitPlatform
runtimeClasspath = output + compileClasspath
}
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
tasks.withType(JavaCompile) {
options.compilerArgs += [ '-Xlint:all' ]
options.incremental = true
options.encoding = 'UTF-8'
}
jar {
manifest {
attributes 'Main-Class': mainClassName, 'TripleA-Version': version
}
}
repositories {
jcenter()
}
dependencies {
errorprone 'com.google.errorprone:error_prone_core:2.0.5'
compile 'commons-io:commons-io:2.5'
compile 'org.postgresql:postgresql:42.1.4'
compile 'com.github.insubstantial:substance:7.3'
compile 'com.google.code.findbugs:jsr305:3.0.2'
compile 'com.google.guava:guava:23.2-jre'
compile 'com.googlecode.soundlibs:jlayer:1.0.1.4'
compile 'com.sun.mail:mailapi:1.6.0'
compile 'com.sun.mail:smtp:1.6.0'
compile 'commons-io:commons-io:2.5'
compile 'org.apache.httpcomponents:httpclient:4.5.3'
compile 'org.apache.httpcomponents:httpmime:4.5.3'
compile 'org.apache.commons:commons-math3:3.6.1'
compile 'org.mindrot:jbcrypt:0.4'
compile 'org.yaml:snakeyaml:1.18'
compile 'org.json:json:20170516'
compile 'com.yuvimasory:orange-extensions:1.3.0'
testCompile 'eu.codearte.catch-exception:catch-exception:2.0.0-ALPHA-1'
testCompile 'nl.jqno.equalsverifier:equalsverifier:2.3.3'
testCompile 'org.hamcrest:java-hamcrest:2.0.0.0'
testCompile 'org.mockito:mockito-core:2.11.0'
testRuntime 'org.junit.platform:junit-platform-launcher:1.0.1'
testCompile 'org.junit.jupiter:junit-jupiter-api:5.0.1'
testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.0.1'
}
task integTest(type: JavaExec) {
group = LifecycleBasePlugin.VERIFICATION_GROUP
description = 'Runs the integration tests.'
classpath = sourceSets.integTest.runtimeClasspath
main = 'org.junit.platform.console.ConsoleLauncher'
args '--details', 'none'
args "--reports-dir=$project.buildDir/integ-test-results/junit-platform"
args '--scan-classpath'
args '--include-classname', '^.*IntegrationTests?$'
mustRunAfter tasks.test
}
task jacocoRootReport(type: JacocoReport) {
group = LifecycleBasePlugin.VERIFICATION_GROUP
description = 'Generates code coverage report for all Test tasks.'
sourceSets sourceSets.main
executionData fileTree(buildDir).include('**/jacoco/*.exec')
reports {
html {
destination = file("${project.jacoco.reportsDir}/root/html")
enabled = true
}
xml {
destination = file("${project.jacoco.reportsDir}/root/jacocoRootReport.xml")
enabled = true
}
}
}
task validateYamls(group: 'verification', description: 'Validates YAML files.') {
doLast {
def lobbyServerYamlFile = file('lobby_server.yaml')
validateYaml(lobbyServerYamlFile, file("$schemasDir/lobby_server.json"))
def mapsYamlFile = file('triplea_maps.yaml')
validateYaml(mapsYamlFile, file("$schemasDir/triplea_maps.json"))
validateMapsYamlUris(mapsYamlFile)
}
}
task renameShadowJar(type: Copy, group: 'release', dependsOn: [shadowJar]) {
ext.output = file("$libsDir/all/triplea.jar")
from shadowJar.archivePath
into ext.output.parent
rename shadowJar.archivePath.name, output.name
}
task downloadAssets(group: 'release') {
doLast {
[
'icons/triplea_icon_16_16.png',
'icons/triplea_icon_32_32.png',
'icons/triplea_icon_48_48.png',
'icons/triplea_icon_64_64.png',
'icons/triplea_icon_128_128.png',
'icons/triplea_icon_256_256.png',
'install4j/macosx-amd64-1.8.0_144.tar.gz',
'install4j/windows-amd64-1.8.0_144.tar.gz',
'install4j/windows-x86-1.8.0_144.tar.gz'
].each { path ->
download {
src "https://raw.githubusercontent.com/triplea-game/assets/master/$path"
dest "$buildDir/assets/$path"
overwrite false
}
}
}
}
task prepareGameEngineProperties() {
group = 'release'
description = 'Updates the game engine properties with final values for distribution.'
doLast {
copy {
from gameEnginePropertiesFile
into gameEnginePropertiesArtifactFile.parent
}
ant.propertyfile(file: gameEnginePropertiesArtifactFile) {
entry key: 'engine_version', value: version
}
}
}
task allPlatform(type: Zip, group: 'release', dependsOn: [renameShadowJar, prepareGameEngineProperties]) {
classifier 'all_platforms'
['assets', 'dice_servers'].each { folder ->
from(folder) {
into(folder)
}
}
from(gameEnginePropertiesArtifactFile)
from(renameShadowJar.output) {
into('bin')
}
}
task lobbyServer(type: Zip, group: 'release', dependsOn: renameShadowJar) {
classifier 'server'
['config/lobby/lobby.properties'].each { fileName ->
from(fileName) {
into('config/lobby')
}
}
from(renameShadowJar.output) {
into('bin')
}
}
task generateZipReleases(group: 'release', dependsOn: [allPlatform, lobbyServer]) {}
import com.install4j.gradle.Install4jTask
task generateInstallers(type: Install4jTask, dependsOn: [renameShadowJar, downloadAssets], group: 'release') {
projectFile = file('build.install4j')
release project.version
doFirst {
logger.lifecycle("building installer release of version '${project.version}'")
}
}
task prepareInstallers(group: 'release', dependsOn: [generateInstallers]) {
doLast {
ant.chmod(dir: releasesDir, perm: '+x', includes: '*.sh')
}
}
task prepareArtifacts(group: 'release', dependsOn: [generateZipReleases, prepareInstallers]) {
doLast {
def artifacts = [
file("$libsDir/triplea-$version-all.jar"),
file("$distsDir/triplea-$version-all_platforms.zip"),
file("$distsDir/triplea-$version-server.zip"),
file("$releasesDir/TripleA_${version}_macos.dmg"),
file("$releasesDir/TripleA_${version}_unix.sh"),
file("$releasesDir/TripleA_${version}_windows-32bit.exe"),
file("$releasesDir/TripleA_${version}_windows-64bit.exe")
]
artifacts.each {
if (!it.exists()) {
throw new GradleException("artifact '$it' does not exist")
}
}
copy {
from artifacts
into artifactsDir
}
}
}
task release(group: 'release', dependsOn: [prepareArtifacts]) {}
gradle.taskGraph.whenReady { graph ->
graph.getAllTasks().any({
if (it.name == "generateInstallers") {
if (!project.hasProperty('install4jHomeDir')) {
File propertiesFile = file("${System.getProperty('user.home')}/.gradle/gradle.properties")
throw new RuntimeException("Specify install4jHomeDir in $propertiesFile")
}
def p = file(project.install4jHomeDir)
logger.lifecycle('using install4j home directory ' + p.getAbsolutePath())
it.project.install4j.installDir = file(project.install4jHomeDir)
}
})
}
tasks.withType(Test) {
testLogging {
exceptionFormat = 'full'
}
}
check {
dependsOn 'integTest', 'validateYamls'
}
checkstyle {
toolVersion = "8.0"
configProperties = [samedir: configFile.parent]
}
checkstyleIntegTest {
maxWarnings = checkstyleIntegTestMaxWarnings.toInteger()
source sourceSets.integTest.output.resourcesDir
}
checkstyleMain {
maxWarnings = checkstyleMainMaxWarnings.toInteger()
source sourceSets.main.output.resourcesDir
}
checkstyleTest {
maxWarnings = checkstyleTestMaxWarnings.toInteger()
source sourceSets.test.output.resourcesDir
}
jacocoTestReport {
reports {
xml.enabled true
html.enabled true
}
}
afterEvaluate {
def junitPlatformTest = tasks.junitPlatformTest
jacoco {
applyTo(junitPlatformTest)
}
task jacocoJunit5TestReport(type: JacocoReport) {
executionData junitPlatformTest
sourceSets sourceSets.main
sourceDirectories = files(sourceSets.main.allSource.srcDirs)
classDirectories = files(sourceSets.main.output)
reports {
xml.enabled true
html.enabled true
}
}
}