-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathbuild.gradle
270 lines (228 loc) · 9.63 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
/*
* 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.13.0"
}
repositories {
jcenter()
mavenCentral()
}
}
// Access Git info from build script
plugins {
id "org.ajoberstar.grgit" version "3.0.0"
}
// 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'
// Definitions
defaultTasks 'clean', 'build'
sourceCompatibility = 10
targetCompatibility = 10
// Don't fail build if tests fail until tests are cleaned up
test.ignoreFailures = true
// Used by gradle assemble & run tasks
mainClassName = 'net.rptools.tokentool.client.TokenTool'
// Custom properties
ext {
def repo = org.ajoberstar.grgit.Grgit.open(currentDir: file('.'))
def head = repo.head()
def tags = repo.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
}
// vendor, tagVersion, msiVersion, and DSN's defaults are set in gradle.properties
println 'Configuring for ' + project.name + " " + tagVersion + " by " + vendor
}
// Default parameters for gradle run command
run {
args = [ '-v='+tagVersion, '-vendor='+vendor ]
applicationDefaultJvmArgs = [ "-Dsentry.environment=Development", "-Dfile.encoding=UTF-8" ]
if(System.getProperty("exec.args") != null) {
args System.getProperty("exec.args").split()
}
}
spotless {
java {
licenseHeaderFile 'spotless.license.java'
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)
}
}
// Set eclipse natures, access rules, and other settings
// https://docs.gradle.org/current/dsl/org.gradle.plugins.ide.eclipse.model.EclipseProject.html
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 {
def jre = entries.find { it.path.contains 'org.eclipse.jdt.launching.JRE_CONTAINER' }
jre.accessRules.add(new AccessRule('0', 'javafx/**'))
}
}
}
}
// In this section you declare where to find the dependencies of your project
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
// In this section you declare the dependencies for your production and test code
dependencies {
// For Sentry bug reporting
annotationProcessor group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.0'
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.11.0'
implementation group: 'org.apache.logging.log4j', name: 'log4j-1.2-api', version: '2.11.0' // Bridges v1 to v2 for other code in other libs
implementation group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'
implementation group: 'commons-logging', name: 'commons-logging', version: '1.2'
implementation group: 'io.sentry', name: 'sentry', version: '1.7.5'
implementation group: 'io.sentry', name: 'sentry-log4j2', version: '1.7.5'
// For PDF image extraction
implementation 'org.apache.pdfbox:pdfbox:2.0.10'
implementation 'org.bouncycastle:bcmail-jdk15on:1.59' // 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.3.2' // https://mvnrepository.com/artifact/com.twelvemonkeys.imageio/imageio-core
implementation group: 'com.twelvemonkeys.imageio', name: 'imageio-jpeg', version: '3.3.2' // https://mvnrepository.com/artifact/com.twelvemonkeys.imageio/imageio-core
implementation group: 'com.twelvemonkeys.imageio', name: 'imageio-psd', version: '3.3.2' // https://mvnrepository.com/artifact/com.twelvemonkeys.imageio/imageio-psd
// Other public libs
implementation group: 'commons-io', name: 'commons-io', version: '2.6' // https://mvnrepository.com/artifact/commons-io/commons-io
implementation group: 'commons-cli', name: 'commons-cli', version: '1.4' // https://mvnrepository.com/artifact/commons-cli/commons-cli
implementation group: 'org.reflections', name: 'reflections', version: '0.9.10' // https://mvnrepository.com/artifact/commons-cli/commons-cli
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5' // https://mvnrepository.com/artifact/com.google.code.gson/gson
}
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'
}
// Currently includes license files
task copyPackageExtras(type: Copy) {
from('package/license/')
into('build/libs/')
include('*')
}
task prepareInnoSetup(type: Copy) {
from("build-resources/TokenTool.iss.template")
into("package/windows/")
rename("TokenTool.iss.template", "TokenTool.iss")
def tokens = [
AppName: "${project.name}",
AppVersion: "${tagVersion}",
Vendor: "${vendor}",
SetupIcon: "${project.projectDir.absolutePath}/package/windows/${project.name}.ico",
WizardImage: "${project.projectDir.absolutePath}/package/windows/${project.name}-setup.bmp",
Slash: "\\",
]
expand(tokens)
inputs.properties(tokens)
}
task deploy(dependsOn: [uberJar, copyPackageExtras, prepareInnoSetup]) {
group = 'distribution'
description = 'Create native installers'
tasks.findByName('copyPackageExtras').mustRunAfter 'uberJar'
doLast {
println 'Deploying ' + project.name + " " + tagVersion + " by " + vendor
// 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}"
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=.",
"-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=Graphics",
}
}
}
task createWrapper(type: Wrapper) {
gradleVersion = '5.2.1'
}
// Configure current release tag in Sentry.io properties
processResources.dependsOn configSentryRelease