-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.gradle
366 lines (341 loc) · 9.24 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
/*
* This gradle configuration compiles and packages YouScope.
*/
// Gradle plugins
plugins {
id 'application'
id 'eclipse'
id 'edu.sc.seis.launch4j' version '2.4.6'
id "com.github.langmo.gradlensis" version "0.1.0"
}
application {
executableDir = ''
mainClassName = 'org.youscope.starter.Starter'
applicationDefaultJvmArgs = ['-Djava.library.path=drivers64', '-Dpython.console.encoding=UTF-8']
}
allprojects {
tasks.withType(JavaExec) {
workingDir = new File("distribution")
}
}
// Empty task to prevent unnecessary copying of libs by launch4j
task emptyTask{
}
// Configuration to create the exe files for YouScope
// See https://github.com/TheBoegl/gradle-launch4j for details
launch4j {
dontWrapJar = true
headerType = 'gui'
jar = "lib/youscope.jar"
errTitle = 'YouScope'
copyConfigurable = rootProject.tasks.emptyTask.outputs.files
cmdLine = ""
chdir = '.'
priority = 'normal'
downloadUrl = "http://java.com/download"
supportUrl = 'http://www.youscope.org'
stayAlive = false
restartOnCrash = false
manifest = ""
icon = "${rootProject.projectDir}/resources/windows/YouScope.ico"
classpath = ['lib/youscope.jar']
mainClassName = "org.youscope.starter.Starter"
bundledJre64Bit = false
bundledJreAsFallback = false
jreMinVersion = "1.7.0"
initialHeapSize = 256
initialHeapPercent = 10
maxHeapSize = 1024
maxHeapPercent = 50
splashFileName = "${rootProject.projectDir}/resources/windows/splash.bmp"
splashWaitForWindows = true
splashTimeout = 60
splashTimeoutError = true
fileDescription = 'YouScope - Microscope Control Environment'
copyright = 'Moritz Lang, [email protected]'
productName = "YouScope - Microscope Control Environment"
companyName = "YouScope.org"
internalName = "YouScope"
language = "ENGLISH_US"
}
// 64 bit version of exe
createExe {
outfile = 'YouScope64.exe'
jreRuntimeBits = "64"
jvmOptions = ["-Dpython.console.encoding=UTF-8", "-Djava.library.path=drivers64"]
variables = ['PATH=%EXEDIR%\\drivers64;%PATH%']
}
// 32 bit version of exe
task createExe32(type: edu.sc.seis.launch4j.tasks.Launch4jLibraryTask) {
outfile = 'YouScope32.exe'
jreRuntimeBits = "32"
jvmOptions = ["-Dpython.console.encoding=UTF-8", "-Djava.library.path=drivers32"]
variables = ['PATH=%EXEDIR%\\drivers32;%PATH%']
}
// Delete annoying start scripts. We are using exe's instead!
startScripts {
doLast {
delete windowsScript
delete unixScript
}
}
// global variables
ext.archivesBaseName = "youscope"
ext.version = '2.1.0'
// Basic subprojects of youscope
project(':core')
{
subprojects {
apply plugin: 'java'
group = 'org.youscope'
version = rootProject.version
repositories {
flatDir {
dirs '../../libs'
}
}
jar.archiveName = "${rootProject.archivesBaseName}-${project.name}.${jar.extension}"
jar.doFirst{
manifest{
def manif = "${projectDir}/src/main/resources/META-INF/MANIFEST.MF"
if (new File(manif).exists()) {
from file(manif)
}
else
{
attributes(
'Class-Path' : configurations.compile.collect { it.getName() }.join(' ')
)
}
attributes(
'Build-Timestamp': new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date()),
'Build-Version' : rootProject.ext.version,
'Created-By' : "Gradle ${gradle.gradleVersion}",
'Build-Jdk' : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
'Build-OS' : "${System.properties['os.name']} ${System.properties['os.arch']} ${System.properties['os.version']}"
)
}
}
}
}
// root project
jar.doFirst{
manifest{
def manif = "${projectDir}/src/main/resources/META-INF/MANIFEST.MF"
if (new File(manif).exists()) {
from file(manif)
}
else
{
attributes(
'Class-Path' : configurations.compile.collect { it.getName() }.join(' ')
)
}
attributes(
'Build-Timestamp': new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date()),
'Build-Version' : rootProject.ext.version,
'Created-By' : "Gradle ${gradle.gradleVersion}",
'Build-Jdk' : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
'Build-OS' : "${System.properties['os.name']} ${System.properties['os.arch']} ${System.properties['os.version']}"
)
}
}
project(':core:api')
{
dependencies {
implementation name: 'xstream-1.4.2'
}
}
project(':core:server')
{
dependencies {
implementation project(':core:api')
implementation name: 'xstream-1.4.2'
}
}
project(':core:client')
{
dependencies {
implementation project(':core:api')
implementation name: 'xstream-1.4.2'
implementation name: 'jcommon-1.0.17'
implementation name: 'jfreechart-1.0.14'
implementation name: 'zxing-core-1.7'
implementation name: 'zxing-j2se-1.7'
runtimeOnly name: 'fugue-icons-2.6.4'
}
}
// Plugin subprojects of youscope
project(':plugins')
{
subprojects {
apply plugin: 'java'
group = 'org.youscope'
version = rootProject.version
repositories {
flatDir {
dirs '../../libs'
}
}
jar.archiveName = "${rootProject.archivesBaseName}-${project.name}.${jar.extension}"
dependencies {
implementation project(':core:api')
implementation name: 'xstream-1.4.2'
}
jar.doFirst{
manifest{
def manif = "${projectDir}/src/main/resources/META-INF/MANIFEST.MF"
if (new File(manif).exists()) {
from file(manif)
}
else
{
attributes(
'Class-Path' : '../lib/youscope-common.jar ../lib/youscope-addon.jar ../lib/xstream-1.4.2.jar'
)
}
attributes(
'Build-Timestamp': new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date()),
'Build-Version' : rootProject.ext.version,
'Created-By' : "Gradle ${gradle.gradleVersion}",
'Build-Jdk' : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
'Build-OS' : "${System.properties['os.name']} ${System.properties['os.arch']} ${System.properties['os.version']}"
)
}
}
}
}
allprojects {
tasks.withType(JavaCompile) {
sourceCompatibility = '1.7'
targetCompatibility = '1.7'
}
}
dependencies {
repositories {
flatDir {
dirs 'libs'
}
}
runtimeOnly project(':core:server')
runtimeOnly project(':core:client')
project(':plugins')
{
subprojects {
runtimeOnly project(':plugins:' + project.name)
}
}
}
///////////////////////////////////
// Define distribution structure
///////////////////////////////////
task externalLibs {
def libs = file("${rootProject.projectDir}/libs")
outputs.dir libs
}
task addMSVC {
def msvc = file("${rootProject.projectDir}/msvc")
outputs.dir msvc
}
// Package distribution
distributions {
nsis {
distributionBaseName = 'nsis'
// copy everything which is in the /distribution folder.
contents {
from 'distribution'
}
contents {
from(addMSVC)
{
into 'msvc'
}
}
contents {
from(createExe)
{
into ''
}
from(createExe32)
{
into ''
}
from(externalLibs) {
into 'lib'
}
project(':') {
from(jar) {
into 'lib'
}
}
project(':core:api') {
from(jar) {
into 'lib'
}
}
project(':core:client') {
from(jar) {
into 'lib'
}
}
project(':core:server') {
from(jar) {
into 'lib'
}
}
project(':plugins') {
subprojects {
from(jar) {
into 'plugins'
}
}
}
}
}
}
// work around for bugs in installNsisDist on github
installNsisDist {
def installDir = file("${rootProject.buildDir}/install/nsis")
def msvcDir = new File(installDir, "msvc")
def libDir = new File(installDir, "lib")
def binDir = new File(installDir, "bin")
// make the wrongly required directories before they are checked for
doFirst {
mkdir installDir
mkdir msvcDir
mkdir libDir
mkdir binDir
}
// remove them after the check
doLast {
println "Installing distribution to $installDir."
binDir.deleteDir()
}
}
nsis {
configuration = file("${rootProject.projectDir}/resources/nsis/YouScope.nsi")
runIn = file("${rootProject.buildDir}/install/nsis/")
additionalPlugins = ['AccessControl']
variables = ['WIN64':'True']
}
task createInstaller32(type: com.github.langmo.gradlensis.GradleNsisTask) {
variables = ['WIN32':'True']
}
task createInstaller3264(type: com.github.langmo.gradlensis.GradleNsisTask) {
variables = ['WIN32':'True', 'WIN64':'True']
}
createInstaller.dependsOn installNsisDist
createInstaller32.dependsOn installNsisDist
createInstaller3264.dependsOn installNsisDist
task createInstallers {
dependsOn ":createInstaller32"
dependsOn ":createInstaller"
dependsOn ":createInstaller3264"
}
def NSIS_GROUP = 'nsis'
createInstaller32.group = createInstaller.group
createInstaller32.description = createInstaller.description
createInstaller3264.group = createInstaller.group
createInstaller3264.description = createInstaller.description
createInstallers.group = createInstaller.group
createInstallers.description = "Creates both the 32bit, the 64bit, and the compined 32/64bit installers"