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

Add options for module and merged module archive name #50

Closed nemphys closed 5 years ago

nemphys commented 5 years ago

With the current version of the plugin, the jars produced in the (jlinkjars directory) for the base module and the merged module and named after the module names (moduleName/merged ModuleName settings). It would be nice to have an option similar to archiveBaseName, so that the produced files are named according to it.

siordache commented 5 years ago

I will add these options in the next release (planned for the beginning of May).

siordache commented 5 years ago

In 2.10.3, the module and merged module archives are named in accordance with archiveBaseName. I think that's better than providing a separate option. The plugin already has a lot of options and the archives produced in the jlinkjars directory are only temporary files used as input for the jlink tool, but they don't appear in the final image. Is it ok for you?

nemphys commented 5 years ago

I have no problem with this change (though the optimal solution would be to also have a setting for the merged module archive name suffix, which now seems to be ".merged.module").

But, now that you mentioned it, I have been meaning to ask: is there any chance to consider an option not to merge all application jars together with the jdk modules inside the (huge) "modules" file by jlink?

I was thinking of a setup where just the jdk/javafx/(etc core) java modules are merged in the new image by jlink, with all application modules/jars (including the merged module) in a separate directory (unmerged). This way, it might be possible to preserve the usefulness of jlink, while also preserving the ability to use smart update solutions like eg. update4j (https://github.com/update4j/update4j).

siordache commented 5 years ago

@nemphys Sorry for my late reply.

I was thinking of a setup where just the jdk/javafx/(etc core) java modules are merged in the new image by jlink, with all application modules/jars (including the merged module) in a separate directory (unmerged).

I was wondering why the names of the base and merged module are important to you. Now I understand and it definitely makes sense. I will try to add support for this use case in the next version.

A more general setup would include the approaches taken by the badass-runtime-plugin and the moditect-gradle-plugin. It would allow to:

It would require some work to cover all possible use cases and make sure that other tasks (such as jpackage) still work properly. Due to lack of time, I will not work on this general solution (at least, not in the next couple of months), but I described it here in case someone wants to contribute it.

nemphys commented 5 years ago

This sounds great and a complete implementation would indeed turn this module into a Swiss army knife for jigsaw projects. Do you think that it would be possible to at least implement the 3rd part ("specify which modules to include in the image created by jlink") anytime soon?

siordache commented 5 years ago

I will first provide a more limited version of this, where you can choose between including all modules or only the JRE modules. It should be available by the end of this week.

nemphys commented 5 years ago

This is great news, looking forward to testing it.

siordache commented 5 years ago

Implemented in 2.13.0.

I also managed to provide support for specifying which modules to include in the image created by jlink. See the documentation of the customImage block.

The newly introduced property mergedModuleJarName allows you to configure the name of the JAR file containing the merged module.

Give it a try!

nemphys commented 5 years ago

Thank you for the fast response, I am closing this since it is resolved. I am currently testing the customImage functionality (and having a hard time with it for the moment), I will probably open a new issue for the problems I am facing there.

mordechaim commented 5 years ago

Nice to see my project update4j part of a discussion, thanks 😊