-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
248 lines (215 loc) · 5.33 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
import groovy.swing.SwingBuilder
plugins
{
id "java"
id "com.github.hierynomus.license" version "0.14.0"
}
repositories
{
jcenter()
}
dependencies
{
compile "org.slf4j:slf4j-api:1.7.25"
compile "ch.qos.logback:logback-classic:1.2.3"
compile "commons-io:commons-io:2.6"
compile "net.sf.trove4j:trove4j:3.0.3"
compile "net.dv8tion:JDA:3.5.0_327"
testCompile "org.mockito:mockito-core:2.10.0"
testCompile "junit:junit:4.12"
}
sourceSets
{
main
{
java
{
srcDirs "src.java"
}
resources
{
srcDirs "res"
}
}
config
{
resources
{
srcDirs "config"
}
}
test
{
java
{
srcDirs "test.java"
}
resources
{
srcDirs "config.test"
}
}
}
ext
{
binaryName=project.name.replace("bot", "")
installationDir=new File(buildDir, "installation")
binDir=new File(installationDir, "bin")
configDir=new File(installationDir, "config")
libDir=new File(installationDir, "lib")
distributablesDir=new File(buildDir, "distributables")
licensePath=new File(projectDir, "LICENSE.txt")
dependencyLicenseReportPath=new File(buildDir, "reports/license/dependency-license.html")
}
task makeDistributable (type: Zip)
task makeInstallation
task signJar
task requestSignature
task setManifestClasspath
task installDependencies (type: Copy)
task installConfigurationFiles (type: Copy)
task installLicense (type: Copy)
task installDependencyLicenses (type: Copy)
licenseConfig.enabled=false
licenseMain.enabled=false
licenseTest.enabled=false
build
{
dependsOn makeDistributable
}
makeDistributable
{
dependsOn signJar
dependsOn makeInstallation
from installationDir
destinationDir distributablesDir
baseName binaryName
}
makeInstallation
{
dependsOn jar
dependsOn installDependencies
dependsOn installConfigurationFiles
dependsOn installLicense
dependsOn installDependencyLicenses
}
signJar
{
dependsOn jar
dependsOn requestSignature
ext
{
// these properties need to exist for the requestSignature task to work properly; values will be overwritten
keystore=""
storepass=""
alias=""
keypass=""
}
doLast
{
ant.signjar(jar: jar.archivePath, keystore: keystore, storepass: storepass, alias: alias, keypass: keypass)
}
}
jar
{
dependsOn setManifestClasspath
destinationDir binDir
baseName binaryName
manifest
{
attributes "Date-Built": new Date().format("MMMM d, yyyy")
attributes "Main-Class": "codes.soloware.derpybot.Derpy"
attributes "Version": "git describe --tags --always HEAD".execute().text.trim()
}
}
requestSignature
{
gradle.taskGraph.whenReady
{
taskGraph -> if (taskGraph.hasTask(":requestSignature"))
{
new SwingBuilder().edt
{
dialog(modal: true, title: "Enter Jar Signature", alwaysOnTop: true, resizable: true, locationRelativeTo: null, pack: true, show: true)
{
vbox
{
label("Path to keystore file: ")
textField id: "keystore"
label("Keystore password: ")
textField id: "storepass", input=passwordField()
label("Alias of the key to sign with:")
textField id: "alias"
label("Key password:")
textField id: "keypass", input=passwordField()
button(defaultButton: true, text: "OK", actionPerformed:
{
signJar.keystore=keystore.text
signJar.storepass=storepass.text
signJar.alias=alias.text
signJar.keypass=keypass.text
dispose()
})
}
}
}
}
}
}
setManifestClasspath
{
dependsOn installDependencies
dependsOn installConfigurationFiles
doLast
{
if (!jar.destinationDir.exists())
jar.destinationDir.mkdir()
ant.manifestclasspath(property: "manifestclasspath", jarfile: jar.archivePath)
{
classpath
{
fileset(dir: libDir, includes: "*.jar")
pathelement(path: configDir)
}
}
jar.manifest.attributes "Class-Path": ant.manifestclasspath
}
}
installDependencies
{
into libDir
configurations.compile.collect
{
from it
}
}
installConfigurationFiles
{
from sourceSets.config.resources.srcDirs
into configDir
}
installLicense
{
from licensePath
into installationDir
}
installDependencyLicenses
{
from dependencyLicenseReportPath
into libDir
rename
{
"licenses.html"
}
project.afterEvaluate
{
dependsOn project.tasks.getByName("downloadLicenses")
}
}
downloadLicenses
{
reportByDependency true
includeProjectDependencies true
dependencyConfiguration "compile"
licenses "net.dv8tion:JDA:3.5.0_327": license("Apache License, Version 2.0", "https://www.apache.org/licenses/LICENSE-2.0.txt")
}