You are viewing a plain text version of this content. The canonical link for it is here.
Posted to npanday-commits@incubator.apache.org by lc...@apache.org on 2011/12/21 16:47:20 UTC
svn commit: r1221800 - in
/incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main:
java/npanday.plugin.msdeploy/ resources/META-INF/npanday/
Author: lcorneliussen
Date: Wed Dec 21 16:47:20 2011
New Revision: 1221800
URL: http://svn.apache.org/viewvc?rev=1221800&view=rev
Log:
[NPANDAY-488] Packaging for Web Applications (also Azure Web Roles)
o Goal for unpacking multiple MSDEPLOY-dependencies
Added:
incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/CreatePackageIterationItem.java
incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/MsDeployUnpackDependenciesMojo.java
- copied, changed from r1221137, incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/MsDeployCreatePackageMojo.java
incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/UnpackDependencyIterationItem.java
Modified:
incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/AbstractMsDeployMojo.java
incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/MsDeployCreatePackageMojo.java
incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/resources/META-INF/npanday/executable-plugins.xml
Modified: incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/AbstractMsDeployMojo.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/AbstractMsDeployMojo.java?rev=1221800&r1=1221799&r2=1221800&view=diff
==============================================================================
--- incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/AbstractMsDeployMojo.java (original)
+++ incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/AbstractMsDeployMojo.java Wed Dec 21 16:47:20 2011
@@ -26,6 +26,7 @@ import npanday.registry.RepositoryRegist
import npanday.vendor.SettingsUtil;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;
@@ -35,7 +36,7 @@ import java.util.List;
/**
* @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
*/
-public abstract class AbstractMsDeployMojo
+public abstract class AbstractMsDeployMojo<T>
extends AbstractMojo
{
/**
@@ -65,12 +66,25 @@ public abstract class AbstractMsDeployMo
*/
private String frameworkVersion;
+ /**
+ * The executable identifier used to locate the right configurations from executable-plugins.xml. Can't be changed.
+ */
+ private String executableIdentifier = "MSDEPLOY";
+
/**
- * The configured profile, from executable-plugins.xml, to be used.
+ * The configured executable version, from executable-plugins.xml, to be used. Should align to a installed
+ * Azure SDK Version.
*
- * @parameter expression = "${profile}" default-value = "MSDEPLOY"
+ * @parameter expression="${msdeploy.version}" default-value="2"
*/
- private String profile;
+ private String executableVersion;
+
+ /**
+ * The configured executable profile, from executable-plugins.xml, to be used.
+ *
+ * @parameter expression="${msdeploy.profile}"
+ */
+ private String executableProfile;
/**
* @component
@@ -97,41 +111,51 @@ public abstract class AbstractMsDeployMo
*/
protected MavenProjectHelper projectHelper;
- public void execute() throws MojoExecutionException
+ public void execute() throws MojoExecutionException, MojoFailureException
{
SettingsUtil.applyCustomSettings( getLog(), repositoryRegistry, settingsPath );
- beforeCommandExecution();
+ final List<T> iterationItems = prepareIterationItems();
- try
- {
- final NetExecutable executable = netExecutableFactory.getNetExecutableFor(
- new ExecutableRequirement( vendor, vendorVersion, frameworkVersion, profile ), getCommands(), null
- );
- executable.execute();
- }
- catch ( ExecutionException e )
- {
- throw new MojoExecutionException(
- "NPANDAY-120-000: Unable to execute profile '" + profile + "' for vendor " + vendor + " v"
- + vendorVersion + " and frameworkVersion = " + frameworkVersion, e
- );
- }
- catch ( PlatformUnsupportedException e )
- {
- throw new MojoExecutionException(
- "NPANDAY-120-001: Unsupported platform configuration. Could not find profile '" + profile
- + "' for vendor " + vendor + " v" + vendorVersion + " and frameworkVersion = " +
- frameworkVersion, e
- );
- }
+ getLog().info( "NPANDAY-120-003: Configured exection items " + iterationItems );
+
+ for(T iterationItem : iterationItems ){
+ getLog().info( "NPANDAY-120-004: Exectuting iteration item " + iterationItem );
+
+ beforeCommandExecution(iterationItem);
- afterCommandExecution();
+ try
+ {
+ final NetExecutable executable = netExecutableFactory.getNetExecutableFor(
+ new ExecutableRequirement( vendor, vendorVersion, frameworkVersion, executableIdentifier ), getCommands(iterationItem), null
+ );
+ executable.execute();
+ }
+ catch ( ExecutionException e )
+ {
+ throw new MojoExecutionException(
+ "NPANDAY-120-000: Unable to execute '" + executableIdentifier + "' for vendor " + vendor + " v"
+ + vendorVersion + " and frameworkVersion = " + frameworkVersion, e
+ );
+ }
+ catch ( PlatformUnsupportedException e )
+ {
+ throw new MojoExecutionException(
+ "NPANDAY-120-001: Unsupported platform configuration. Could not find '" + executableIdentifier
+ + "' for vendor " + vendor + " v" + vendorVersion + " and frameworkVersion = " +
+ frameworkVersion, e
+ );
+ }
+
+ afterCommandExecution(iterationItem);
+ }
}
- protected abstract void afterCommandExecution() throws MojoExecutionException;
+ protected abstract void afterCommandExecution( T iterationItem ) throws MojoExecutionException;
+
+ protected abstract void beforeCommandExecution( T iterationItem );
- protected abstract void beforeCommandExecution();
+ protected abstract List<T> prepareIterationItems() throws MojoFailureException;
- abstract List<String> getCommands() throws MojoExecutionException;
+ protected abstract List<String> getCommands(T item) throws MojoExecutionException;
}
Added: incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/CreatePackageIterationItem.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/CreatePackageIterationItem.java?rev=1221800&view=auto
==============================================================================
--- incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/CreatePackageIterationItem.java (added)
+++ incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/CreatePackageIterationItem.java Wed Dec 21 16:47:20 2011
@@ -0,0 +1,50 @@
+package npanday.plugin.msdeploy;
+
+import npanday.ArtifactType;
+import npanday.PathUtil;
+import org.apache.maven.project.MavenProject;
+
+import java.io.File;
+
+/**
+ * @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
+ */
+public class CreatePackageIterationItem
+{
+ private String classifier;
+
+ private File packageFile;
+
+ private File packageSource;
+
+ public CreatePackageIterationItem( MavenProject project )
+ {
+ this.classifier = null;
+ this.packageSource = PathUtil.getPreparedPackageFolder( project );
+ this.packageFile = new File(
+ project.getBuild().getDirectory(),
+ project.getArtifactId() + "." + ArtifactType.MSDEPLOY_PACKAGE.getExtension()
+ );
+ }
+
+ public String getClassifier()
+ {
+ return classifier;
+ }
+
+ public File getPackageFile()
+ {
+ return packageFile;
+ }
+
+ public File getPackageSource()
+ {
+ return packageSource;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "CreatePackageIterationItem{" + "classifier='" + classifier + '\'' + '}';
+ }
+}
Modified: incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/MsDeployCreatePackageMojo.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/MsDeployCreatePackageMojo.java?rev=1221800&r1=1221799&r2=1221800&view=diff
==============================================================================
--- incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/MsDeployCreatePackageMojo.java (original)
+++ incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/MsDeployCreatePackageMojo.java Wed Dec 21 16:47:20 2011
@@ -8,47 +8,51 @@ import org.apache.maven.plugin.MojoExecu
import java.io.File;
import java.util.List;
+import static com.google.common.collect.Lists.newArrayList;
+
/**
* @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
* @goal create-package
*/
public class MsDeployCreatePackageMojo
- extends AbstractMsDeployMojo
+ extends AbstractMsDeployMojo<CreatePackageIterationItem>
{
- private File packageFile;
-
@Override
- protected void afterCommandExecution() throws MojoExecutionException
+ protected void afterCommandExecution( CreatePackageIterationItem iterationItem ) throws MojoExecutionException
{
- if ( !packageFile.exists() )
+ if ( !iterationItem.getPackageFile().exists() )
{
throw new MojoExecutionException(
- "NPANDAY-121-001: MSDeploy seemed to fail on creating the package " + packageFile.getAbsolutePath()
+ "NPANDAY-121-001: MSDeploy seemed to fail on creating the package " + iterationItem.getPackageFile().getAbsolutePath()
);
}
- projectHelper.attachArtifact( project, ArtifactType.MSDEPLOY_PACKAGE.getPackagingType(), packageFile );
+ projectHelper.attachArtifact( project, ArtifactType.MSDEPLOY_PACKAGE.getPackagingType(), iterationItem.getPackageFile() );
+ }
+
+ @Override
+ protected void beforeCommandExecution( CreatePackageIterationItem iterationItem )
+ {
+
}
@Override
- protected void beforeCommandExecution()
+ protected List<CreatePackageIterationItem> prepareIterationItems()
{
- packageFile = new File(
- project.getBuild().getDirectory(),
- project.getArtifactId() + "." + ArtifactType.MSDEPLOY_PACKAGE.getExtension()
+ // TODO: NPANDAY-497 Support multiple packages with different classifiers
+ return newArrayList(
+ new CreatePackageIterationItem(project)
);
}
@Override
- List<String> getCommands() throws MojoExecutionException
+ protected List<String> getCommands(CreatePackageIterationItem item) throws MojoExecutionException
{
List<String> commands = Lists.newArrayList();
- File packageSource = PathUtil.getPreparedPackageFolder( project );
-
commands.add( "-verb:sync" );
- commands.add( "-source:contentPath=" + packageSource.getAbsolutePath() );
- commands.add( "-dest:package=" + packageFile.getAbsolutePath() );
+ commands.add( "-source:contentPath=" + item.getPackageSource().getAbsolutePath() );
+ commands.add( "-dest:package=" + item.getPackageFile().getAbsolutePath() );
return commands;
}
Copied: incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/MsDeployUnpackDependenciesMojo.java (from r1221137, incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/MsDeployCreatePackageMojo.java)
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/MsDeployUnpackDependenciesMojo.java?p2=incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/MsDeployUnpackDependenciesMojo.java&p1=incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/MsDeployCreatePackageMojo.java&r1=1221137&r2=1221800&rev=1221800&view=diff
==============================================================================
--- incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/MsDeployCreatePackageMojo.java (original)
+++ incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/MsDeployUnpackDependenciesMojo.java Wed Dec 21 16:47:20 2011
@@ -2,53 +2,68 @@ package npanday.plugin.msdeploy;
import com.google.common.collect.Lists;
import npanday.ArtifactType;
-import npanday.PathUtil;
+import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
-import java.io.File;
import java.util.List;
+import java.util.Set;
+
+import static com.google.common.collect.Lists.newArrayList;
/**
+ * Resolves all MSDeploy-Packages and unpacks them for further use.
+ *
* @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
- * @goal create-package
+ *
+ * @goal unpack-dependencies
+ * @requiresDependencyResolution compile
*/
-public class MsDeployCreatePackageMojo
- extends AbstractMsDeployMojo
+public class MsDeployUnpackDependenciesMojo
+ extends AbstractMsDeployMojo<UnpackDependencyIterationItem>
{
- private File packageFile;
+ @Override
+ protected void afterCommandExecution( UnpackDependencyIterationItem iterationItem ) throws MojoExecutionException
+ {
+
+ }
@Override
- protected void afterCommandExecution() throws MojoExecutionException
+ protected void beforeCommandExecution( UnpackDependencyIterationItem iterationItem )
{
- if ( !packageFile.exists() )
- {
- throw new MojoExecutionException(
- "NPANDAY-121-001: MSDeploy seemed to fail on creating the package " + packageFile.getAbsolutePath()
- );
- }
- projectHelper.attachArtifact( project, ArtifactType.MSDEPLOY_PACKAGE.getPackagingType(), packageFile );
}
@Override
- protected void beforeCommandExecution()
+ protected List<UnpackDependencyIterationItem> prepareIterationItems() throws MojoFailureException
{
- packageFile = new File(
- project.getBuild().getDirectory(),
- project.getArtifactId() + "." + ArtifactType.MSDEPLOY_PACKAGE.getExtension()
- );
+ List<UnpackDependencyIterationItem> items = newArrayList();
+
+ final Set projectDependencyArtifacts = project.getDependencyArtifacts();
+ for ( Object artifactAsObject : projectDependencyArtifacts )
+ {
+ Artifact artifact = (Artifact)artifactAsObject;
+ if (artifact.getType().equals( ArtifactType.MSDEPLOY_PACKAGE.getPackagingType())
+ || artifact.getType().equals( ArtifactType.MSDEPLOY_PACKAGE.getExtension()))
+ {
+ items.add( new UnpackDependencyIterationItem(project, artifact) );
+ }
+ }
+
+ return items;
}
@Override
- List<String> getCommands() throws MojoExecutionException
+ protected List<String> getCommands(UnpackDependencyIterationItem item) throws MojoExecutionException
{
List<String> commands = Lists.newArrayList();
- File packageSource = PathUtil.getPreparedPackageFolder( project );
+ // this requires npanday.executable.impl.CommonsExecNetExecutable to be used, as it will respect
+ // the "home-made" quoting
commands.add( "-verb:sync" );
- commands.add( "-source:contentPath=" + packageSource.getAbsolutePath() );
- commands.add( "-dest:package=" + packageFile.getAbsolutePath() );
+ commands.add( "-source:package=\"" + item.getPackageSource().getAbsolutePath() + "\"");
+ commands.add( "-dest:contentPath=\"" + item.getPackageTarget().getAbsolutePath() + "\"" );
return commands;
}
Added: incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/UnpackDependencyIterationItem.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/UnpackDependencyIterationItem.java?rev=1221800&view=auto
==============================================================================
--- incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/UnpackDependencyIterationItem.java (added)
+++ incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday.plugin.msdeploy/UnpackDependencyIterationItem.java Wed Dec 21 16:47:20 2011
@@ -0,0 +1,54 @@
+package npanday.plugin.msdeploy;
+
+import npanday.PathUtil;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+
+import java.io.File;
+
+/**
+ * @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
+ */
+public class UnpackDependencyIterationItem
+{
+ private File packageSource;
+
+ private File packageTarget;
+
+ private Artifact artifact;
+
+ public UnpackDependencyIterationItem( MavenProject project, Artifact artifact ) throws MojoFailureException
+ {
+ this.artifact = artifact;
+
+ if (!artifact.isResolved()){
+ throw new MojoFailureException( "NPANDAY-124-000: The artifact should already have been resolved: " + artifact);
+ }
+
+ // TODO: very, very temporary fix for NPANDAY-509
+
+
+ packageSource = artifact.getFile();
+ assert packageSource != null : "package source should not be null here";
+
+ packageTarget = new File( PathUtil.getPreparedPackageFolder( project ), artifact.getArtifactId() );
+ }
+
+ public File getPackageSource()
+ {
+ return packageSource;
+ }
+
+ public File getPackageTarget()
+ {
+ return packageTarget;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "UnpackDependencyIterationItem{" + "packageSource=" + packageSource + ", packageTarget=" + packageTarget
+ + ", artifact=" + artifact + '}';
+ }
+}
Modified: incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/resources/META-INF/npanday/executable-plugins.xml
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/resources/META-INF/npanday/executable-plugins.xml?rev=1221800&r1=1221799&r2=1221800&view=diff
==============================================================================
--- incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/resources/META-INF/npanday/executable-plugins.xml (original)
+++ incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/resources/META-INF/npanday/executable-plugins.xml Wed Dec 21 16:47:20 2011
@@ -20,10 +20,12 @@ under the License.
<executablePlugin>
<profile>MSDEPLOY</profile>
- <pluginClass>npanday.executable.impl.DefaultNetExecutable</pluginClass>
+ <pluginClass>npanday.executable.impl.CommonsExecNetExecutable</pluginClass>
<vendor>MICROSOFT</vendor>
<executable>msdeploy</executable>
+ <executableVersion>2</executableVersion>
+
<frameworkVersions>
<frameworkVersion>4.0</frameworkVersion>
<frameworkVersion>3.5</frameworkVersion>