wiverson / maven-jpackage-template

Sample project illustrating building nice, small cross-platform JavaFX or Swing desktop apps with native installers while still using the standard Maven dependency system.
Apache License 2.0
351 stars 53 forks source link

Error creating windows installer with jPackage #4

Closed o4codes closed 3 years ago

o4codes commented 3 years ago

On running mvn clean install the build works then hits an error when running the jpackage-win-installer phase. The error it gives out is yielded below:

Bundler EXE Installer Package skipped because of a configuration problem: java.lang.module.FindException: Error reading module: C:\Users\shadrach PC\Documents\programming projects \Maven\clip_share\target\modules\clipShare.jar

Failed to execute goal io.github.wiverson:jtoolprovider-plugin:1.0.23:java-tool (jpackage-win-installer) on project clipShare: jpackage 1 -> [Help 1]

Is there anything cause for this ?

wiverson commented 3 years ago

There is a property in the build script, that should match the name of the artifactId but with dots instead of dashes.

In the template as it ships, the artifactId is...

<artifactId>maven-jpackage-template</artifactId>

...and the java-mod-name property is set to...

maven.jpackage.template

If you change the name of your artifact to, say, clipshare, than you should change the name of the java-mod-name to match, as in...

clipshare

...and...

clipshare

I would strongly recommend sticking to lower-case only names - some file systems are case dependent, some are case independent.

Let me know if this works!

I'm going to leave this issue open, as I think I can do some stuff to simplify this in the future.

o4codes commented 3 years ago

I tried renaming all to lowercase still the issue persists.

The structure of source folder is show below

structure

Does the structure of the project have anything to do with the issue at hand ?

wiverson commented 3 years ago

Hmm. The error message is saying that jpackage can't read the module declared in clipShare.jar. That means either it can't find the path (perhaps the space in the name) or there is something wrong with the jar file (perhaps it's missing some configuration info). The jar file in the template project is generated by the moditect-maven-plugin.

Does just checking out a copy of the template, perhaps in a C:\src\test folder with no names and running it work for you?

o4codes commented 3 years ago

I removed the spaces and yet still did not work.

I cloned the template and tried with your source code and it worked with your codes. I am starting to feel it's from the structure of my project or probably me having a resource folder, or using fxml instead of building the UI with java or probably it's from the libraries I used ?

wiverson commented 3 years ago

It's possible it's a matter of sorting out JavaFX module configuration. jpackage indicating that it can't read the module is the key, of course.

Are you doing man clean install or just install? Try doing clean for each run first, see if that works, or at least gives you a different error...?

wiverson commented 3 years ago

Yeah, if you are using FXML you need to have the javafx.fxml mod loaded. Look for every place that lists the other javafx modes (e.g. javafx.base, javafx.controls) and add javafx.fxml.

Try adding javafx.fxml to the modules-in-use property line like this:

<modules-in-use>javafx.base,javafx.controls,javafx.graphics,javafx.fxml,java.logging</modules-in-use>

wiverson commented 3 years ago

As an FYI, here are all the javafx jmods:

javafx.base.jmod javafx.fxml.jmod javafx.media.jmod javafx.web.jmod javafx.controls.jmod javafx.graphics.jmod javafx.swing.jmod

o4codes commented 3 years ago

Finally the the native installers is built successfully. The error was coming from the META-INF file. By removing it, the build ran successfully.