forked from RPTools/maptool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
414 lines (343 loc) · 16.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
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
/*
* For more details take a look at the Java Quickstart chapter in the Gradle
* user guide available at https://docs.gradle.org/4.1/userguide/tutorial_java_projects.html
*/
import org.gradle.plugins.ide.eclipse.model.AccessRule
buildscript {
dependencies {
classpath "com.diffplug.spotless:spotless-plugin-gradle:3.27.1"
}
repositories {
mavenCentral()
}
}
// Access Git info from build script
plugins {
id "org.ajoberstar.grgit" version "4.0.1"
}
// Apply the java plugin to add support for Java
apply plugin: 'base'
apply plugin: 'application'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'com.diffplug.gradle.spotless'
apply plugin: 'jacoco'
// Definitions
defaultTasks 'clean', 'build'
sourceCompatibility = 10
targetCompatibility = 10
// Used by gradle assemble & run tasks
mainClassName = 'net.rptools.maptool.client.LaunchInstructions'
applicationDefaultJvmArgs = ["-Xss8M"]
// Custom properties
ext {
// Get tag and commit info from Git to use for version numbering
def grgit = org.ajoberstar.grgit.Grgit.open(currentDir: file('.'))
def head = grgit.head()
def tags = grgit.tag.list().find {
it.commit == head
}
revision = head.abbreviatedId
revisionFull = head.id
if (tags) {
tagVersion = tags.getName()
msiVersion = tagVersion
enviroment = "Production"
sentryDSN = sentry_production_dsn
} else {
tagVersion = 'SNAPSHOT-' + revision
enviroment = "Development"
sentryDSN = sentry_development_dsn
}
// not doing anything as of a bug in grgit when opening with currentDir/dir
// https://github.com/ajoberstar/grgit/issues/288
grgit.close()
// therefore close the underlying repository manually
grgit.repository.jgit.getRepository().close()
// vendor, tagVersion, msiVersion, and DSN's defaults are set in gradle.properties
println 'Configuring for ' + project.name + " " + tagVersion + " by " + vendor
}
run {
args = [ '-v='+version ]
applicationDefaultJvmArgs = [ "-Xss8M", "-Djava.library.path=lib", "-Dsentry.environment=Development", "-Dfile.encoding=UTF-8", "-DMAPTOOL_DATADIR=.maptool-" + vendor ] // Add -Dlog4j2.debug to see log4j2 details
if(System.getProperty("exec.args") != null) {
args System.getProperty("exec.args").split()
}
}
spotless {
java {
target project.fileTree(project.rootDir) {
include 'src/**/*.java'
exclude '**/JTextAreaAppender.java'
}
licenseHeaderFile 'spotless.license.java'
// Now using the Google Java style guide
googleJavaFormat()
}
format 'misc', {
target '**/*.gradle', '**/.gitignore'
// spotless has built-in rules for most basic formatting tasks
trimTrailingWhitespace()
// or spaces. Takes an integer argument if you don't like 4
indentWithSpaces(4)
}
}
jacoco {
toolVersion = "0.8.1"
reportsDir = file("$buildDir/reports/jacoco")
}
// Set eclipse natures, access rules, and other settings
// https://docs.gradle.org/current/dsl/org.gradle.plugins.ide.eclipse.model.EclipseProject.html
// https://discuss.gradle.org/t/buildship-1-0-18-is-now-available/19012
eclipse {
project {
natures 'org.eclipse.buildship.core.gradleprojectnature'
buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
}
classpath {
file {
withXml {
def node = it.asNode()
node.appendNode('classpathentry', [kind: 'con', path: 'org.eclipse.fx.ide.jdt.core.JAVAFX_CONTAINER'])
}
whenMerged {
entries.each { source ->
if (source.kind == 'con' && source.path.startsWith('org.eclipse.jdt.launching.JRE_CONTAINER')) {
source.accessRules.add(new AccessRule('0', 'javafx/**'))
source.accessRules.add(new AccessRule('0', 'jdk/nashorn/api/**'))
}
}
}
}
}
}
// In this section you declare where to find the dependencies of your project
repositories {
// Use 'jcenter' for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
mavenLocal()
mavenCentral()
jcenter()
maven { url = 'http://maptool.craigs-stuff.net/repo/' }
maven { url = 'http://www.nerps.net/repo/' }
maven { url = 'https://jitpack.io' }
}
// In this section you declare the dependencies for your production and test code
dependencies {
// Jamz: Do NOT update log4j libs without testing with uberjar build, 2.13.0 currently does not work
// See open issue: https://issues.apache.org/jira/browse/LOG4J2-673
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.12.1'
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.12.1'
implementation group: 'org.apache.logging.log4j', name: 'log4j-1.2-api', version: '2.12.1' // Bridges v1 to v2 for other code in other libs
implementation group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.30'
implementation group: 'commons-logging', name: 'commons-logging', version: '1.2'
// For Sentry bug reporting
implementation group: 'io.sentry', name: 'sentry', version: '1.7.29'
implementation group: 'io.sentry', name: 'sentry-log4j2', version: '1.7.29'
implementation group: 'org.apache.commons', name: 'commons-collections4', version: '4.4' // https://mvnrepository.com/artifact/org.apache.commons/commons-collections4
implementation 'net.java.abeille:abeille-formsrt:2.0'
// sourceControl gitRepository currently not producing classpath for Eclipse
// using jitpack.io for now
// implementation 'net.rptools.clientserver:clientserver:1.4.0.+'
implementation 'com.github.RPTools:clientserver:1.4.0.0'
implementation 'org.hibernate:antlr:2.7.5H3'
implementation 'commons-beanutils:commons-beanutils:1.9.4'
implementation 'commons-io:commons-io:2.6'
implementation 'commons-jxpath:commons-jxpath:1.3'
implementation 'commons-lang:commons-lang:2.6'
implementation 'commons-net:commons-net:3.6'
implementation 'commons-cli:commons-cli:1.4'
implementation 'net.rptools.decktool:decktool:1.0.b1'
implementation 'com.github.RPTools:maptool-resources:1.6.0'
implementation 'com.github.RPTools:parser:1.5.5'
implementation 'jide-common:jide-common:3.2.3'
implementation 'jide-components:jide-components:3.2.3'
implementation 'jide-dialogs:jide-dialogs:3.2.3'
implementation 'jide-dock:jide-dock:3.2.3'
implementation 'jide-editor:jide-editor:3.2.3'
implementation 'jide-grids:jide-grids:3.2.3'
implementation 'jide-properties:jide-properties:3.2.3'
implementation 'jide-shortcut:jide-shortcut:3.2.3'
implementation 'org.eclipse.jetty:jetty-server:9.4.25.v20191220'
implementation 'org.eclipse.jetty:jetty-servlet:9.4.25.v20191220'
implementation 'org.eclipse.jetty:jetty-webapp:9.4.25.v20191220'
implementation 'org.eclipse.jetty:jetty-continuation:9.4.25.v20191220'
implementation 'org.eclipse.jetty.websocket:websocket-server:9.4.25.v20191220'
implementation 'org.eclipse.jetty.websocket:websocket-client:9.4.25.v20191220'
implementation 'org.eclipse.jetty.websocket:websocket-servlet:9.4.25.v20191220'
implementation 'org.eclipse.jetty.websocket:websocket-api:9.4.25.v20191220'
implementation 'net.sf.ezmorph:ezmorph:1.0.6'
implementation 'net.sf.json-lib:json-lib:2.4:jdk15'
implementation 'org.reflections:reflections:0.9.11'
implementation 'com.caucho.hessian:hessian:3.1.6'
implementation 'org.mozilla:rhino:1.7.12'
implementation 'ca.odell.renderpack:renderpack:1.2004'
implementation 'net.tsc.servicediscovery:servicediscovery:1.0.b5'
implementation 'org.swinglabs:swing-worker:1.2'
implementation 'net.sbbi.upnp:upnplib:1.0.9-nodebug'
implementation 'com.withay:withay-util:1.0'
implementation 'xmlpull:xmlpull:1.1.3.1'
implementation 'xpp3:xpp3_min:1.1.4c'
implementation 'com.thoughtworks.xstream:xstream:1.4.11.1'
implementation 'yasb:yasb:0.2-21012007'
implementation 'de.muntjak.tinylookandfeel:tinylaf-nocp:1.4.0'
implementation 'com.jayway.jsonpath:json-path:2.4.0'
// For PDF image extraction
implementation 'org.apache.pdfbox:pdfbox:2.0.18'
implementation 'org.bouncycastle:bcmail-jdk15on:1.64' // To decrypt passworded/secured pdf's
implementation 'com.github.jai-imageio:jai-imageio-core:1.4.0' // For pdf image extraction, specifically for jpeg2000 (jpx) support.
implementation 'com.github.jai-imageio:jai-imageio-jpeg2000:1.3.0' // For pdf image extraction, specifically for jpeg2000 (jpx) support.
// Image processing lib
implementation group: 'com.twelvemonkeys.imageio', name: 'imageio-core', version: '3.4.3' // https://mvnrepository.com/artifact/com.twelvemonkeys.imageio/imageio-core
implementation group: 'com.twelvemonkeys.imageio', name: 'imageio-jpeg', version: '3.4.3' // https://mvnrepository.com/artifact/com.twelvemonkeys.imageio/imageio-core
implementation group: 'com.twelvemonkeys.imageio', name: 'imageio-psd', version: '3.4.3' // https://mvnrepository.com/artifact/com.twelvemonkeys.imageio/imageio-psd
// For syntax highlighting in macro editor
implementation group: 'com.fifesoft', name: 'rsyntaxtextarea', version: '3.0.8' // https://mvnrepository.com/artifact/com.fifesoft/rsyntaxtextarea
implementation group: 'com.fifesoft', name: 'rstaui', version: '3.0.3' // https://mvnrepository.com/artifact/com.fifesoft/rstaui
implementation group: 'com.fifesoft', name: 'autocomplete', version: '3.0.5' // https://mvnrepository.com/artifact/com.fifesoft/autocomplete
// For simple xml work in Hero Lab integration
implementation group: 'com.jcabi', name: 'jcabi-xml', version: '0.22.1' // https://mvnrepository.com/artifact/com.jcabi/jcabi-xml
// For some math functions used in the A* Pathfinding
// https://locationtech.github.io/jts/jts-features.html
implementation group: 'org.locationtech.jts', name: 'jts-core', version: '1.16.1' // https://mvnrepository.com/artifact/org.locationtech.jts/jts-core
// For RESTful functions
implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.3.0'
// Better JSON functions...
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6' // https://mvnrepository.com/artifact/com.google.code.gson/gson
// Declare the dependency for your favourite test framework you want to use in your tests.
// TestNG is also supported by the Gradle Test task. Just change the
// testimplementation dependency to testimplementation 'org.testng:testng:6.8.1' and add
// 'test.useTestNG()' to your build script.
//testCompile 'junit:junit:4.12'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.5.2'
// For mocking features during unit tests
testImplementation group: 'org.mockito', name: 'mockito-core', version: '3.2.4'
// sourceControl gitRepository currently not producing classpath for Eclipse
// using jitpack.io for now
// compile ('net.rptools.dicelib:dicelib:1.5.2')
implementation 'com.github.RPTools:dicelib:1.5.5'
// Noise Generator
implementation 'com.github.cwisniew:NoiseLib:1.0.0-rc3' // The most recent version, 1.0.0 is build for a later java version: major version 55 is newer than 54, the highest major version supported by this compiler
}
task configSentryRelease(type: Copy) {
from("build-resources/sentry.properties.template")
into("src/main/resources/")
rename("sentry.properties.template", "sentry.properties")
def tokens = [
AppVersion: "${tagVersion}",
Environment: "${enviroment}",
SentryDSN: "${sentryDSN}"
]
expand(tokens)
inputs.properties(tokens)
}
task uberJar(type: Jar) {
group = 'distribution'
description = 'Create uber jar for native installers'
baseName project.name + '-' + tagVersion
manifest {
attributes 'Implementation-Title': project.name,
'Implementation-Version': tagVersion,
'Implementation-Vendor': vendor,
'Git-Commit': revision,
'Git-Commit-SHA': revisionFull,
'Built-By': System.getProperty('user.name'),
'Built-Date': new Date(),
'Built-JDK': System.getProperty('java.version'),
'Source-Compatibility': project.sourceCompatibility,
'Target-Compatibility': project.targetCompatibility,
'Main-Class': project.mainClassName
}
from {
configurations.runtimeClasspath.collect {
it.isDirectory() ? it : zipTree(it)
}
}
with jar
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA' // Jamz: This is needed to prevent org.bouncycastle:bcmail resigning and security errors
exclude 'module-info.class' //This is to make sure maptool doesn't become a module by including module-info of dependencies. Probably needs to be fixed before we go to jdk 11+
}
// For logging Git Commit during CI
task displayGitInfo {
doLast {
println 'Git-Commit-SHA: ' + revisionFull
}
}
// Currently includes license files
task copyPackageExtras(type: Copy) {
from('package/license/')
into('build/libs/')
include('*')
}
task prepareInnoSetup(type: Copy) {
from("package/windows/MapTool.iss.template")
into("package/windows/")
rename("MapTool.iss.template", "MapTool.iss")
def tokens = [
AppName: "${project.name}",
AppVersion: "${tagVersion}",
Vendor: "${vendor}",
WizardImage: "${project.projectDir.absolutePath}/package/windows/${project.name}-setup.bmp",
Slash: "\\",
]
expand(tokens)
inputs.properties(tokens)
}
task deploy(dependsOn: [clean, displayGitInfo, uberJar, copyPackageExtras, prepareInnoSetup]) {
group = 'distribution'
description = 'Create native installers'
tasks.findByName('copyPackageExtras').mustRunAfter 'uberJar'
doLast {
// Using the -deploy Command with Bundler Arguments
// javapackager -deploy -native exe -BsystemWide=true -BjvmOptions=-Xmx128m -BjvmOptions=-Xms128m -outdir packages -outfile BrickBreaker -srcdir dist
// -srcfiles BrickBreaker.jar -appclass brickbreaker.Main -name BrickBreaker -title "BrickBreaker demo"
// *Note: You can specify a JRE using "-Bruntime=../../../deploy-ready-jre"
// It will bundle system/workspace JDK by default
def javapackager_deploy = exec {
workingDir "${project.projectDir.absolutePath}"
println workingDir
commandLine "javapackager",
"-deploy", "-v",
"-native", "installer",
"-appclass", mainClassName,
"-srcdir", "build/libs",
"-outdir", "releases/release-" + tagVersion,
"-outfile", project.name,
"-name", project.name,
"-description", project.name + " " + tagVersion + " by " + vendor,
"-title", project.name,
"-vendor", vendor,
"-BdropinResourcesRoot=.",
"-BAssociations=cmpgn",
"-BinstalldirChooser=true",
"-BsystemWide=false",
"-BmenuHint=true",
"-Bwin.menuGroup=" + vendor,
"-BshortcutHint=true",
"-BappVersion=" + tagVersion,
"-Bwin.msi.productVersion=" + msiVersion,
"-BlicenseFile=COPYING.AFFERO",
"-BlicenseType='GNU AFFERO GENERAL PUBLIC LICENSE'",
"-Bcategory=Games",
"-BuserJvmOptions=-DMAPTOOL_DATADIR\\==.maptool-" + vendor,
"-BuserJvmOptions=-Dfile.encoding\\==UTF-8",
"-BuserJvmOptions=-Xss=8M"
println commandLine
}
}
}
javadoc {
options.addStringOption('Xmaxwarns', '2000')
options.addBooleanOption('html5', true)
options.tags("note:a:<strong><u>Note:</u></strong>")
}
test {
useJUnitPlatform()
}
task createWrapper(type: Wrapper) {
gradleVersion = '5.3.1'
}
// Configure current release tag in Sentry.io properties
processResources.dependsOn configSentryRelease