-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
build.gradle
330 lines (293 loc) · 15.5 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
/*
* Copyright (c) 2019-2024. Clément Grennerat
* All rights reserved. You must refer to the licence Apache 2.
*/
plugins {
id 'application'
id 'idea'
id 'org.openjfx.javafxplugin' version '0.1.0'
id 'org.gradlex.extra-java-module-info' version '1.8'
id 'org.beryx.jlink' version '3.0.1'
}
repositories {
mavenCentral()
maven { url "https://clojars.org/repo" }
maven { url 'https://jitpack.io' }
flatDir { dirs 'locallibs' }
}
extraJavaModuleInfo {
failOnMissingModuleInfo.set(false)
automaticModule("jlatexmath-1.0.7.jar", "jlatexmath")
automaticModule("writer2latex.jar", "writertolatex")
automaticModule("jlatexmath-font-greek-1.0.7.jar", "jlatexmath.font.greek")
automaticModule("jlatexmath-font-cyrillic-1.0.7.jar", "jlatexmath.font.cyrillic")
automaticModule("xmpcore-6.0.6.jar", "xmpcore")
automaticModule("metadata-extractor-2.19.0.jar", "metadata.extractor")
automaticModule("jai-imageio-core-1.4.0.jar", "jai.imageio.core")
automaticModule("jai-imageio-jpeg2000-1.4.0.jar", "jai.imageio.jpeg2000")
automaticModule("batik-parser-1.17.jar", "batik.parser")
automaticModule("google-diff-match-patch-0.1.jar", "google.diff.match.patch")
automaticModule("unique4j-1.4.jar", "uniqueforj")
// Used by JThemeDetector
automaticModule("versioncompare-1.4.1.jar", "versioncompare")
}
dependencies {
implementation 'org.jetbrains:annotations:23.0.0'
// JMetro
implementation(group: 'org.jfxtras', name: 'jmetro', version: '11.6.16') {
exclude group: 'org.openjfx'
}
// ControlsFX
implementation group: 'org.controlsfx', name: 'controlsfx', version: '11.2.1'
// Support special images format when render a PDF
implementation group: 'com.github.jai-imageio', name: 'jai-imageio-core', version: '1.4.0'
implementation group: 'com.github.jai-imageio', name: 'jai-imageio-jpeg2000', version: '1.4.0'
implementation group: 'org.apache.pdfbox', name: 'jbig2-imageio', version: '3.0.4'
// Signing and encrypting pdf (not used)
//compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.53'
// Image IO - EXIF
implementation group: 'com.drewnoakes', name: 'metadata-extractor', version: '2.19.0'
// YAML & JSON & CSV
implementation group: 'org.yaml', name: 'snakeyaml', version: '2.2'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.17.1'
implementation group: 'com.opencsv', name: 'opencsv', version: '5.9'
// LaTeX
implementation 'org.scilab.forge:jlatexmath:1.0.7'
implementation(name: 'writer2latex', ext: 'jar')
// OSX
implementation ('de.jangassen:nsmenufx:3.1.0'){
exclude group: 'net.java.dev.jna'
}
// SVG
implementation group: 'org.apache.xmlgraphics', name: 'batik-parser', version: '1.17'
implementation group: 'de.rototor.pdfbox', name: 'graphics2d', version: '3.0.2'
// PDF Box
implementation group: 'org.apache.pdfbox', name: 'pdfbox', version: '3.0.2'
implementation group: 'commons-logging', name: 'commons-logging', version: '1.2'
// Text Google diff / match / patch
implementation group: 'google-diff-match-patch', name: 'google-diff-match-patch', version: '0.1'
// Unique4J
implementation 'tk.pratanumandal:unique4j:1.4'
// OS Theme detector
implementation ('com.github.Dansoftowner:jSystemThemeDetector:3.9.1'){
exclude group: 'net.java.dev.jna'
}
// Add transitive dependency JNA that must exist only under -jpms (for modular projects)
implementation 'net.java.dev.jna:jna:5.12.1'
implementation 'net.java.dev.jna:jna-platform:5.12.1'
implementation 'org.jetbrains:annotations:24.0.0'
}
def os = org.gradle.internal.os.OperatingSystem.current()
def aarch64 = System.getProperty("os.arch") == "aarch64"
version = "1.4.2"
description = "PDF students assessments editor"
//frenchDescription="Éditeur de copies PDF"
compileJava.options.encoding = "UTF-8"
compileTestJava.options.encoding = "UTF-8"
java {
modularity.inferModulePath.set(true)
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
javafx {
version = '22'
modules = ['javafx.controls', 'javafx.swing', 'javafx.fxml']
}
application {
mainModule.set('fr.clementgre.pdf4teachers')
mainClass.set('fr.clementgre.pdf4teachers.Main')
}
// Xlint check
/*gradle.projectsEvaluated {
tasks.withType(JavaCompile){
options.compilerArgs << "-Xlint:unchecked"
}
}*/
run {
jvmArgs = [
'--add-exports=javafx.graphics/com.sun.javafx.scene=org.controlsfx.controls', // For controlsFX NotificationPane
'--add-exports=javafx.graphics/com.sun.javafx.scene.traversal=org.controlsfx.controls', // For controlsFX NotificationPane
'--add-exports=javafx.base/com.sun.javafx.event=org.controlsfx.controls', // For controlsFX SearchComboBox
]
if(os.macOsX){
// The dock icon works only when app is in /Applications
jvmArgs += '-Xdock:icon=/Applications/PDF4Teachers.app/contents/Resources/logo.icns'
}else if(os.windows){
}
}
if(os.windows){
task autoPackage {
dependsOn('jpackage')
doLast {
exec {
workingDir './build'
commandLine 'cmd', '/C', "if exist .\\AutoPackage (rmdir /s /q AutoPackage) && mkdir AutoPackage &&" +
"copy .\\jpackage\\PDF4Teachers-" + version + ".msi .\\AutoPackage\\PDF4Teachers-Windows-" + version + ".msi &&" +
"cd jpackage && jar -cfM ..\\AutoPackage\\PDF4Teachers-Windows-" + version + ".zip .\\PDF4Teachers"
}
}
}
}else if(os.linux){
task autoPackage {
dependsOn('jpackage')
doLast {
exec {
workingDir './build'
commandLine 'bash', '-c', "rm -R ./AutoPackage ;" +
"mkdir -p ./AutoPackage/debian/DEBIAN ./AutoPackage/other/pdf4teachers ;" +
"dpkg-deb -x ./jpackage/pdf4teachers_" + version + "_amd64.deb ./AutoPackage/debian/ ;" +
"dpkg-deb -e ./jpackage/pdf4teachers_" + version + "_amd64.deb ./AutoPackage/debian/DEBIAN ;" +
"cp ../distribution/linux/PDF4Teachers.png ./AutoPackage/debian/opt/pdf4teachers/lib/PDF4Teachers.png ;" +
"cp ../distribution/linux/pdf4teachers.desktop ./AutoPackage/debian/opt/pdf4teachers/lib/pdf4teachers-PDF4Teachers.desktop ;" +
"dpkg-deb -Z xz -b ./AutoPackage/debian/ ./AutoPackage/PDF4Teachers-Linux-" + version + ".deb ;" +
"cp -R ./jpackage/PDF4Teachers/* ./AutoPackage/other/pdf4teachers/ ;" +
"cp ../distribution/linux/pdf4teachers.desktop ./AutoPackage/other/pdf4teachers ;" +
"cd AutoPackage/other ; tar cfz pdf4teachers.tar.gz pdf4teachers ;" +
"cp pdf4teachers.tar.gz ../PDF4Teachers-Linux-" + version + ".tar.gz"
}
}
}
}else if(os.macOsX){
task autoPackage {
dependsOn('jlink')
doLast {
exec {
workingDir './build'
commandLine 'bash', '-c', "rm -R ./AutoPackage ;" +
"mkdir -p ./AutoPackage/PDF4Teachers.app/contents/Resources/ ./AutoPackage/PDF4Teachers.app/contents/MacOS/ ;" +
"cp ../distribution/macosx/logo.icns ./AutoPackage/PDF4Teachers.app/contents/Resources/logo.icns ;" +
"cp -R ./image/PDF4Teachers-mac/* ./AutoPackage/PDF4Teachers.app/contents/MacOS/ ;" +
"sed 's/x.x.x/" + version + "/g' ../distribution/macosx/Info.plist > ./AutoPackage/PDF4Teachers.app/contents/Info.plist ;" +
"/Applications/DMG\\ Canvas.app/Contents/Resources/dmgcanvas ../distribution/macosx/PDF4Teachers.dmgcanvas " +
"./AutoPackage/PDF4Teachers-MacOSX-" + (aarch64 ? "AArch64-" : "") + version + ".dmg " +
"-setFilePath PDF4Teachers.app ./AutoPackage/PDF4Teachers.app"
}
}
}
}
jlink {
options = [
'--strip-debug',
'--no-header-files',
'--no-man-pages'
] as List<String>
launcher {
name = 'PDF4Teachers'
jvmArgs = [
'--add-exports=javafx.graphics/com.sun.javafx.scene=org.controlsfx.controls',
'--add-exports=javafx.graphics/com.sun.javafx.scene.traversal=org.controlsfx.controls',
'--add-exports=javafx.base/com.sun.javafx.event=org.controlsfx.controls',
'--add-reads=PDF4Teachers.merged.module=org.apache.commons.logging',
'--add-exports=org.apache.commons.logging/org.apache.commons.logging=PDF4Teachers.merged.module'
]
if(os.macOsX){
// The dock icon works only when app is in /Applications
jvmArgs += '-Xdock:icon=/Applications/PDF4Teachers.app/contents/Resources/logo.icns'
}else if(os.windows){
}
}
String jdkPath = project.findProperty('jdkPath')
String platform = os.windows ? 'win' : (os.macOsX ? 'mac' : 'lin')
if(jdkPath != null){ // Use ./gradlew jpackage -PjdkPath=xxx
project.logger.info("Using JDK passed in property: ".concat(jdkPath))
javaHome.set(jdkPath)
}else{
if (os.windows) javaHome.set('C:\\Program Files\\Eclipse Adoptium\\jdk-21.0.3.9-hotspot')
else if (os.macOsX && aarch64) javaHome.set('/Users/clement/Library/Java/JavaVirtualMachines/liberica-21.0.3')
else if (os.macOsX) javaHome.set('/Library/Java/JavaVirtualMachines/temurin-21.jdk/Contents/Home')
else if (os.linux) javaHome.set('/home/clement/.jdks/corretto-21.0.4')
project.logger.info("Using JDK: ".concat(javaHome.get()))
}
targetPlatform(platform, javaHome.get())
jpackage {
targetPlatformName = platform
installerType = os.windows ? 'msi' : (os.macOsX ? 'dmg' : 'deb')
installerOptions = [
'--description', project.description,
'--copyright', 'Copyrigth 2019-2022 Clément Grennerat',
'--app-version', project.version,
'--vendor', "Clément Grennerat",
'--type', installerType
] as List<String>
if (os.windows) { // WINDOWS
imageOptions += ['--icon', 'src/main/resources/logo.ico']
installerOptions += [
'--win-dir-chooser',
'--win-menu',
'--win-shortcut',
'--win-menu-group', '',
'--file-associations', 'distribution/windows/association-win.properties'
]
} else if (os.macOsX) { // MAC
imageOptions += ['--icon', 'src/main/resources/logo.icns']
installerOptions += [
"--mac-package-name", "PDF4Teachers"
]
} else if (os.linux) { // LINUX
imageOptions += ['--icon', 'src/main/resources/logo.png']
installerOptions += [
'--linux-menu-group', 'Education;Office',
'--linux-shortcut',
//'--file-associations', 'distribution/linux/association-lin.properties'
]
if (installerType == 'deb') installerOptions += ['--linux-deb-maintainer', '[email protected]']
else if (installerType == 'rpm') installerOptions += ['--linux-rpm-license-type', 'Apache-2.0']
}
}
mergedModule {
// requires 'org.apache.commons.logging';
// JBig2
uses "org.apache.pdfbox.jbig2.util.cache.CacheBridge"
requires 'java.logging'
requires 'jdk.xml.dom'
requires 'java.scripting'
requires 'java.sql'
requires 'java.xml'
requires 'java.desktop'
requires 'java.datatransfer'
uses 'javax.imageio.spi.ImageWriterSpi'
provides 'org.apache.xmlgraphics.image.loader.spi.ImageConverter' with 'org.apache.xmlgraphics.image.loader.impl.ImageConverterBitmap2G2D',
'org.apache.xmlgraphics.image.loader.impl.ImageConverterBuffered2Rendered',
'org.apache.xmlgraphics.image.loader.impl.ImageConverterG2D2Bitmap',
'org.apache.xmlgraphics.image.loader.impl.ImageConverterRendered2PNG'
provides 'javax.imageio.spi.ImageOutputStreamSpi' with 'com.github.jaiimageio.impl.stream.ChannelImageOutputStreamSpi'
provides 'org.apache.xmlgraphics.image.writer.ImageWriter' with 'org.apache.xmlgraphics.image.writer.imageio.ImageIOJPEGImageWriter',
'org.apache.xmlgraphics.image.writer.imageio.ImageIOPNGImageWriter',
'org.apache.xmlgraphics.image.writer.imageio.ImageIOTIFFImageWriter',
'org.apache.xmlgraphics.image.writer.internal.PNGImageWriter',
'org.apache.xmlgraphics.image.writer.internal.TIFFImageWriter'
provides 'org.apache.xmlgraphics.image.loader.spi.ImagePreloader' with 'org.apache.xmlgraphics.image.loader.impl.PreloaderBMP',
'org.apache.xmlgraphics.image.loader.impl.PreloaderEMF',
'org.apache.xmlgraphics.image.loader.impl.PreloaderEPS',
'org.apache.xmlgraphics.image.loader.impl.PreloaderGIF',
'org.apache.xmlgraphics.image.loader.impl.PreloaderJPEG',
'org.apache.xmlgraphics.image.loader.impl.PreloaderRawPNG',
'org.apache.xmlgraphics.image.loader.impl.PreloaderTIFF',
'org.apache.xmlgraphics.image.loader.impl.imageio.PreloaderImageIO'
provides 'javax.imageio.spi.ImageReaderSpi' with 'com.github.jaiimageio.impl.plugins.bmp.BMPImageReaderSpi',
'com.github.jaiimageio.impl.plugins.pcx.PCXImageReaderSpi',
'com.github.jaiimageio.impl.plugins.pnm.PNMImageReaderSpi',
'com.github.jaiimageio.impl.plugins.raw.RawImageReaderSpi',
'com.github.jaiimageio.impl.plugins.tiff.TIFFImageReaderSpi',
'com.github.jaiimageio.impl.plugins.wbmp.WBMPImageReaderSpi',
'com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi',
'org.apache.pdfbox.jbig2.JBIG2ImageReaderSpi'
provides 'org.apache.xmlgraphics.image.loader.spi.ImageLoaderFactory' with 'org.apache.xmlgraphics.image.loader.impl.ImageLoaderFactoryEPS',
'org.apache.xmlgraphics.image.loader.impl.ImageLoaderFactoryInternalTIFF',
'org.apache.xmlgraphics.image.loader.impl.ImageLoaderFactoryPNG',
'org.apache.xmlgraphics.image.loader.impl.ImageLoaderFactoryRaw',
'org.apache.xmlgraphics.image.loader.impl.ImageLoaderFactoryRawCCITTFax',
'org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO'
provides 'javax.imageio.spi.ImageInputStreamSpi' with 'com.github.jaiimageio.impl.stream.ChannelImageInputStreamSpi'
provides 'javax.xml.transform.URIResolver' with 'org.apache.xmlgraphics.util.uri.DataURIResolver'
provides 'javax.imageio.spi.ImageWriterSpi' with 'com.github.jaiimageio.impl.plugins.bmp.BMPImageWriterSpi',
'com.github.jaiimageio.impl.plugins.gif.GIFImageWriterSpi',
'com.github.jaiimageio.impl.plugins.pcx.PCXImageWriterSpi',
'com.github.jaiimageio.impl.plugins.pnm.PNMImageWriterSpi',
'com.github.jaiimageio.impl.plugins.raw.RawImageWriterSpi',
'com.github.jaiimageio.impl.plugins.tiff.TIFFImageWriterSpi',
'com.github.jaiimageio.impl.plugins.wbmp.WBMPImageWriterSpi',
'com.github.jaiimageio.jpeg2000.impl.J2KImageWriterSpi'
}
}