Author: lcorneliussen
Date: Wed Dec 21 18:29:10 2011
New Revision: 1221831
URL: http://svn.apache.org/viewvc?rev=1221831&view=rev
Log:
[NPANDAY-480] Support Windows Azure Cloud Service Project and Packaging (CCPack)
o initial working mojos
Added:
incubator/npanday/trunk/plugins/azure-maven-plugin/
incubator/npanday/trunk/plugins/azure-maven-plugin/pom.xml
incubator/npanday/trunk/plugins/azure-maven-plugin/src/
incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/
incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/java/
incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/java/npanday.plugin.azure/
incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/java/npanday.plugin.azure/AbstractCSPackDeployMojo.java
incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/java/npanday.plugin.azure/PackageAzureCloudServiceMojo.java
incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/resources/
incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/resources/META-INF/
incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/resources/META-INF/npanday/
incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/resources/META-INF/npanday/executable-plugins.xml
incubator/npanday/trunk/plugins/azure-maven-plugin/src/site/
incubator/npanday/trunk/plugins/azure-maven-plugin/src/site/site.xml
Modified:
incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/ArtifactType.java
incubator/npanday/trunk/plugins/pom.xml
Modified:
incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/ArtifactType.java
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/ArtifactType.java?rev=1221831&r1=1221830&r2=1221831&view=diff
==============================================================================
---
incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/ArtifactType.java
(original)
+++
incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/ArtifactType.java
Wed Dec 21 18:29:10 2011
@@ -166,6 +166,7 @@ public enum ArtifactType
/* Azure support */
AZURE_CLOUD_SERVICE ("azure-cloud-service", null, "cspkg"),
+ AZURE_CLOUD_SERVICE_CONFIGURATION ("azure-cloud-service-configuration",
null, "cscfg"),
/* MSDeploy support */
MSDEPLOY_PACKAGE ("msdeploy-package", null, "msdeploy.zip");
Added: incubator/npanday/trunk/plugins/azure-maven-plugin/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/azure-maven-plugin/pom.xml?rev=1221831&view=auto
==============================================================================
--- incubator/npanday/trunk/plugins/azure-maven-plugin/pom.xml (added)
+++ incubator/npanday/trunk/plugins/azure-maven-plugin/pom.xml Wed Dec 21
18:29:10 2011
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>maven-dotnet-plugins</artifactId>
+ <groupId>org.apache.npanday.plugins</groupId>
+ <version>1.5.0-incubating-SNAPSHOT</version>
+ </parent>
+ <groupId>org.apache.npanday.plugins</groupId>
+ <artifactId>azure-maven-plugin</artifactId>
+ <packaging>maven-plugin</packaging>
+
+ <name>NPanday :: Azure Maven Plugin</name>
+ <description>Maven Plugin for packaging of Azure Cloud Services</description>
+</project>
Added:
incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/java/npanday.plugin.azure/AbstractCSPackDeployMojo.java
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/java/npanday.plugin.azure/AbstractCSPackDeployMojo.java?rev=1221831&view=auto
==============================================================================
---
incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/java/npanday.plugin.azure/AbstractCSPackDeployMojo.java
(added)
+++
incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/java/npanday.plugin.azure/AbstractCSPackDeployMojo.java
Wed Dec 21 18:29:10 2011
@@ -0,0 +1,155 @@
+/*
+ * 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.
+ */
+package npanday.plugin.azure;
+
+import npanday.PlatformUnsupportedException;
+import npanday.executable.ExecutableRequirement;
+import npanday.executable.ExecutionException;
+import npanday.executable.NetExecutable;
+import npanday.registry.RepositoryRegistry;
+import npanday.vendor.SettingsUtil;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectHelper;
+
+import java.util.List;
+
+
+/**
+ * Abstract Mojo for interaction with CSPack
+ *
+ * @author <a href="mailto:[email protected]">Lars Corneliussen</a>
+ */
+public abstract class AbstractCSPackDeployMojo
+ extends AbstractMojo
+{
+ /**
+ * @parameter expression="${npanday.settings}"
default-value="${user.home}/.m2"
+ */
+ private String settingsPath;
+
+ /**
+ * 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="${vendor}"
+ */
+ private String vendorVersion;
+
+ /**
+ * The framework version, the executable is compatible with.
+ *
+ * @parameter expression = "${frameworkVersion}"
+ */
+ private String frameworkVersion;
+
+ /**
+ * The executable identifier used to locate the right configurations from
executable-plugins.xml. Can't be changed.
+ */
+ private String executableIdentifier = "CSPACK";
+
+ /**
+ * The configured executable version, from executable-plugins.xml, to be
used. Should align to a installed
+ * Azure SDK Version.
+ *
+ * @parameter expression="${azuresdk.version}" default-value="1.6"
+ */
+ private String executableVersion;
+
+ /**
+ * The configured executable profile, from executable-plugins.xml, to be
used.
+ *
+ * @parameter expression="${cspack.profile}"
+ */
+ private String executableProfile;
+
+ /**
+ * @component
+ */
+ private RepositoryRegistry repositoryRegistry;
+
+ /**
+ * @component
+ */
+ private npanday.executable.NetExecutableFactory netExecutableFactory;
+
+ /**
+ * The maven project.
+ *
+ * @parameter expression="${project}"
+ * @required
+ */
+ protected MavenProject project;
+
+ /**
+ * The maven project helper.
+ *
+ * @component
+ */
+ protected MavenProjectHelper projectHelper;
+
+ public void execute() throws MojoExecutionException
+ {
+ SettingsUtil.applyCustomSettings( getLog(), repositoryRegistry,
settingsPath );
+
+ beforeCommandExecution();
+
+ try
+ {
+ // TODO: confusion of 'identifier' and 'profile' / align to new
NPANDAY-499
+ final NetExecutable executable =
netExecutableFactory.getNetExecutableFor(
+ new ExecutableRequirement(
+ vendor, vendorVersion, frameworkVersion,
executableIdentifier, executableVersion
+ /*, executableProfile*/
+ ), getCommands(), null
+ );
+ executable.execute();
+ }
+ catch ( ExecutionException e )
+ {
+ throw new MojoExecutionException(
+ "NPANDAY-122-000: Unable to execute profile '" +
executableIdentifier + "' for vendor " + vendor + " v"
+ + vendorVersion + " and frameworkVersion = " +
frameworkVersion, e
+ );
+ }
+ catch ( PlatformUnsupportedException e )
+ {
+ throw new MojoExecutionException(
+ "NPANDAY-122-001: Unsupported platform configuration. Could
not find profile '" + executableIdentifier
+ + "' for vendor " + vendor + " v" + vendorVersion + " and
frameworkVersion = " +
+ frameworkVersion, e
+ );
+ }
+
+ afterCommandExecution();
+ }
+
+ protected abstract void afterCommandExecution() throws
MojoExecutionException;
+
+ protected abstract void beforeCommandExecution();
+
+ protected abstract List<String> getCommands() throws
MojoExecutionException;
+}
Added:
incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/java/npanday.plugin.azure/PackageAzureCloudServiceMojo.java
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/java/npanday.plugin.azure/PackageAzureCloudServiceMojo.java?rev=1221831&view=auto
==============================================================================
---
incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/java/npanday.plugin.azure/PackageAzureCloudServiceMojo.java
(added)
+++
incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/java/npanday.plugin.azure/PackageAzureCloudServiceMojo.java
Wed Dec 21 18:29:10 2011
@@ -0,0 +1,131 @@
+package npanday.plugin.azure;
+
+import com.google.common.collect.Lists;
+import npanday.ArtifactType;
+import npanday.PathUtil;
+import npanday.plugin.azure.AbstractCSPackDeployMojo;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.io.File;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Packages roles specified in the dependencies into a common cloud service
package (*.cspkg), accompanied
+ * with a configuration template (*.cscfg).
+ *
+ * @author <a href="mailto:[email protected]">Lars Corneliussen</a>
+ * @goal create-cloud-service-package
+ * @requiresDependencyResolution runtime
+ */
+public class PackageAzureCloudServiceMojo
+ extends AbstractCSPackDeployMojo
+{
+ private File packageFile, templateConfigurationFile;
+
+ /**
+ * @parameter expression="${cspack.serviceDefinition}"
default-value="${basedir}/ServiceDefinition.csdef"
+ */
+ private File serviceDefinitionFile;
+
+ /**
+ * @parameter expression="${cspack.generateConfigurationFile}"
default-value="true"
+ */
+ private boolean generateConfigurationFile;
+
+ @Override
+ protected void afterCommandExecution() throws MojoExecutionException
+ {
+ attachPackageFile();
+
+ if ( generateConfigurationFile )
+ {
+ attachConfigurationFile();
+ }
+ }
+
+ private void attachPackageFile() throws MojoExecutionException
+ {
+ if ( !packageFile.exists() )
+ {
+ throw new MojoExecutionException(
+ "NPANDAY-123-001: CSPack seemed to fail on creating the
package " + packageFile.getAbsolutePath()
+ );
+ }
+
+ project.getArtifact().setFile( packageFile );
+ }
+
+ private void attachConfigurationFile() throws MojoExecutionException
+ {
+ if ( !templateConfigurationFile.exists() )
+ {
+ throw new MojoExecutionException(
+ "NPANDAY-123-002: CSPack seemed to fail on creating the
template configuration file "
+ + packageFile.getAbsolutePath()
+ );
+
+ }
+
+ projectHelper.attachArtifact(
+ project,
ArtifactType.AZURE_CLOUD_SERVICE_CONFIGURATION.getPackagingType(),
"configtemplate",
+ templateConfigurationFile
+ );
+ }
+
+ @Override
+ protected void beforeCommandExecution()
+ {
+ packageFile = new File(
+ project.getBuild().getDirectory(),
+ project.getArtifactId() + "." +
ArtifactType.AZURE_CLOUD_SERVICE.getExtension()
+ );
+
+ templateConfigurationFile = new File(
+ project.getBuild().getDirectory(), project.getArtifactId() +
"-configtemplate" + "."
+ + ArtifactType.AZURE_CLOUD_SERVICE_CONFIGURATION.getExtension()
+ );
+ }
+
+ @Override
+ protected List<String> getCommands() throws MojoExecutionException
+ {
+ List<String> commands = Lists.newArrayList();
+
+ commands.add( serviceDefinitionFile.getAbsolutePath() );
+
+ if ( generateConfigurationFile )
+ {
+ commands.add( "/generateConfigurationFile:\"" +
templateConfigurationFile.getAbsolutePath() + "\"" );
+ }
+
+ commands.add( "/out:" + packageFile.getAbsolutePath() );
+
+ 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() ) )
+ {
+ final File webRoot = new File(
+ PathUtil.getPreparedPackageFolder( project ),
artifact.getArtifactId()
+ );
+
+ commands.add(
+ "/role:" + artifact.getArtifactId() + ";" +
webRoot.getAbsolutePath()
+ );
+
+ // TODO: 'Web/' is hardcoded here; where to get it from?1
(310) 728-2143 x2813
+ commands.add(
+ "/sitePhysicalDirectories:" + artifact.getArtifactId() +
";Web/;" + webRoot.getAbsolutePath()
+ );
+ }
+ }
+
+ return commands;
+ }
+
+
+}
Added:
incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/resources/META-INF/npanday/executable-plugins.xml
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/resources/META-INF/npanday/executable-plugins.xml?rev=1221831&view=auto
==============================================================================
---
incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/resources/META-INF/npanday/executable-plugins.xml
(added)
+++
incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/resources/META-INF/npanday/executable-plugins.xml
Wed Dec 21 18:29:10 2011
@@ -0,0 +1,46 @@
+<!--
+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>CSPACK</profile>
+ <pluginClass>npanday.executable.impl.CommonsExecNetExecutable</pluginClass>
+
+ <executable>cspack</executable>
+ <executableVersion>1.6</executableVersion>
+
+ <vendor>MICROSOFT</vendor>
+
+ <frameworkVersions>
+ <frameworkVersion>4.0</frameworkVersion>
+ <frameworkVersion>3.5</frameworkVersion>
+ </frameworkVersions>
+
+ <probingPaths>
+ <probingPath>${HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft
SDKs\ServiceHosting\v1.6@InstallPath}\bin</probingPath>
+ </probingPaths>
+
+ <platforms>
+ <platform>
+ <operatingSystem>Windows</operatingSystem>
+ </platform>
+ </platforms>
+
+ </executablePlugin>
+</executablePlugins>
Added: incubator/npanday/trunk/plugins/azure-maven-plugin/src/site/site.xml
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/azure-maven-plugin/src/site/site.xml?rev=1221831&view=auto
==============================================================================
--- incubator/npanday/trunk/plugins/azure-maven-plugin/src/site/site.xml (added)
+++ incubator/npanday/trunk/plugins/azure-maven-plugin/src/site/site.xml Wed
Dec 21 18:29:10 2011
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/DECORATION/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0
http://maven.apache.org/xsd/decoration-1.0.0.xsd">
+ <body>
+ <menu ref="parent" />
+
+ <menu name="Overview">
+ <item name="About" href="index.html"/>
+ <item name="Goals" href="plugin-info.html"/>
+ </menu>
+
+ <menu ref="reports" />
+ </body>
+</project>
Modified: incubator/npanday/trunk/plugins/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/pom.xml?rev=1221831&r1=1221830&r2=1221831&view=diff
==============================================================================
--- incubator/npanday/trunk/plugins/pom.xml (original)
+++ incubator/npanday/trunk/plugins/pom.xml Wed Dec 21 18:29:10 2011
@@ -57,6 +57,7 @@ under the License.
<module>wix-maven-plugin</module>
<module>partcover-maven-plugin</module>
<module>msdeploy-maven-plugin</module>
+ <module>azure-maven-plugin</module>
</modules>
<dependencies>
<dependency>