99
1010import org .apache .commons .lang3 .StringUtils ;
1111
12+ import io .github .fvarrui .javapackager .model .Arch ;
1213import io .github .fvarrui .javapackager .model .Platform ;
1314import io .github .fvarrui .javapackager .model .WindowsConfig ;
1415import io .github .fvarrui .javapackager .model .WindowsExeCreationTool ;
@@ -57,7 +58,8 @@ protected File doApply(WindowsPackager packager) throws Exception {
5758 File jreDestinationFolder = packager .getJreDestinationFolder ();
5859 boolean bundleJre = packager .getBundleJre ();
5960 String vmLocation = packager .getWinConfig ().getVmLocation ();
60- WindowsConfig winConfig = packager .getWinConfig ();
61+ WindowsConfig winConfig = packager .getWinConfig ();
62+ Arch arch = packager .getArch ();
6163
6264 if (winConfig .isWrapJar ()) {
6365 Logger .warn ("'wrapJar' property ignored when building EXE with " + getArtifactName ());
@@ -72,7 +74,11 @@ protected File doApply(WindowsPackager packager) throws Exception {
7274 FileUtils .copyFileToFile (iconFile , getGenericIcon ());
7375
7476 // creates generic exe
75- FileUtils .copyResourceToFile ("/windows/WinRun4J64.exe" , getGenericExe ());
77+ if (arch == Arch .x64 ) {
78+ FileUtils .copyResourceToFile ("/windows/WinRun4J64.exe" , getGenericExe ());
79+ } else if (arch == Arch .x86 ) {
80+ FileUtils .copyResourceToFile ("/windows/WinRun4J.exe" , getGenericExe ());
81+ }
7682
7783 // uses vmLocation only if a JRE is bundled
7884 if (bundleJre ) {
@@ -89,7 +95,7 @@ protected File doApply(WindowsPackager packager) throws Exception {
8995
9096 } else {
9197
92- // searchs for valid jvm.dll file in JRE
98+ // searchs for a valid jvm.dll file in JRE
9399 Optional <File > jvmDllFile = Arrays .asList (JVM_DLL_PATHS )
94100 .stream ()
95101 .map (path -> new File (jreDestinationFolder , path ))
@@ -115,11 +121,6 @@ protected File doApply(WindowsPackager packager) throws Exception {
115121
116122 }
117123
118- // generates ini file
119- File genericIni = new File (getOutputFolder (), "app.ini" );
120- VelocityUtils .render ("windows/ini.vtl" , genericIni , packager );
121- Logger .info ("INI file generated in " + genericIni .getAbsolutePath () + "!" );
122-
123124 // set exe metadata with rcedit
124125 RcEdit rcedit = new RcEdit (getOutputFolder ());
125126 rcedit .setIcon (getGenericExe (), getGenericIcon ());
@@ -136,6 +137,7 @@ protected File doApply(WindowsPackager packager) throws Exception {
136137 FileUtils .copyFileToFolder (jarFile , appFolder );
137138
138139 // copies winrun4j launcher helper library (needed to work around
140+ /*
139141 File winrun4jJar = new File(libsFolder, "winrun4j-launcher.jar");
140142 FileUtils.copyResourceToFile("/windows/winrun4j-launcher.jar", winrun4jJar);
141143
@@ -147,7 +149,13 @@ protected File doApply(WindowsPackager packager) throws Exception {
147149
148150 // copies winrun4j properties to launcher jar
149151 JarUtils.addFileToJar(winrun4jJar, propertiesFile);
152+ */
150153
154+ // generates ini file
155+ File genericIni = new File (getOutputFolder (), "app.ini" );
156+ VelocityUtils .render ("windows/ini.vtl" , genericIni , packager );
157+ Logger .info ("INI file generated in " + genericIni .getAbsolutePath () + "!" );
158+
151159 // copies ini file to app folder
152160 File iniFile = new File (appFolder , name + ".ini" );
153161 FileUtils .copyFileToFile (genericIni , iniFile );
0 commit comments