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 br...@apache.org on 2013/08/13 05:39:23 UTC

svn commit: r1513353 - /incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/Converter/Algorithms/AzurePomConverter.cs

Author: brett
Date: Tue Aug 13 05:39:23 2013
New Revision: 1513353

URL: http://svn.apache.org/r1513353
Log:
[NPANDAY-480] additional role content in Azure project

Some Azure project templates include files to overwrite or supplement what
is included in the originally packaged role (for example,
diagnostics.wadcfg). Copy that into the package preparation area as part of
the build.

Modified:
    incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/Converter/Algorithms/AzurePomConverter.cs

Modified: incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/Converter/Algorithms/AzurePomConverter.cs
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/Converter/Algorithms/AzurePomConverter.cs?rev=1513353&r1=1513352&r2=1513353&view=diff
==============================================================================
--- incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/Converter/Algorithms/AzurePomConverter.cs (original)
+++ incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/Converter/Algorithms/AzurePomConverter.cs Tue Aug 13 05:39:23 2013
@@ -19,7 +19,10 @@
 //
 #endregion
 using System;
+using System.Collections.Generic;
 using System.IO;
+using System.Text.RegularExpressions;
+using System.Xml;
 using log4net;
 using NPanday.Model.Pom;
 using NPanday.ProjectImporter.Digest.Model;
@@ -96,6 +99,58 @@ namespace NPanday.ProjectImporter.Conver
                 AddPluginConfiguration(plugin, "serviceConfigurationFile", projectDigest.CloudConfig);
             }
 
+            Dictionary<string, string> extraRoleContent = new Dictionary<string,string>();
+            foreach (Content content in projectDigest.Contents)
+            {
+                Regex r = new Regex(@"(\w+)Content\\(.+)");
+                Match m = r.Match(content.IncludePath);
+                if (m.Success)
+                {
+                    string role = m.Groups[1].Value;
+                    string include = m.Groups[2].Value;
+
+                    if (extraRoleContent.ContainsKey(role))
+                    {
+                        extraRoleContent[role] = extraRoleContent[role] + "," + include;
+                    }
+                    else
+                    {
+                        extraRoleContent.Add(role, include);
+                    }
+                }
+                else
+                {
+                    log.WarnFormat("Not copying content declared in project from an unknown path: {0}", content.IncludePath);
+                }
+            }
+
+            if (extraRoleContent.Count > 0)
+            {
+                Plugin antPlugin = AddPlugin("org.apache.maven.plugins", "maven-antrun-plugin", null, false);
+
+                Dictionary<string, string> configuration = new Dictionary<string, string>();
+
+                AddPluginExecution(antPlugin, "copy-files", new string[] { "run" }, "prepare-package");
+
+                XmlDocument xmlDocument = new XmlDocument();
+                string xmlns = @"http://maven.apache.org/POM/4.0.0";
+                XmlElement tasks = xmlDocument.CreateElement("tasks", xmlns);
+                foreach (string role in extraRoleContent.Keys)
+                {
+                    XmlElement copyTask = xmlDocument.CreateElement("copy", xmlns);
+                    copyTask.SetAttribute("todir", @"${project.build.directory}/packages/" + projectDigest.ProjectName + "/" + role);
+                    XmlElement fileset = xmlDocument.CreateElement("fileset", xmlns);
+                    fileset.SetAttribute("dir", role + "Content");
+                    fileset.SetAttribute("includes", extraRoleContent[role]);
+                    copyTask.AppendChild(fileset);
+                    tasks.AppendChild(copyTask);
+                }
+
+                PluginExecutionConfiguration config = new PluginExecutionConfiguration();
+                config.Any = new XmlElement[] { tasks };
+                antPlugin.executions[0].configuration = config;
+            }
+
             if (writePom)
             {
                 PomHelperUtility.WriteModelToPom(new FileInfo(Path.Combine(projectDigest.FullDirectoryName, "pom.xml")), Model);