Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repositories {
mavenLocal()
mavenCentral()
maven {
url 'https://plugins.gradle.org/m2/'
url = uri('https://plugins.gradle.org/m2/')
}
}

Expand Down Expand Up @@ -67,8 +67,10 @@ group = 'io.github.fvarrui'
version = '1.7.7-SNAPSHOT'
description = 'Hybrid Maven/Gradle plugin to package Java applications as native Windows, Mac OS X or GNU/Linux executables and create installers for them'

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

compileJava.options.encoding = 'UTF-8'

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public PackagePluginExtension(Project project) {
this.organizationEmail = "";
this.useResourcesAsWorkingDir = true;
this.vmArgs = new ArrayList<>();
this.appArgs = new ArrayList<>();
this.winConfig = new WindowsConfig();
this.outputDirectory = project.getBuildDir();
this.scripts = new Scripts();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.io.File;

import io.github.fvarrui.javapackager.model.Platform;
import io.github.fvarrui.javapackager.utils.CommandUtils;
import io.github.fvarrui.javapackager.utils.Logger;
import io.github.fvarrui.javapackager.utils.VelocityUtils;
import io.github.fvarrui.javapackager.utils.XMLUtils;
Expand Down Expand Up @@ -32,7 +33,7 @@ public boolean skip(WindowsPackager packager) {
return true;
}

return false;
return false;
}

@Override
Expand All @@ -53,17 +54,23 @@ protected File doApply(WindowsPackager packager) throws Exception {

// prettify wxs
XMLUtils.prettify(wxsFile);

// candle wxs file
Logger.info("Compiling file " + wxsFile);
File wixobjFile = new File(assetsFolder, name + ".wixobj");
execute("candle", "-out", wixobjFile, wxsFile);
Logger.info("WIXOBJ file generated in " + wixobjFile + "!");

// lighting wxs file
Logger.info("Linking file " + wixobjFile);
File msiFile = new File(outputDirectory, name + "_" + version + ".msi");
execute("light", "-sw1076", "-spdb", "-out", msiFile, wixobjFile);
// We can rely on the MSM generation to populate this
if(packager.getWixMajorVersion() == 3) {
// candle wxs file
Logger.info("Compiling file " + wxsFile);
File wixobjFile = new File(assetsFolder, name + ".wixobj");
execute("candle", "-arch", "x64", "-out", wixobjFile, wxsFile);
Logger.info("WIXOBJ file generated in " + wixobjFile + "!");

// lighting wxs file
Logger.info("Linking file " + wixobjFile);
execute("light", "-sw1076", "-spdb", "-out", msiFile, wixobjFile);
} else {
Logger.info("Building file " + wxsFile);
CommandUtils.execute("wix", "build", "-pdbtype", "none", "-arch", "x64", "-out", msiFile, wxsFile);
}

// setup file
if (!msiFile.exists()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.github.fvarrui.javapackager.utils.Logger;
import io.github.fvarrui.javapackager.utils.VelocityUtils;
import io.github.fvarrui.javapackager.utils.XMLUtils;
import org.codehaus.plexus.util.cli.CommandLineException;

/**
* Creates an MSI file including all app folder's content only for Windows so app
Expand Down Expand Up @@ -40,6 +41,19 @@ protected File doApply(WindowsPackager packager) throws Exception {
return packager.getMsmFile();
}

try {
String version = CommandUtils.execute("wix", "-version");
packager.setWixMajorVersion(Integer.parseInt(version.split("\\.")[0]));
} catch(CommandLineException ex) {
try {
CommandUtils.execute("candle", "-?");
CommandUtils.execute("light", "-?");
packager.setWixMajorVersion(3);
} catch(CommandLineException ex2) {
throw new Exception("Either 'wix' or 'candle' and 'light' must be on PATH");
}
}

File assetsFolder = packager.getAssetsFolder();
String name = packager.getName();
File outputDirectory = packager.getOutputDirectory();
Expand All @@ -53,16 +67,21 @@ protected File doApply(WindowsPackager packager) throws Exception {
// prettify wxs
XMLUtils.prettify(wxsFile);

// candle wxs file
Logger.info("Compiling file " + wxsFile);
File wixobjFile = new File(assetsFolder, name + ".msm.wixobj");
CommandUtils.execute("candle", "-out", wixobjFile, wxsFile);
Logger.info("WIXOBJ file generated in " + wixobjFile + "!");

// lighting wxs file
Logger.info("Linking file " + wixobjFile);
File msmFile = new File(outputDirectory, name + "_" + version + ".msm");
CommandUtils.execute("light", "-sw1076", "-spdb", "-out", msmFile, wixobjFile);
if(packager.getWixMajorVersion() == 3) {
// candle wxs file
Logger.info("Compiling file " + wxsFile);
File wixobjFile = new File(assetsFolder, name + ".msm.wixobj");
CommandUtils.execute("candle", "-arch", "x64", "-out", wixobjFile, wxsFile);
Logger.info("WIXOBJ file generated in " + wixobjFile + "!");

// lighting wxs file
Logger.info("Linking file " + wixobjFile);
CommandUtils.execute("light", "-sw1076", "-spdb", "-out", msmFile, wixobjFile);
} else {
Logger.info("Building file " + wxsFile);
CommandUtils.execute("wix", "build", "-pdbtype", "none", "-arch", "x64", "-out", msmFile, wxsFile);
}

// setup file
if (!msmFile.exists()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -937,12 +937,12 @@ public String toString() {
+ ", customizedJre=" + customizedJre + ", jrePath=" + jrePath + ", jdkPath=" + jdkPath
+ ", additionalResources=" + additionalResources + ", modules=" + modules + ", additionalModules="
+ additionalModules + ", platform=" + platform + ", envPath=" + envPath + ", vmArgs=" + vmArgs
+ ", runnableJar=" + runnableJar + ", copyDependencies=" + copyDependencies + ", jreDirectoryName="
+ jreDirectoryName + ", winConfig=" + winConfig + ", linuxConfig=" + linuxConfig + ", macConfig="
+ macConfig + ", createTarball=" + createTarball + ", tarballName=" + tarballName + ", createZipball="
+ createZipball + ", zipballName=" + zipballName + ", extra=" + extra + ", useResourcesAsWorkingDir="
+ useResourcesAsWorkingDir + ", assetsDir=" + assetsDir + ", classpath=" + classpath
+ ", jreMinVersion=" + jreMinVersion + ", manifest=" + manifest + ", additionalModulePaths="
+ ", appArgs=" + appArgs + ",runnableJar=" + runnableJar + ", copyDependencies=" + copyDependencies
+ ", jreDirectoryName=" + jreDirectoryName + ", winConfig=" + winConfig + ", linuxConfig=" + linuxConfig
+ ", macConfig=" + macConfig + ", createTarball=" + createTarball + ", tarballName=" + tarballName
+ ", createZipball=" + createZipball + ", zipballName=" + zipballName + ", extra=" + extra
+ ", useResourcesAsWorkingDir=" + useResourcesAsWorkingDir + ", assetsDir=" + assetsDir+ ", classpath="
+ classpath + ", jreMinVersion=" + jreMinVersion + ", manifest=" + manifest + ", additionalModulePaths="
+ additionalModulePaths + ", fileAssociations=" + fileAssociations + ", packagingJdk=" + packagingJdk
+ ", scripts=" + scripts + ", arch=" + arch + ", templates=" + templates + "]";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class WindowsPackager extends Packager {

private File manifestFile;
private File msmFile;
private int wixMajorVersion;

public File getManifestFile() {
return manifestFile;
Expand All @@ -28,9 +29,17 @@ public File getMsmFile() {
return msmFile;
}

public int getWixMajorVersion() {
return wixMajorVersion;
}

public void setMsmFile(File msmFile) {
this.msmFile = msmFile;
}

public void setWixMajorVersion(int wixMajorVersion) {
this.wixMajorVersion = wixMajorVersion;
}

public WindowsPackager() {
super();
Expand Down
23 changes: 18 additions & 5 deletions src/main/resources/windows/msm.wxs.vtl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#end
</Directory>
#else
<Component Id="_${id}" Guid="${guid}" Win64="yes">
<Component Id="_${id}" Guid="${guid}">
#if($file.equals(${info.executable}))
<File Id="EXEFILE" Name="${file.name}" KeyPath="yes" Source="${file}">
<Shortcut Id="ApplicationStartMenuShortcut" Name="${info.winConfig.shortcutName}" Description="${info.description}" Directory="ProgramMenuFolder" />
Expand All @@ -32,15 +32,26 @@
</Component>
#end
#end
#if($info.wixMajorVersion == 3)
<?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}">
#end
<Wix xmlns="#if($info.wixMajorVersion > 3)http://wixtoolset.org/schemas/v4/wxs#{else}http://schemas.microsoft.com/wix/2006/wi#end">
<Module Id="${name}_Module" Codepage="1252" Language="1033" Version="${info.winConfig.productVersion}"
#if($info.wixMajorVersion > 3)
Guid="${GUID.randomUUID()}" InstallerVersion="${installedVersion}"
#end
>
#if($info.wixMajorVersion == 3)
<Package Id="${GUID.randomUUID()}" Manufacturer="${info.organizationName}" InstallerVersion="${installedVersion}" Languages="1033" Platform="${info.arch.toMsiArchitecture()}" SummaryCodepage="1252" Description="${info.description}"/>
#end

#if($info.wixMajorVersion == 3)
<Directory Id="TARGETDIR" Name="SourceDir">
#end
#list(${info.appFolder})
<Directory Id="ProgramMenuFolder" />
#if($info.wixMajorVersion == 3)<Directory Id="ProgramMenuFolder" />#end
#if ($info.winConfig.registry)
<Component Id="RegistryEntries" Guid="${GUID.randomUUID()}">
<Component Id="RegistryEntries" Guid="${GUID.randomUUID()}" #if($info.wixMajorVersion > 3)Directory="TARGETDIR"#end>
#foreach ($entry in $info.winConfig.registry.entries)
<RegistryKey Root="${entry.root}" Key="${entry.subkey}" ForceDeleteOnUninstall="yes">
<RegistryValue
Expand All @@ -56,6 +67,8 @@
#end
</Component>
#end
#if($info.wixMajorVersion == 3)
</Directory>
#end
</Module>
</Wix>
23 changes: 17 additions & 6 deletions src/main/resources/windows/wxs.vtl
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
#set($moduleName = $info.name.replaceAll("[^A-Za-z0-9_.]", "_") + "_Module")
#if($info.wixMajorVersion == 3)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
#end
<Wix xmlns="#if($info.wixMajorVersion == 3)http://schemas.microsoft.com/wix/2006/wi#{else}http://wixtoolset.org/schemas/v4/wxs#end">
#if($info.wixMajorVersion > 3)
<Package Codepage="1252" Language="1033" Manufacturer="${info.organizationName}" Name="${info.name}" UpgradeCode="${info.winConfig.msiUpgradeCode}" Version="${info.winConfig.productVersion}" InstallerVersion="200">
<SummaryInformation Description="${info.description}" />
#else
<Product Id="*" Codepage="1252" Language="1033" Manufacturer="${info.organizationName}" Name="${info.name}" UpgradeCode="${info.winConfig.msiUpgradeCode}" Version="${info.winConfig.productVersion}">
<Package Compressed="yes" InstallScope="perMachine" InstallerVersion="200" Languages="1033" Platform="x64" SummaryCodepage="1252" Description="${info.description}"/>
<Package Compressed="yes" InstallScope="perMachine" InstallerVersion="200" Languages="1033" Platform="x64" SummaryCodepage="1252" Description="${info.description}"/>
#end
<Media Id="1" Cabinet="Application.cab" EmbedCab="yes"/>
#if($info.wixMajorVersion == 3)
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
#end
<#if($info.wixMajorVersion > 3)StandardDirectory#{else}Directory#end Id="ProgramFiles64Folder">
<Merge Id="${moduleName}" Language="1033" SourceFile="${info.msmFile}" DiskId="1" />
</Directory>
</#if($info.wixMajorVersion > 3)StandardDirectory#{else}Directory#end>
#if($info.wixMajorVersion == 3)
</Directory>
<Feature Id="_${GUID.randomUUID().toString().replaceAll('-','_')}" Absent="disallow" AllowAdvertise="no" ConfigurableDirectory="TARGETDIR" Description="${info.description}" Level="1" Title="${info.displayName}">
#end
<Feature Id="_${GUID.randomUUID().toString().replaceAll('-','_')}" #if($info.wixMajorVersion > 3)AllowAbsent="no"#{else}Absent="disallow"#end AllowAdvertise="no" ConfigurableDirectory="TARGETDIR" Description="${info.description}" Level="1" Title="${info.displayName}">
<MergeRef Id="${moduleName}"/>
</Feature>
<Icon Id="ICONFILE" SourceFile="${info.iconFile.getAbsolutePath()}"/>
Expand All @@ -18,5 +29,5 @@
<WixVariable Id="WixUILicenseRtf" Value="LICENSE"/>
#end
<MajorUpgrade AllowDowngrades="no" AllowSameVersionUpgrades="no" DowngradeErrorMessage="A later version of ${info.winConfig.productName} is already installed. Setup will now exit." IgnoreRemoveFailure="no"/>
</Product>
</#if($info.wixMajorVersion > 3)Package#{else}Product#end>
</Wix>