-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpom.xml
More file actions
424 lines (400 loc) · 23.4 KB
/
pom.xml
File metadata and controls
424 lines (400 loc) · 23.4 KB
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
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
<?xml version="1.0" encoding="UTF-8"?>
<!--
╔══════════════════════════════════════════════════════════════════════════════╗
║ MUSEMIX BUILD CONFIGURATION ║
╠══════════════════════════════════════════════════════════════════════════════╣
║ This pom.xml contains a complex but working jpackage setup for a modular ║
║ JavaFX application that depends on libraries with automatic modules (JNA). ║
║ ║
║ THE PROBLEM: ║
║ * jpackage internally uses jlink to create a custom JVM runtime ║
║ * jlink ONLY works with proper named modules (has module-info.class) ║
║ * fxthemes library has `requires com.sun.jna` in its module-info ║
║ * JNA is an AUTOMATIC MODULE (no module-info) => jlink refuses it ║
║ * JavaFX Maven deps include empty "stub" JARs (no classifier) that are ║
║ also automatic modules, alongside platform-specific JARs (*-win.jar) ║
║ ║
║ THE SOLUTION (hybrid classpath + module-path approach): ║
║ 1. Put JavaFX platform JARs (*-win.jar) on module-path for jlink ║
║ 2. Put everything else (app, fxthemes, JNA, ikonli, etc.) on input ║
║ which becomes the classpath (ALL-UNNAMED module) ║
║ 3. Use add-modules to include JavaFX in the runtime image ║
║ 4. Use add-opens targeting ALL-UNNAMED (since fxthemes is on classpath) ║
║ ║
║ BUILD COMMANDS: ║
║ Development run: mvnw javafx:run ║
║ Create installer: mvnw clean package -Pexport ║
║ Native AOT (GraalVM): mvnw gluonfx:build ║
╚══════════════════════════════════════════════════════════════════════════════╝
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.uniqueapps</groupId>
<artifactId>musemix</artifactId>
<version>2.1</version>
<name>musemix</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>21</maven.compiler.release>
</properties>
<!--
DEPENDENCIES NOTE:
* JavaFX deps (21.0.2) bring both stub JARs and platform-classified JARs (*-win.jar)
* fxthemes transitively depends on JNA (automatic module) which causes jlink issues
* All deps here are "compile" scope, but we split them at package time:
* JavaFX *-win.jar => module-path (for jlink to resolve JavaFX modules)
* Everything else => input/classpath (runs as ALL-UNNAMED)
-->
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>21.0.2</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>21.0.2</version>
</dependency>
<dependency>
<groupId>io.github.mkpaz</groupId>
<artifactId>atlantafx-base</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>org.kordamp.ikonli</groupId>
<artifactId>ikonli-javafx</artifactId>
<version>12.4.0</version>
</dependency>
<dependency>
<groupId>org.kordamp.ikonli</groupId>
<artifactId>ikonli-fontawesome6-pack</artifactId>
<version>12.4.0</version>
</dependency>
<dependency>
<groupId>com.pixelduke</groupId>
<artifactId>fxthemes</artifactId>
<version>1.5.1</version>
</dependency>
</dependencies>
<!--
BUILD PLUGINS - PHASE EXECUTION ORDER:
═══════════════════════════════════════════════════════════════════════════
For normal dev: mvnw javafx:run (just uses javafx-maven-plugin)
For export (mvnw clean package -Pexport):
compile phase: maven-compiler-plugin compiles sources
package phase: 1. maven-jar-plugin creates musemix-2.0.jar
2. maven-dependency-plugin copies all deps to target/libs/
3. maven-antrun-plugin:
- Deletes empty JavaFX stub JARs (automatic modules)
- Moves non-JavaFX JARs to target/input/ (classpath)
- Copies app JAR to target/input/
4. jpackage-maven-plugin creates native installer
Result after package phase:
target/libs/ → Only JavaFX *-win.jar files (proper modules)
target/input/ → App JAR + all other deps (classpath JARs)
target/installer/ → Native Windows installer (.exe)
═══════════════════════════════════════════════════════════════════════════
-->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>21</source>
<target>21</target>
</configuration>
</plugin>
<!-- For running locally: mvnw javafx:run -->
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<configuration>
<mainClass>com.uniqueapps.musemix/com.uniqueapps.musemix.MusemixApplication</mainClass>
<options>
<option>--add-opens</option>
<option>javafx.graphics/javafx.stage=com.pixelduke.fxthemes</option>
<option>--add-opens</option>
<option>javafx.graphics/com.sun.javafx.tk=com.pixelduke.fxthemes</option>
<option>--add-opens</option>
<option>javafx.graphics/com.sun.javafx.tk.quantum=com.pixelduke.fxthemes</option>
</options>
</configuration>
</plugin>
<!-- Build the application JAR with main class manifest -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
<mainClass>com.uniqueapps.musemix.MusemixApplication</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<!-- Copy all compile-scope dependencies to target/libs -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.6.1</version>
<executions>
<execution>
<id>copy-deps</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/libs</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!--
ANTRUN: The "fishy" JAR reorganization step
═══════════════════════════════════════════════════════════════════
WHY THIS EXISTS:
* Maven copies ALL JavaFX JARs: both stubs (javafx-fxml-21.0.2.jar)
and platform JARs (javafx-fxml-21.0.2-win.jar)
* The stub JARs are EMPTY and are automatic modules => breaks jlink
* JNA JARs are also automatic modules => can't be on module-path
* Solution: Delete stubs, keep only *-win.jar in libs/ for module-path,
move everything else to input/ for classpath
RESULT:
target/libs/ = javafx-*-win.jar only (4 files, proper modules)
target/input/ = app.jar + fxthemes + JNA + ikonli + atlantafx
═══════════════════════════════════════════════════════════════════
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>reorganize-jars-for-jpackage</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<!-- Create input dir for classpath JARs -->
<mkdir dir="${project.build.directory}/input"/>
<!--
STEP 1: Delete empty JavaFX stub JARs
These are the non-classifier JARs (e.g., javafx-fxml-21.0.2.jar)
They contain no code, just Maven metadata, and are automatic modules.
We keep *-win.jar which have the actual platform-specific code.
-->
<delete>
<fileset dir="${project.build.directory}/libs">
<include name="javafx-base-*.jar"/>
<include name="javafx-controls-*.jar"/>
<include name="javafx-fxml-*.jar"/>
<include name="javafx-graphics-*.jar"/>
<exclude name="*-win.jar"/>
</fileset>
</delete>
<!--
STEP 2: Move non-JavaFX JARs to input/ (classpath)
This includes: fxthemes, JNA, ikonli, atlantafx
These can't be on module-path because:
* JNA is an automatic module (no module-info)
* fxthemes requires JNA, so if JNA isn't resolvable, fxthemes fails
By putting them on classpath, they become ALL-UNNAMED module.
-->
<move todir="${project.build.directory}/input">
<fileset dir="${project.build.directory}/libs">
<include name="*.jar"/>
<exclude name="javafx-*-win.jar"/>
</fileset>
</move>
<!--
STEP 3: Copy app JAR to input/
Our app JAR also goes on classpath because it imports fxthemes
which is now on classpath. Module system would complain otherwise.
-->
<copy file="${project.build.directory}/${project.build.finalName}.jar"
todir="${project.build.directory}/input"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
<!--
JPACKAGE: Native installer creation
═══════════════════════════════════════════════════════════════════
This is a HYBRID setup, not fully modular, not fully classpath:
* module-path points to JavaFX JARs (proper modules for jlink)
* input points to app + deps (classpath, ALL-UNNAMED)
* add-modules tells jlink which modules to include in runtime
* add-opens targets ALL-UNNAMED (not named module) because
fxthemes is on classpath
WHY NOT FULLY MODULAR (module mode):
fxthemes requires JNA, JNA is automatic module, jlink rejects it
WHY NOT FULLY CLASSPATH (no module-path):
JavaFX must be in the runtime image, and jlink needs to find it
on module-path to include it via add-modules
═══════════════════════════════════════════════════════════════════
-->
<plugin>
<groupId>org.panteleyev</groupId>
<artifactId>jpackage-maven-plugin</artifactId>
<version>1.6.5</version>
<configuration>
<!-- Basic app info -->
<name>Musemix</name>
<appVersion>${project.version}</appVersion>
<vendor>UnknownCoder56</vendor>
<description>MIDI player, visualizer and composer</description>
<!--
CLASSPATH MODE: Using main-jar + main-class instead of module
This puts the app on classpath (ALL-UNNAMED) rather than module-path.
Required because our deps include automatic modules (JNA).
-->
<mainJar>${project.build.finalName}.jar</mainJar>
<mainClass>com.uniqueapps.musemix.MusemixApplication</mainClass>
<!--
INPUT: Directory containing classpath JARs
Contains: app.jar, fxthemes, JNA, ikonli, atlantafx
These all run as ALL-UNNAMED module at runtime.
-->
<input>${project.build.directory}/input</input>
<!--
MODULE-PATH: Directory containing proper module JARs
Contains: ONLY javafx-*-win.jar files (4 JARs)
jlink uses this to resolve add-modules and build the runtime.
-->
<modulePaths>
<modulePath>${project.build.directory}/libs</modulePath>
</modulePaths>
<destination>${project.build.directory}/installer</destination>
<icon>${project.basedir}/src/main/resources/com/uniqueapps/musemix/logo.ico</icon>
<!--
ADD-MODULES: Modules to include in the jlink runtime image
These are resolved from module-path (JavaFX) + JDK modules.
The app itself is NOT a module here (it's on classpath).
-->
<addModules>
<addModule>javafx.controls</addModule>
<addModule>javafx.fxml</addModule>
<addModule>javafx.graphics</addModule>
<addModule>java.desktop</addModule>
<addModule>java.xml.crypto</addModule>
</addModules>
<!--
JAVA OPTIONS: Runtime flags baked into the launcher
IMPORTANT: We use ALL-UNNAMED instead of com.pixelduke.fxthemes!
Because fxthemes is on classpath (input dir), not module-path,
it runs as part of the unnamed module. The add-opens must
target ALL-UNNAMED for the reflection to work.
These opens are required by fxthemes for window theming:
* javafx.stage: Window decoration access
* com.sun.javafx.tk: Toolkit internals
* com.sun.javafx.tk.quantum: Quantum toolkit (Windows rendering)
-->
<javaOptions>
<option>--add-opens</option>
<option>javafx.graphics/javafx.stage=ALL-UNNAMED</option>
<option>--add-opens</option>
<option>javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED</option>
<option>--add-opens</option>
<option>javafx.graphics/com.sun.javafx.tk.quantum=ALL-UNNAMED</option>
</javaOptions>
<!-- Windows-specific installer options -->
<winDirChooser>true</winDirChooser>
<winMenu>true</winMenu>
<winMenuGroup>Musemix</winMenuGroup>
<winShortcut>true</winShortcut>
<winShortcutPrompt>true</winShortcutPrompt>
<winPerUserInstall>true</winPerUserInstall>
</configuration>
</plugin>
<plugin>
<groupId>com.gluonhq</groupId>
<artifactId>gluonfx-maven-plugin</artifactId>
<version>1.0.28</version>
<configuration>
<mainClass>com.uniqueapps.musemix.MusemixApplication</mainClass>
<graalvmHome>C:/Users/arpan/Downloads/graalvm-java23-windows-amd64-gluon-23+25.1-dev</graalvmHome>
<reflectionList>
<list>com.uniqueapps.musemix.HomeController</list>
<list>com.uniqueapps.musemix.Player</list>
<list>javafx.scene.layout.GridPane</list>
<list>javafx.scene.control.Tab</list>
<list>javafx.scene.control.Separator</list>
<list>javafx.scene.control.ListView</list>
<list>javafx.scene.CacheHint</list>
<list>javax.sound.sampled.AudioSystem</list>
<list>com.sun.media.sound.SoftSynthesizer</list>
<list>com.sun.media.sound.JDK13Services</list>
<list>javax.sound.midi.MidiSystem</list>
</reflectionList>
<jniList>
<list>com.uniqueapps.musemix.HomeController</list>
<list>com.uniqueapps.musemix.Player</list>
<list>com.sun.media.sound.DirectAudioDevice</list>
<list>com.sun.media.sound.DirectAudioDeviceProvider</list>
<list>com.sun.media.sound.PortMixerProvider</list>
<list>com.sun.media.sound.DirectAudioDeviceProvider$DirectAudioDeviceInfo</list>
<list>com.sun.media.sound.PortMixerProvider$PortMixerInfo</list>
<list>java.lang.Boolean</list>
<list>java.lang.Float</list>
<list>java.lang.Integer</list>
<list>java.lang.System</list>
<list>java.lang.Thread</list>
<list>javax.sound.sampled.AudioSystem</list>
<list>com.sun.media.sound.SoftSynthesizer</list>
<list>com.sun.media.sound.JDK13Services</list>
<list>javax.sound.midi.MidiSystem</list>
</jniList>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<!--
EXPORT PROFILE: mvnw clean package -Pexport
═══════════════════════════════════════════════════════════════════════
This profile binds jpackage to the 'package' phase so everything
runs in a single command. Without this profile, jpackage-maven-plugin
has no execution binding and won't run automatically.
WHY package PHASE:
* maven-dependency-plugin runs at package phase (copies deps)
* maven-antrun-plugin runs at package phase (reorganizes JARs)
* jpackage needs both to complete first, so it also runs at package
* Using 'install' phase would work but requires extra lifecycle step
The <configuration> is inherited from the main <build> section,
so we only need to add the <executions> binding here.
═══════════════════════════════════════════════════════════════════════
-->
<profile>
<id>export</id>
<build>
<plugins>
<plugin>
<groupId>org.panteleyev</groupId>
<artifactId>jpackage-maven-plugin</artifactId>
<version>1.6.5</version>
<executions>
<execution>
<id>jpackage</id>
<phase>package</phase>
<goals>
<goal>jpackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>