Skip to content

Commit 54d3a3d

Browse files
Damodar ReddyAbhinandan Prateek
authored andcommitted
CLOUDSTACK-6410 : Maven Integration for windows Wix tool to create msi installer thropugh maven build process
Signed-off-by: Abhinandan Prateek <aprateek@apache.org>
1 parent b1dfeb9 commit 54d3a3d

3 files changed

Lines changed: 283 additions & 0 deletions

File tree

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<artifactId>Wix-cloudstack-maven-plugin</artifactId>
5+
<name>Wix-cloudstack-maven-plugin</name>
6+
<packaging>maven-plugin</packaging>
7+
<parent>
8+
<groupId>org.apache.cloudstack</groupId>
9+
<artifactId>cloudstack</artifactId>
10+
<version>4.5.0-SNAPSHOT</version>
11+
</parent>
12+
13+
<dependencies>
14+
<dependency>
15+
<groupId>org.apache.maven</groupId>
16+
<artifactId>maven-plugin-api</artifactId>
17+
<version>${maven-plugin-api.version}</version>
18+
</dependency>
19+
<dependency>
20+
<groupId>org.apache.commons</groupId>
21+
<artifactId>commons-exec</artifactId>
22+
<version>${commons-exec.version}</version>
23+
</dependency>
24+
<dependency>
25+
<groupId>org.bitbucket.joxley</groupId>
26+
<artifactId>wix-maven-plugin</artifactId>
27+
<version>${wix-maven-plugin.version}</version>
28+
</dependency>
29+
</dependencies>
30+
31+
<properties>
32+
<maven-plugin-api.version>2.0</maven-plugin-api.version>
33+
<commons-exec.version>1.1</commons-exec.version>
34+
<wix-maven-plugin.version>1.1.1</wix-maven-plugin.version>
35+
</properties>
36+
37+
<build>
38+
<pluginManagement>
39+
<plugins>
40+
<!-- Ignore/Execute plugin execution -->
41+
<plugin>
42+
<groupId>org.eclipse.m2e</groupId>
43+
<artifactId>lifecycle-mapping</artifactId>
44+
<version>1.0.0</version>
45+
<configuration>
46+
<lifecycleMappingMetadata>
47+
<pluginExecutions>
48+
<pluginExecution>
49+
<pluginExecutionFilter>
50+
<groupId>org.apache.maven.plugins</groupId>
51+
<artifactId>maven-enforcer-plugin</artifactId>
52+
<versionRange>[1.0.0,)</versionRange>
53+
<goals>
54+
<goal>enforce</goal>
55+
</goals>
56+
</pluginExecutionFilter>
57+
<action>
58+
<ignore />
59+
</action>
60+
</pluginExecution>
61+
</pluginExecutions>
62+
</lifecycleMappingMetadata>
63+
</configuration>
64+
</plugin>
65+
</plugins>
66+
</pluginManagement>
67+
</build>
68+
</project>
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
package org.apache.cloudstack.wix;
2+
3+
import java.io.File;
4+
import java.io.IOException;
5+
6+
import org.apache.commons.exec.CommandLine;
7+
import org.apache.commons.exec.DefaultExecutor;
8+
import org.apache.commons.exec.ExecuteException;
9+
import org.apache.maven.plugin.MojoExecutionException;
10+
import org.apache.maven.plugin.MojoFailureException;
11+
import org.bitbucket.joxley.wix.AbstractWixMojo;
12+
13+
/**
14+
*
15+
* @goal heat
16+
*
17+
* @phase package
18+
*
19+
*/
20+
public class HeatMojo extends AbstractWixMojo {
21+
22+
/**
23+
* Directory name to be harvested
24+
*
25+
* @parameter expression="${dir}"
26+
* @required
27+
*
28+
*/
29+
private String dir;
30+
31+
/**
32+
* use template, one of: fragment,module,product
33+
* @parameter expression="${template}" defaults to fragment
34+
*
35+
*/
36+
private String template;
37+
38+
/**
39+
* Output file
40+
*
41+
* @parameter expression="${outputFile}"
42+
*/
43+
private File outputFile;
44+
45+
/**
46+
*
47+
* variable names to be passed to heat command
48+
* @parameter expression="${vars}"
49+
*/
50+
private String vars;
51+
52+
/**
53+
*
54+
* variable names to be passed to heat command
55+
* @parameter expression="${workingDirectory}"
56+
*/
57+
private File workingDirectory;
58+
59+
/**
60+
*
61+
* <DirectoryName> directory reference to root directories
62+
* @parameter expression="${directoryName}"
63+
*/
64+
private String directoryName;
65+
66+
@Override
67+
public void execute() throws MojoExecutionException, MojoFailureException {
68+
try {
69+
CommandLine commandLine = new CommandLine("heat");
70+
71+
if(dir != null && !dir.trim().isEmpty()) {
72+
commandLine.addArgument("dir");
73+
commandLine.addArgument(dir);
74+
}
75+
76+
commandLine.addArgument("-gg");
77+
commandLine.addArgument("-cg");
78+
commandLine.addArgument("ClientPath");
79+
commandLine.addArgument("-ke");
80+
commandLine.addArgument("-sfrag");
81+
82+
if(template == null || template.trim().isEmpty()) {
83+
commandLine.addArgument("-template");
84+
commandLine.addArgument("fragment");
85+
} else {
86+
commandLine.addArgument("-template");
87+
commandLine.addArgument(template);
88+
}
89+
90+
if (outputFile != null) {
91+
commandLine.addArgument("-out");
92+
commandLine.addArgument(outputFile.getAbsolutePath());
93+
}
94+
95+
if (directoryName != null) {
96+
commandLine.addArgument("-dr");
97+
commandLine.addArgument(directoryName);
98+
}
99+
100+
if (vars != null) {
101+
commandLine.addArguments(vars, false);
102+
}
103+
104+
DefaultExecutor executor = new DefaultExecutor();
105+
getLog().debug("working directory " + commandLine.toString());
106+
executor.setWorkingDirectory(getWorkingDirectory(workingDirectory));
107+
int exitValue = executor.execute(commandLine);
108+
109+
if (exitValue != 0) {
110+
throw new MojoExecutionException(
111+
"Problem executing heat, return code " + exitValue);
112+
}
113+
114+
} catch (ExecuteException e) {
115+
throw new MojoExecutionException("Problem executing heat", e);
116+
} catch (IOException e) {
117+
throw new MojoExecutionException("Problem executing heat", e);
118+
}
119+
}
120+
121+
}

‎client/pom.xml‎

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,16 @@
515515
<exclude name="*.in"/>
516516
</fileset>
517517
</copy>
518+
<copy todir="./target">
519+
<fileset dir="../scripts/installer/windows/">
520+
<include name="start.bat"/>
521+
</fileset>
522+
</copy>
523+
<copy todir="./target/client">
524+
<fileset dir="./target/generated-webapp">
525+
<include name="**/*"/>
526+
</fileset>
527+
</copy>
518528
</target>
519529
</configuration>
520530
</execution>
@@ -648,6 +658,90 @@
648658
</plugins>
649659
</build>
650660
</profile>
661+
<profile>
662+
<id>buildw</id>
663+
<activation>
664+
<property>
665+
<name>buildw</name>
666+
</property>
667+
</activation>
668+
<build>
669+
<plugins>
670+
<plugin>
671+
<groupId>org.apache.maven.plugins</groupId>
672+
<artifactId>maven-war-plugin</artifactId>
673+
<version>2.3</version>
674+
<configuration>
675+
<webappDirectory>target/client</webappDirectory>
676+
<webXml>./target/generated-webapp/WEB-INF/web.xml</webXml>
677+
<warSourceDirectory>./target/generated-webapp</warSourceDirectory>
678+
<archive>
679+
<manifest>
680+
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
681+
</manifest>
682+
<manifestEntries>
683+
<Implementation-Revision>${git.revision}</Implementation-Revision>
684+
<Implementation-Branch>${git.branch}</Implementation-Branch>
685+
</manifestEntries>
686+
</archive>
687+
</configuration>
688+
</plugin>
689+
<plugin>
690+
<groupId>org.apache.cloudstack</groupId>
691+
<artifactId>Wix-cloudstack-maven-plugin</artifactId>
692+
<version>4.5.0-SNAPSHOT</version>
693+
<configuration>
694+
<vars>-var wix.SourceClient</vars>
695+
<workingDirectory>${basedir}/target</workingDirectory>
696+
<dir>client</dir>
697+
<template>fragment</template>
698+
<directoryName>WEBAPPS</directoryName>
699+
<outputFile>target/client.wxs</outputFile>
700+
</configuration>
701+
<executions>
702+
<execution>
703+
<id>wix-cs</id>
704+
<goals>
705+
<goal>heat</goal>
706+
</goals>
707+
</execution>
708+
</executions>
709+
</plugin>
710+
<plugin>
711+
<groupId>org.bitbucket.joxley</groupId>
712+
<artifactId>wix-maven-plugin</artifactId>
713+
<version>1.1.1</version>
714+
<configuration>
715+
<workingDirectory>${basedir}/target</workingDirectory>
716+
<extensions>
717+
<extension>WixFirewallExtension</extension>
718+
<extension>WixUIExtension</extension>
719+
</extensions>
720+
<arguments>-dSourceClient=SourceDir\client</arguments>
721+
<sourceFiles>
722+
<sourceFile>../scripts/installer/windows/acs.wxs</sourceFile>
723+
<sourceFile>target/client.wxs</sourceFile>
724+
</sourceFiles>
725+
<outputDirectory>target</outputDirectory>
726+
<objectFiles>
727+
<objectFile>target/acs.wixobj</objectFile>
728+
<objectFile>target/client.wixobj</objectFile>
729+
</objectFiles>
730+
<outputFile>target/acs.msi</outputFile>
731+
</configuration>
732+
<executions>
733+
<execution>
734+
<id>wix</id>
735+
<goals>
736+
<goal>candle</goal>
737+
<goal>light</goal>
738+
</goals>
739+
</execution>
740+
</executions>
741+
</plugin>
742+
</plugins>
743+
</build>
744+
</profile>
651745
<profile>
652746
<id>simulator</id>
653747
<activation>

0 commit comments

Comments
 (0)