beryx / badass-jlink-plugin

Create a custom runtime image of your modular application
https://badass-jlink-plugin.beryx.org
Apache License 2.0
385 stars 27 forks source link

createMergedModule fails with: WindowsLookAndFeel not found #188

Closed vewert closed 1 year ago

vewert commented 3 years ago

Hi, I'm not sure if you can help or not, but I am trying to migrate an old Swing application that was using ant, to build, to now use Gradle, with the hopes of being able to use jlink/jpackage, using your wonderful plugin.

After fighting with things for a few days, I've successfully reorganized the directory structure, modularized the application, and can now successfully build and run using Gradle.

My next step was to try jpackage (using your plugin), but when I run it, I get the following:

> Task :createMergedModule FAILED
6 actionable tasks: 5 executed, 1 up-to-date
/Users/vewert/DevProj/pwminder-desktop-3.2/build/jlinkbase/tmpjars/ca.ewert.merged.module/module-info.java:1: error: cannot access WindowsLookAndFeel
open module ca.ewert.merged.module {
     ^
  class file for com.sun.java.swing.plaf.windows.WindowsLookAndFeel not found
1 error

FAILURE: Build failed with an exception.

I looked in my code, and I don't think I am using com.sun.java.swing.plaf.windows.WindowsLookAndFeel, but I suspect one (or more) of the jars I'm using might be (there are a couple of jars that provide some custom look and feels).

Without being able to modify the offending jar(s), is there some configuration in your plugin I can use, to get around this error?

I understand its not really an issue with this plugin, but any help would be appreciated.

siordache commented 3 years ago

It's difficult to say what is wrong, without seeing your code, but try to add this to your build.gradle:

jlink {
    ...
    mergedModule {
        additive = true
        requires 'java.desktop'
        ...
    }
    ...
}

If you still get the error, execute: ./gradlew suggestMergedModuleInfo and post the output here.

vewert commented 3 years ago

Thanks. In the mean time, I decided to revert back to my old build system (which worked, so I could put out a release). I am also in the midst of re-writing the application using JavaFX/gradle/jpackage, which is not having this issue.

In case it helps anyone else, however, I did try your suggestions. After updating build.gradle as suggested, I got the following error:

error: duplicate requires: java.desktop
                org.apache.logging.log4j.util.SystemPropertiesPropertySource;    requires java.desktop;

After reverting build.gradle I ran ./gradlew suggestMergedModuleInfo with the following output:

> Task :suggestMergedModuleInfo
mergedModule {
    requires 'java.management';
    requires 'java.naming';
    requires 'java.logging';
    requires 'java.scripting';
    requires 'java.sql';
    requires 'java.prefs';
    requires 'java.rmi';
    requires 'java.xml';
    requires 'java.desktop';
    requires 'java.datatransfer';
    requires 'java.compiler';
    requires 'java.security.jgss';
    uses 'org.apache.logging.log4j.util.PropertySource';
    uses 'org.apache.logging.log4j.core.util.ContextDataProvider';
    uses 'org.apache.logging.log4j.core.util.WatchEventService';
    uses 'org.apache.logging.log4j.spi.Provider';
    uses 'org.apache.logging.log4j.message.ThreadDumpMessage.ThreadInfoFactory';
    provides 'com.fasterxml.jackson.core.JsonFactory' with 'com.fasterxml.jackson.core.JsonFactory';
    provides 'org.apache.logging.log4j.message.ThreadDumpMessage.ThreadInfoFactory' with 'org.apache.logging.log4j.core.message.ExtendedThreadInfoFactory';
    provides 'org.apache.logging.log4j.core.util.ContextDataProvider' with 'org.apache.logging.log4j.core.impl.ThreadContextDataProvider';
    provides 'javax.annotation.processing.Processor' with 'org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor';
    provides 'javax.swing.LookAndFeel' with 'com.jgoodies.looks.plastic.Plastic3DLookAndFeel',
                'com.jgoodies.looks.plastic.PlasticLookAndFeel',
                'com.jgoodies.looks.plastic.PlasticXPLookAndFeel',
                'com.jgoodies.looks.windows.WindowsLookAndFeel';
    provides 'org.apache.logging.log4j.spi.Provider' with 'org.apache.logging.log4j.core.impl.Log4jProvider';
    provides 'org.apache.logging.log4j.util.PropertySource' with 'org.apache.logging.log4j.util.EnvironmentPropertySource',
                'org.apache.logging.log4j.util.SystemPropertiesPropertySource';
}

My guess is that it has something to do with using jgoodies Look and Feel.

As mentioned, I have given up on this path for now, but hopefully this may help someone else.

Thanks again for all your help, and for creating this awesome plugin!