fvarrui / JavaPackager

:package: Gradle/Maven plugin to package Java applications as native Windows, MacOS, or Linux executables and create installers for them.
GNU General Public License v3.0
1.07k stars 134 forks source link

v1.7.3 broken on Windows #381

Open ogerardin opened 11 months ago

ogerardin commented 11 months ago

I'm submitting a…

Short description of the issue/suggestion: v1.7.3 and later are broken on Windows. No issue until 1.7.2.

[ERROR] MSI installer generation failed due to: Command execution failed: light -spdb -out C:\Users\gerardin\IdeaProjects\xpman\xpman-fx-dist\target\X-Plane Manager_1.0-SNAPSHOT.msm C:\Users\gerardin\IdeaProjects\xpman\xpman-fx-dist\target\assets\X-Plane Manager.msm.wixobj Steps to reproduce the issue/enhancement:

Bump plugin version to 1.7.3

What is the expected behavior?

No regression.

What is the current behavior?

Fails with error message.

Do you have outputs, screenshots, demos or samples which demonstrate the problem or enhancement?

[ERROR]     MSI installer generation failed due to: Command execution failed: light -spdb -out C:\Users\gerardin\IdeaProjects\xpman\xpman-fx-dist\target\X-Plane Manager_1.0-SNAPSHOT.msm C:\Users\gerardin\IdeaProjects\xpman\xpman-fx-dist\target\assets\X-Plane Manager.msm.wixobj
[ERROR] 
org.codehaus.plexus.util.cli.CommandLineException: Command execution failed: light -spdb -out C:\Users\gerardin\IdeaProjects\xpman\xpman-fx-dist\target\X-Plane Manager_1.0-SNAPSHOT.msm C:\Users\gerardin\IdeaProjects\xpman\xpman-fx-dist\target\assets\X-Plane Manager.msm.wixobj
    at io.github.fvarrui.javapackager.utils.CommandUtils.executeOnDirectory (CommandUtils.java:20)
    at io.github.fvarrui.javapackager.utils.CommandUtils.execute (CommandUtils.java:30)
    at io.github.fvarrui.javapackager.packagers.GenerateMsm.doApply (GenerateMsm.java:65)
    at io.github.fvarrui.javapackager.packagers.GenerateMsi.doApply (GenerateMsi.java:40)
    at io.github.fvarrui.javapackager.packagers.GenerateMsi.doApply (GenerateMsi.java:16)
    at io.github.fvarrui.javapackager.packagers.ArtifactGenerator.apply (ArtifactGenerator.java:44)
    at io.github.fvarrui.javapackager.packagers.Packager.generateInstallers (Packager.java:447)
    at io.github.fvarrui.javapackager.maven.PackageMojo.execute (PackageMojo.java:387)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:342)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:330)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:175)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:76)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:163)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:160)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:910)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

Other information (e.g. related issues, suggestions how to fix, links for us to have context)

fvarrui commented 11 months ago

Hi @ogerardin! I've managed to reproduce your issue with WiX Toolset 3.11.2.4516 ... I guess new versions are more restrictive than previous ones.

Here you have a quick fix, until I can patch and release JP 1.7.6:

Just create ${project.basedir}/assets/windows/msm.wxs.vtl file with next content and will use this template instead of the default one:

#set ($name = $info.name.replaceAll("[^A-Za-z0-9_.]", "_"))
#set ($id = 0)
#macro(list $file)
    #set($guid = $GUID.randomUUID())
    #set($id = $id + 1)
    #if($file.isDirectory())
        #if($file.equals(${info.appFolder}))
        <Directory Id="INSTALLFOLDER" Name="${file.name}">
        #else
        <Directory Id="_${id}" Name="${file.name}">
        #end
        #foreach($child in $file.listFiles())
            #list($child)
        #end
        </Directory>
    #else
        <Component Id="_${id}" Guid="${guid}" Win64="yes">
        #if($file.equals(${info.executable}))
            <File Id="EXEFILE" Name="${guid}_${file.name}" KeyPath="yes" Source="${file}">
                <Shortcut Id="ApplicationStartMenuShortcut" Name="${info.winConfig.shortcutName}" Description="${info.description}" Directory="ProgramMenuFolder" />
            </File>
            <RemoveFolder Id="ApplicationProgramsFolder" On="uninstall" />
            <RegistryValue Root="HKLM" Key="Software\\${info.organizationName}\\${info.name}" Name="installed" Type="integer" Value="1" />
        #else
            <File Name="${guid}_${file.name}" KeyPath="yes" Source="${file}"/>
        #end
        </Component>
    #end
#end
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Module Id="${name}_Module" Codepage="1252" Language="1033" Version="${info.winConfig.productVersion}">
        <Package Id="${GUID.randomUUID()}" Manufacturer="${info.organizationName}" InstallerVersion="200" Languages="1033" Platform="x64" SummaryCodepage="1252" Description="${info.description}"/>
        <Directory Id="TARGETDIR" Name="SourceDir">
            #list(${info.appFolder})
            <Directory Id="ProgramMenuFolder" />
#if ($info.winConfig.registry)
            <Component Id="RegistryEntries" Guid="${GUID.randomUUID()}">
#foreach ($entry in $info.winConfig.registry.entries)
                <RegistryKey Root="${entry.root}" Key="${entry.subkey}" ForceDeleteOnUninstall="yes">
                    <RegistryValue 
                        Type="${entry.valueTypeAsWIXToolsetString}"
#if ($entry.valueName)
                        Name="$!{entry.valueName}"
#end
#if ($entry.valueData)
                        Value="$!{entry.valueData}"
#end
                    />
                </RegistryKey>
#end
            </Component>
#end
        </Directory>
    </Module>
</Wix>

Now it concats guid to filename, in order to avoid duplicated files:

#if($file.equals(${info.executable}))
    <File Id="EXEFILE" Name="${guid}_${file.name}" KeyPath="yes" Source="${file}">
        <Shortcut Id="ApplicationStartMenuShortcut" Name="${info.winConfig.shortcutName}" Description="${info.description}" Directory="ProgramMenuFolder" />
    </File>
    <RemoveFolder Id="ApplicationProgramsFolder" On="uninstall" />
    <RegistryValue Root="HKLM" Key="Software\\${info.organizationName}\\${info.name}" Name="installed" Type="integer" Value="1" />
#else
    <File Name="${guid}_${file.name}" KeyPath="yes" Source="${file}"/>
#end

I hope it helps!

ogerardin commented 11 months ago

Thanks for your investigation! So far I don't have a real need to update to 1.7.3, so I will wait for 1.7.6.

fvarrui commented 5 months ago

Hi @ogerardin! I managed to build a MSI installer with WiX 3.14 using JavaPackager 1.7.6. Please, could you test it and give me some feedback? Thanks!

ogerardin commented 4 months ago

Hi @ogerardin! I managed to build a MSI installer with WiX 3.14 using JavaPackager 1.7.6. Please, could you test it and give me some feedback? Thanks!

I will asap!