Author: brett Date: Fri Aug 22 04:23:53 2014 New Revision: 1619663 URL: http://svn.apache.org/r1619663 Log: [NPANDAY-523] have WIX plugin use the new execution framework
Submitted by: Adrián Boimvaser Added: incubator/npanday/trunk/plugins/wix-maven-plugin/src/main/resources/ incubator/npanday/trunk/plugins/wix-maven-plugin/src/main/resources/META-INF/ incubator/npanday/trunk/plugins/wix-maven-plugin/src/main/resources/META-INF/npanday/ incubator/npanday/trunk/plugins/wix-maven-plugin/src/main/resources/META-INF/npanday/executable-plugins.xml (with props) Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/NetExecutableFactoryImpl.java incubator/npanday/trunk/plugins/wix-maven-plugin/src/main/java/npanday/plugin/wix/AbstractWixMojo.java incubator/npanday/trunk/plugins/wix-maven-plugin/src/main/java/npanday/plugin/wix/CandleMojo.java incubator/npanday/trunk/plugins/wix-maven-plugin/src/main/java/npanday/plugin/wix/LightMojo.java Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/NetExecutableFactoryImpl.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/NetExecutableFactoryImpl.java?rev=1619663&r1=1619662&r2=1619663&view=diff ============================================================================== --- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/NetExecutableFactoryImpl.java (original) +++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/NetExecutableFactoryImpl.java Fri Aug 22 04:23:53 2014 @@ -90,7 +90,7 @@ public class NetExecutableFactoryImpl if ( netHome != null ) { getLogger().info( "NPANDAY-066-014: Found executable path in pom: Path = " + netHome.getAbsolutePath() ); - executableConfig.getExecutionPaths().add( netHome.getAbsolutePath() ); + executablePaths.add( netHome.getAbsolutePath() ); } Modified: incubator/npanday/trunk/plugins/wix-maven-plugin/src/main/java/npanday/plugin/wix/AbstractWixMojo.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/wix-maven-plugin/src/main/java/npanday/plugin/wix/AbstractWixMojo.java?rev=1619663&r1=1619662&r2=1619663&view=diff ============================================================================== --- incubator/npanday/trunk/plugins/wix-maven-plugin/src/main/java/npanday/plugin/wix/AbstractWixMojo.java (original) +++ incubator/npanday/trunk/plugins/wix-maven-plugin/src/main/java/npanday/plugin/wix/AbstractWixMojo.java Fri Aug 22 04:23:53 2014 @@ -19,20 +19,51 @@ package npanday.plugin.wix; * under the License. */ -import org.apache.commons.exec.CommandLine; -import org.apache.commons.exec.DefaultExecutor; -import org.apache.commons.exec.ExecuteException; +import npanday.PlatformUnsupportedException; +import npanday.executable.ExecutableRequirement; +import npanday.executable.ExecutionException; +import npanday.executable.NetExecutable; + import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; +import com.google.common.collect.Lists; + import java.io.File; -import java.io.IOException; import java.util.List; public abstract class AbstractWixMojo extends AbstractMojo { /** + * The vendor of the framework, the executable is provided by or compatible with. + * + * @parameter expression="${vendor}" + */ + private String vendor; + + /** + * The version of the framework vendor, the executable is provided by or compatible with. + * + * @parameter expression="${vendorVersion}" + */ + private String vendorVersion; + + /** + * The framework version, the executable is compatible with. + * + * @parameter expression = "${frameworkVersion}" + */ + private String frameworkVersion; + + /** + * The configured executable version, from executable-plugins.xml, to be used. + * + * @parameter expression="${wix.version}" default-value="3.0" + */ + private String executableVersion; + + /** * WiX extensions to use * * @parameter @@ -59,64 +90,62 @@ public abstract class AbstractWixMojo */ private boolean suppressSchemaValidation; + /** + * @component + */ + private npanday.executable.NetExecutableFactory netExecutableFactory; + public void execute() throws MojoExecutionException { try { - CommandLine commandLine = new CommandLine( getWixPath( getCommand() ) ); - + List<String> commands = Lists.newArrayList(); + if ( extensions != null ) { for ( String ext : extensions ) { - commandLine.addArgument( "-ext" ); - commandLine.addArgument( ext ); + commands.add( "-ext" ); + commands.add( ext ); } } if ( suppressSchemaValidation ) { - commandLine.addArgument( "-ss" ); + commands.add( "-ss" ); } if ( arguments != null ) { - commandLine.addArgument( arguments ); + commands.add( arguments ); } - commandLine.addArguments( getArguments().toArray( new String[0] ) ); - - getLog().info( "Executing " + commandLine ); - - DefaultExecutor executor = new DefaultExecutor(); - int exitValue = executor.execute( commandLine ); - if ( exitValue != 0 ) - { - throw new MojoExecutionException( "Problem executing " + getCommand() + ", return code " + exitValue ); - } + commands.addAll( getArguments() ); + + NetExecutable executor = netExecutableFactory.getExecutable( + new ExecutableRequirement( + vendor, vendorVersion, frameworkVersion, getExecutableIdentifier(), executableVersion + ), commands, (wixHome != null) ? new File( wixHome, "bin" ) : null + ); + executor.execute(); } - catch ( ExecuteException e ) - { - throw new MojoExecutionException( "Problem executing " + getCommand(), e ); - } - catch ( IOException e ) - { - throw new MojoExecutionException( "Problem executing " + getCommand(), e ); + catch (ExecutionException e) { + throw new MojoExecutionException( + "Unable to execute '" + getExecutableIdentifier() + "' for vendor " + vendor + " v" + + vendorVersion + " and frameworkVersion = " + frameworkVersion, e + ); } - } - - private String getWixPath( String name ) - { - if ( wixHome != null ) - { - return new File( new File( wixHome, "bin" ), name ).getAbsolutePath(); + catch (PlatformUnsupportedException e) { + throw new MojoExecutionException( + "Unable to execute '" + getExecutableIdentifier() + "' for vendor " + vendor + " v" + + vendorVersion + " and frameworkVersion = " + frameworkVersion, e + ); } - return name; } - public abstract String getCommand(); - + public abstract String getExecutableIdentifier(); + public abstract List<String> getArguments() throws MojoExecutionException; } Modified: incubator/npanday/trunk/plugins/wix-maven-plugin/src/main/java/npanday/plugin/wix/CandleMojo.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/wix-maven-plugin/src/main/java/npanday/plugin/wix/CandleMojo.java?rev=1619663&r1=1619662&r2=1619663&view=diff ============================================================================== --- incubator/npanday/trunk/plugins/wix-maven-plugin/src/main/java/npanday/plugin/wix/CandleMojo.java (original) +++ incubator/npanday/trunk/plugins/wix-maven-plugin/src/main/java/npanday/plugin/wix/CandleMojo.java Fri Aug 22 04:23:53 2014 @@ -63,10 +63,15 @@ public class CandleMojo */ private File outputDirectory; + /** + * The executable identifier used to locate the right configurations from executable-plugins.xml. Can't be changed. + */ + private String executableIdentifier = "CANDLE"; + @Override - public String getCommand() + public String getExecutableIdentifier() { - return "candle"; + return executableIdentifier; } @Override Modified: incubator/npanday/trunk/plugins/wix-maven-plugin/src/main/java/npanday/plugin/wix/LightMojo.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/wix-maven-plugin/src/main/java/npanday/plugin/wix/LightMojo.java?rev=1619663&r1=1619662&r2=1619663&view=diff ============================================================================== --- incubator/npanday/trunk/plugins/wix-maven-plugin/src/main/java/npanday/plugin/wix/LightMojo.java (original) +++ incubator/npanday/trunk/plugins/wix-maven-plugin/src/main/java/npanday/plugin/wix/LightMojo.java Fri Aug 22 04:23:53 2014 @@ -72,10 +72,15 @@ public class LightMojo */ private String[] cultures; + /** + * The executable identifier used to locate the right configurations from executable-plugins.xml. Can't be changed. + */ + private String executableIdentifier = "LIGHT"; + @Override - public String getCommand() + public String getExecutableIdentifier() { - return "light"; + return executableIdentifier; } @Override Added: incubator/npanday/trunk/plugins/wix-maven-plugin/src/main/resources/META-INF/npanday/executable-plugins.xml URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/wix-maven-plugin/src/main/resources/META-INF/npanday/executable-plugins.xml?rev=1619663&view=auto ============================================================================== --- incubator/npanday/trunk/plugins/wix-maven-plugin/src/main/resources/META-INF/npanday/executable-plugins.xml (added) +++ incubator/npanday/trunk/plugins/wix-maven-plugin/src/main/resources/META-INF/npanday/executable-plugins.xml Fri Aug 22 04:23:53 2014 @@ -0,0 +1,70 @@ +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> +<executablePlugins xmlns="http://npanday.apache.org/executables/1.5.0"> + + <executablePlugin> + <profile>CANDLE</profile> + <pluginClass>npanday.executable.impl.DefaultNetExecutable</pluginClass> + + <executable>candle</executable> + <executableVersion>3.0</executableVersion> + + <vendor>MICROSOFT</vendor> + + <frameworkVersions> + <frameworkVersion>2.0.50727</frameworkVersion> + </frameworkVersions> + + <probingPaths> + <probingPath>%WIX%</probingPath> + </probingPaths> + + <platforms> + <platform> + <operatingSystem>Windows</operatingSystem> + </platform> + </platforms> + + </executablePlugin> + + <executablePlugin> + <profile>LIGHT</profile> + <pluginClass>npanday.executable.impl.DefaultNetExecutable</pluginClass> + + <executable>light</executable> + <executableVersion>3.0</executableVersion> + + <vendor>MICROSOFT</vendor> + + <frameworkVersions> + <frameworkVersion>2.0.50727</frameworkVersion> + </frameworkVersions> + + <probingPaths> + <probingPath>%WIX%</probingPath> + </probingPaths> + + <platforms> + <platform> + <operatingSystem>Windows</operatingSystem> + </platform> + </platforms> + + </executablePlugin> +</executablePlugins> Propchange: incubator/npanday/trunk/plugins/wix-maven-plugin/src/main/resources/META-INF/npanday/executable-plugins.xml ------------------------------------------------------------------------------ svn:eol-style = native