1

We need meta-information in the generated executable so that right-clicking and selecting "details" will display the description, copyright and version.

We have added description and vendor in the releaseConfiguration block but the executable still has no meta information.

José Pereda
  • 44,311
  • 7
  • 104
  • 132
  • What platform are you referring to? Windows only? – José Pereda Jan 19 '23 at 13:23
  • The plugin uses this [wxs](https://github.com/gluonhq/substrate/blob/master/src/main/resources/native/windows/wix/main.wxs) file to create the executable when calling `gluonfx:package`, based on these [values](https://github.com/gluonhq/substrate/blob/master/src/main/java/com/gluonhq/substrate/util/windows/MSIBundler.java#L174). Do you see any field that should be different or missing? – José Pereda Jan 19 '23 at 14:05
  • We use gluonfx:build to create the executable, but not package. We use WixToolSet directly, due to a complex configuration needed. Can we customize the exe creation of the build goal to include the meta-inf? – Antonio Vázquez Araújo Jan 19 '23 at 14:14
  • Did you ever try `gluonfx:package`? If it doesn't work for you, you could just run it once, and then modify at your convenience the configuration files/values it uses to create the executable manually. – José Pereda Jan 19 '23 at 15:44
  • Yes, it generates a simple msi. But the exe is already generated by the build goal. I need to include the meta-information in the generated exe, not in the msi. Excuse me if I don't understand you. – Antonio Vázquez Araújo Jan 19 '23 at 16:47
  • Oh, right! My bad, I realize now that you are talking about the exe itself. Now that rings a bell... there was this [issue](https://github.com/gluonhq/substrate/issues/1089), where the executable was getting the values from `glass.dll`, but that was fixed a while ago by the GluonFX plugin, and now there is no default [`version.rc`](https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/resources/version.rc) included. This means you could try to add yours... (which means for now: add it to your project, compile it and link it with the rest of default files...) – José Pereda Jan 19 '23 at 17:23
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jan 19 '23 at 19:53
  • Thank you @JoséPereda for your quick and kind support. But one more thing: how can I add my resource to the project? I put it in the resources folder and add it in resources-config.json but the resource compiler doesn't use it. It uses something called "IconGroup.rc", which I don't have. I also try to name my resource as "IconGroup.rc" with the same result. – Antonio Vázquez Araújo Jan 20 '23 at 11:48
  • Since there is no built-in support yet for this, you will need to compile and link it manually... (check the logs and see how you can modify the command line from the different steps). Or you could clone [Substrate](https://github.com/gluonhq/substrate), and modify it to include `version.rc` with `launch.c` (so it gets compiled and linked)... – José Pereda Jan 20 '23 at 12:29

1 Answers1

2

Until the GluonFX plugin has support for this, there is a relatively easy way to add meta-data to your executable.

You need a version.rc file like the one OpenJFX uses for the different JavaFX libraries: version.rc.

Then, basically you need to compile it with the proper values, and finally link it with the rest of the obj files that produce the executable.

These are the required steps:

Build GluonFX project

Assuming that you have a project like HelloGluon, you need to run once:

mvn gluonfx:build

and that will produce an executable without meta-data under target/gluonfx/x86_64-windows/HelloGluon.exe.

Resource file

The fact that there is a default icon added via target/gluonfx/x86_64-windows/gvm/tmp/icon/IconGroup.obj means that there is already a resource file added to the executable. Since there can be only one, we need to bypass that with some manual work.

If you check the log:

Default icon.ico image generated in C:\%path.to.project%\target\gluonfx\x86_64-windows\gensrc\windows\assets.
Consider copying it to C:\%path.to.project%\src\windows

So let's do that: create the folder C:\%path.to.project%\src\windows, and copy the icon icon.ico, and also the version.rc file.

Edit C:\%path.to.project%\src\windows\version.rc and add right after #define STR(x) #x the following:

IDI_ICON1 ICON "icon.ico"

Compile

Following the flags used for compilation in the OpenJFX win.gradle build file, and from the x64 command prompt, you can run:

cd C:\%path.to.your.project%\src\windows

rc /d JFX_FNAME=HelloGluon.exe /d JFX_INTERNAL_NAME=HelloGluon \
   /d "JFX_COMPANY=My company" /d "JFX_COMPONENT=My component" \
   /d "JFX_NAME=My name" /d "JFX_VER=1.0.0" /d "JFX_BUILD_ID=1.0.0.0+1" \
   /d "JFX_COPYRIGHT=My Copyright" /d "JFX_FVER=1,0,0" \
   /d "JFX_FTYPE=0x7L" \
   /FoC:\%path.to.your.project%\src\windows\version.res version.rc


cvtres /machine:x64 -out:C:\%path.to.your.project%\src\windows\version.obj C:\%path.to.your.project%\src\windows\version.res


This should create version.obj:

> dir
 
C:\%path.to.your.project%\src\windows

21/01/2023  14:38    <DIR>          .
21/01/2023  14:38    <DIR>          ..
21/01/2023  14:18            15.031 icon.ico
21/01/2023  14:38             1.528 version.obj
21/01/2023  14:36             2.629 version.rc
21/01/2023  14:36               796 version.res

Link

Now check the log target/gluonfx/log/process-link-****.log and copy the link command, replacing the IconGroup.obj now with your `version.obj:

link C:\%path.to.project%\target\gluonfx\x86_64-windows\gvm\HelloGluon\launcher.obj \
C:\%path.to.project%\target\gluonfx\x86_64-windows\gvm\tmp\SVM-*****\com.gluonapplication.gluonapplication.obj \

C:\%path.to.project%\src\windows\version.obj \

j2pkcs11.lib java.lib ... crypt32.lib /NODEFAULTLIB:libcmt.lib \
/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup comdlg32.lib ... prism_d3d.lib /WHOLEARCHIVE:glass.lib ... /WHOLEARCHIVE:prism_d3d.lib \
/OUT:C:\%path.to.project%\target\gluonfx\x86_64-windows\HelloGluon.exe \
/LIBPATH:C:\~\.gluon\substrate\javafxStaticSdk\20-ea+7\windows-x86_64\sdk\lib \
/LIBPATH:C:\graalvm-svm-java17-windows-gluon-22.1.0.1-Final\lib\svm\clibraries\windows-amd64 \
/LIBPATH:C:\graalvm-svm-java17-windows-gluon-22.1.0.1-Final\lib\static\windows-amd64


This will link again your executable with your metadata, and you will see that in details from Windows Explorer:

Note that if you run mvn gluonfx:build again, you will lose thet metadata, and you will need to run the manual link command all over again.

José Pereda
  • 44,311
  • 7
  • 104
  • 132
  • Thank you @josepereda, for this very complete and thorough response. However, I can't find a safe and practical way to automate that in CI/CD workflows. I've been looking for ways to do the same via rc.exe and mt.exe, but I can't seem to modify the executable metadata. Your solution might work for me for local work, but I think I need some way to automate it. – Antonio Vázquez Araújo Jan 23 '23 at 18:44
  • I understand. The proper fix is needed in GluonFX (in [Substrate](https://github.com/gluonhq/substrate/blob/master/src/main/java/com/gluonhq/substrate/target/WindowsTargetConfiguration.java#L258) that always adds a default iconGroup.rc). In the meantime, you could try to automate it as well... (really ugly, but it could work: grep the link command line from the link log, replace IconGroup.obj with resources.obj and run it again...). – José Pereda Jan 23 '23 at 19:13