-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
240 lines (214 loc) · 8.44 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
import org.apache.tools.ant.taskdefs.condition.Os
import java.time.LocalDate
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.11'
id 'de.undercouch.download' version '4.0.0'
id 'idea'
}
group 'com.poterion.footprint'
version project.hasProperty('version') && project.version != "unspecified" ? project.version : '1.0-SNAPSHOT'
ext {
APP_NAME = "Footprint"
VENDOR = "Poterion"
EMAIL = "[email protected]"
if (Os.isFamily(Os.FAMILY_MAC)) {
IMAGE_NAME = "${APP_NAME}"
ARCHIVE = 'tar.gz'
JDK = 'zulu8.42.0.23-ca-fx-jdk8.0.232-macosx_x64'
JRE_SUFFIX = ""
CONTAINERS = ['image', 'dmg', 'pkg']
} else if (Os.isFamily(Os.FAMILY_UNIX)) {
IMAGE_NAME = "footprint"
ARCHIVE = 'tar.gz'
JDK = 'zulu8.42.0.23-ca-fx-jdk8.0.232-linux_x64'
JRE_SUFFIX = "/jre"
CONTAINERS = ['image', 'deb', 'rpm']
} else if (Os.isFamily(Os.FAMILY_WINDOWS)) {
IMAGE_NAME = "${APP_NAME}"
ARCHIVE = 'zip'
JDK = 'zulu8.42.0.23-ca-fx-jdk8.0.232-win_x64'
JRE_SUFFIX = ""
CONTAINERS = ['image', 'exe', 'msi']
} else throw new GradleException("Must run on Linux, MacOS or Windows")
JDKS_ROOT = project.hasProperty('jdks')
? project.jdks
: "${rootDir}/jdk"
JAVA_HOME = project.hasProperty('javahome')
? project.javahome
: new File("${JDKS_ROOT}/${JDK}").absolutePath
JRE_HOME = "${JAVA_HOME}${JRE_SUFFIX}"
JPACKAGER = project.hasProperty('javapackager')
? project.javapackager
: file("${JAVA_HOME}/bin/javapackager").absolutePath
println "JAVA_HOME=${JAVA_HOME}"
println "JPACKAGER=${JPACKAGER}"
}
task cleanOpenJDK(type: Delete, group: 'jdk') {
delete "${JDKS_ROOT}"
}
task downloadOpenJDK(type: Download, group: 'jdk') {
src "https://cdn.azul.com/zulu/bin/${JDK}.${ARCHIVE}"
dest file("${JDKS_ROOT}/${JDK}.${ARCHIVE}")
onlyIfNewer true
//overwrite false
}
task extractOpenJDK(type: Copy, group: 'jdk', dependsOn: downloadOpenJDK) {
if (!file(downloadOpenJDK.dest).exists()) {
if (ARCHIVE == 'zip') {
from zipTree(downloadOpenJDK.dest)
} else {
from tarTree(downloadOpenJDK.dest)
}
}
into "${JDKS_ROOT}"
}
allprojects {
compileJava {
options.fork = true
options.forkOptions.executable = "${JAVA_HOME}/bin/javac"
options.forkOptions.javaHome = file("${JAVA_HOME}")
}
}
tasks.assemble.dependsOn(extractOpenJDK)
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
task assembleFatJar(type: Jar, group: 'build', dependsOn: [assemble, extractOpenJDK]) {
manifest {
attributes 'Implementation-Title': APP_NAME,
'Implementation-Version': "${archiveVersion.get()}",
'Main-Class': 'com.poterion.footprint.manager.Main'
}
archiveBaseName.set(project.name + '-all')
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
task assembleSelfContained(group: 'build', dependsOn: assembleFatJar) {
doLast {
if (Os.isFamily(Os.FAMILY_MAC) // Fix Mac required directory structure
&& !project.hasProperty('javahome')
&& !file("${JAVA_HOME}/Contents/Home/jre").exists()) {
file("${JAVA_HOME}/Contents/Home").mkdirs()
exec {
commandLine "ln", "-s", "${JAVA_HOME}/jre", "${JAVA_HOME}/Contents/Home/jre"
}
}
logger.info("Building self contained images: ${CONTAINERS}")
logger.info("JAVA_HOME=${JAVA_HOME}")
logger.info("JPACKAGER=${JPACKAGER}")
logger.info("SRC=${file("${buildDir}/libs/footprint-all-${version}.jar").path}")
CONTAINERS.forEach { type ->
try {
logger.info("Packaging ${type} of ${APP_NAME} ${version.replace("-SNAPSHOT", "")}")
exec {
commandLine("${JPACKAGER}",
"-deploy",
"-Bruntime=${JRE_HOME}",
"-BappVersion=${version.replace("-SNAPSHOT", "")}",
"-Bicon=api/src/main/resources/com/poterion/footprint/manager/icons/application.icns",
"-Bcategory=Utility",
"-BlicenseFile=COPYING",
"-Bcopyright=2018-${LocalDate.now().year} ${VENDOR}",
"-Bemail=${EMAIL}",
//"-Barguments=--config-dir=.", // Store config inside the app directory
"-Bmac.category=Utility",
"-Bmac.CFBundleIdentifier=com.poterion.footprint.manager",
"-Bmac.CFBundleName=${APP_NAME}",
"-Bmac.CFBundleVersion=${version.replace("-SNAPSHOT", "")}",
"-native", type,
"-srcdir", ".",
"-srcfiles", "build/libs/footprint-all-${version}.jar",
"-srcfiles", "COPYING",
"-outdir", ".",
"-outfile", IMAGE_NAME,
"-appclass", "com.poterion.footprint.manager.Main",
"-name", IMAGE_NAME,
"-title", APP_NAME,
"-vendor", VENDOR,
"-nosign",
"-v")
standardOutput = new ByteArrayOutputStream()
ext.output = {
return standardOutput.toString()
}
}
println ext.output()
} catch (e) {
logger.error("${type}: ${e.message}\n\n ${ext.output()}", e)
}
}
}
}
task archiveSelfContainedLinuxImage(type: Tar, group: 'build') {
archiveBaseName = "${project.name}"
archiveVersion = "${project.version.replace("-SNAPSHOT", "")}"
archiveExtension = 'tar.gz'
into ("/${IMAGE_NAME}/"){
from "${rootDir}/bundles/${IMAGE_NAME.replace(' ', '')}"
}
destinationDir file("${rootDir}/bundles")
compression = Compression.GZIP
}
if (Os.isFamily(Os.FAMILY_UNIX) && !Os.isFamily(Os.FAMILY_MAC)) {
assembleSelfContained.finalizedBy archiveSelfContainedLinuxImage
}
clean {
delete 'bundles'
}
repositories {
mavenCentral()
jcenter()
google()
maven {
url 'https://www.dcm4che.org/maven2/'
}
}
dependencies {
//compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(":kotlin-utils")
compile project(":javafx-utils")
// Kotlin
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
//implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3"
// Persistence
compile 'com.h2database:h2:1.4.199'
compile 'org.hibernate:hibernate-core:5.4.10.Final'
compile 'org.flywaydb:flyway-core:6.0.3'
// Codecs/Metadata
compile 'com.drewnoakes:metadata-extractor:2.12.0'
compile 'org.rawdarkroom:jrawio:1.7-ALPHA-2'
compile 'org.rawdarkroom:codec:1.7-ALPHA-2'
compile 'org.rawdarkroom:processor:1.7-ALPHA-2'
//implementation 'it.tidalwave.imageio:jrawio-all:1.5.0'
compile 'xuggle:xuggle-xuggler:5.4'
compile 'net.coobird:thumbnailator:0.4.8'
// Drivers
compile 'net.samuelcampos:usbdrivedetector:2.1.1'
compile 'eu.agno3.jcifs:jcifs-ng:2.1.3' // FIXME JK: Due to this dependency fat-jar is not starting
//implementation 'de.picturesafe.file:smb-nio-ng:0.1.0-SNAPSHOT'
//implementation 'org.samba.jcifs:jcifs:1.3.3'
//implementation 'ch.pontius.nio:smb-nio:0.6-RELEASE'
//implementation 'com.hierynomus:smbj:0.9.1'
// ReactiveX
compile "io.reactivex.rxjava2:rxjava:2.1.6"
compile("io.reactivex.rxjava2:rxkotlin:2.3.0") {
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib'
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-common'
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-reflect'
}
// JavaFX
//implementation 'org.controlsfx:controlsfx:8.40.16'
// Commons
compile "commons-cli:commons-cli:1.4"
// Logger
api 'org.slf4j:slf4j-api:1.7.28'
compile 'org.slf4j:slf4j-log4j12:1.7.28'
}