Howto add the version, description and copyright meta-data in the generated executable using gluonfx:build?

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.

Upvotes: 1

Views: 219

Answers (1)

José Pereda
José Pereda

Reputation: 45456

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.

Upvotes: 2

Related Questions