Author: brett
Date: Thu Jul 3 01:27:01 2008
New Revision: 673616
URL:
http://svn.apache.org/viewvc?rev=673616&view=revLog:
[NMAVEN-119] Ability to generate pom.xml file from an existing Visual Studio solution file
Submitted by: Jan Ancajas
Added:
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Console/
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Console/pom.xml
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Console/src/
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Console/src/main/
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Console/src/main/csharp/
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Console/src/main/csharp/NMaven/
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Console/src/main/csharp/NMaven/ProjectImporter/
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Console/src/main/csharp/NMaven/ProjectImporter/NMavenImportRunner.cs
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/pom.xml
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Generator/
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Generator/BasePomGenerator.cs
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Generator/ProjectPomGenerator.cs
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Generator/SolutionPomGenerator.cs
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Model/
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Model/DefaultDOMElement.cs
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Model/DefaultDOMElements.cs
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Model/Project.cs
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Model/Solution.cs
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/NMavenImporter.cs
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Parser/
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Parser/DefaultDOMParser.cs
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Parser/DefaultSolutionParser.cs
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Parser/ProjectTransformer.cs
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/util/
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/util/Constants.cs
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/util/Utility.cs
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/pom.xml
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.VisualStudio.Addin/src/main/csharp/NMaven/VisualStudio/Addin/NMavenImportProjectForm.Designer.cs
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.VisualStudio.Addin/src/main/csharp/NMaven/VisualStudio/Addin/NMavenImportProjectForm.cs
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.VisualStudio.Addin/src/main/csharp/NMaven/VisualStudio/Addin/NMavenImportProjectForm.resx
Modified:
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.VisualStudio.Addin/pom.xml
incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.VisualStudio.Addin/src/main/csharp/NMaven/VisualStudio/Addin/Connect.cs
incubator/nmaven/branches/NMAVEN_0.14/assemblies/pom.xml
Added: incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Console/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Console/pom.xml?rev=673616&view=auto==============================================================================
--- incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Console/pom.xml (added)
+++ incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Console/pom.xml Thu Jul 3 01:27:01 2008
@@ -0,0 +1,73 @@
+<?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>
+ <parent>
+ <groupId>NMaven.ProjectImporter</groupId>
+ <version>0.14-incubating-SNAPSHOT</version>
+ <artifactId>NMaven.ImporterProjectParent</artifactId>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>NMaven.ProjectImporter</groupId>
+ <artifactId>NMaven.ProjectImporterConsole</artifactId>
+ <version>0.14-incubating-SNAPSHOT</version>
+ <packaging>exe</packaging>
+ <name>NMaven.ProjectImporterConsole</name>
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-webdav</artifactId>
+ <version>1.0-beta-2</version>
+ </extension>
+ </extensions>
+ <sourceDirectory>src/main/csharp</sourceDirectory>
+ <testSourceDirectory>src/test/csharp</testSourceDirectory>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.dotnet.plugins</groupId>
+ <artifactId>maven-compile-plugin</artifactId>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>src</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>NMaven.ProjectImporter</groupId>
+ <artifactId>NMaven.ProjectImporterEngine</artifactId>
+ <version>0.14-incubating-SNAPSHOT</version>
+ <type>library</type>
+ </dependency>
+ <dependency>
+ <groupId>NUnit</groupId>
+ <artifactId>NUnit.Framework</artifactId>
+ <type>library</type>
+ <version>2.2.8.0</version>
+ </dependency>
+ </dependencies>
+</project>
Added: incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Console/src/main/csharp/NMaven/ProjectImporter/NMavenImportRunner.cs
URL:
http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Console/src/main/csharp/NMaven/ProjectImporter/NMavenImportRunner.cs?rev=673616&view=auto==============================================================================
--- incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Console/src/main/csharp/NMaven/ProjectImporter/NMavenImportRunner.cs (added)
+++ incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Console/src/main/csharp/NMaven/ProjectImporter/NMavenImportRunner.cs Thu Jul 3 01:27:01 2008
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Xml;
+using System.IO;
+using NMaven.ProjectImporter.NMaven;
+
+
+namespace NMaven.ProjectImporter.NMaven.ProjectImporter
+{
+ class NMavenImportRunner
+ {
+
+ public static void Main(String[] args)
+ {
+ if (args.Length == 0)
+ {
+ Console.WriteLine("please specify the solution file. e.g. : " + Environment.NewLine + @"NMaven.ProjectImporterEngine.exe " + " \"C:\\projects\\multi-module-csharp\\NMaven\\NMaven.sln\"");
+
+ }
+ else
+ {
+ NMavenImporter importer = new NMavenImporter(args);
+ importer.GeneratePom();
+ Console.WriteLine("Done Generating Project Poms....");
+
+
+ Console.WriteLine("Solution/Parent Pom: " + importer.GeneratedSolutionPomFile );
+
+ foreach(string pom in importer.GeneratedProjectPomFiles)
+ {
+ Console.WriteLine("Project Pom: " + pom);
+ }
+
+ }
+ Console.In.ReadLine();
+
+ }
+ }
+}
Added: incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/pom.xml?rev=673616&view=auto==============================================================================
--- incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/pom.xml (added)
+++ incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/pom.xml Thu Jul 3 01:27:01 2008
@@ -0,0 +1,67 @@
+<?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:xsi="
http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>NMaven.ProjectImporter</groupId>
+ <version>0.14-incubating-SNAPSHOT</version>
+ <artifactId>NMaven.ImporterProjectParent</artifactId>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>NMaven.ProjectImporter</groupId>
+ <artifactId>NMaven.ProjectImporterEngine</artifactId>
+ <version>0.14-incubating-SNAPSHOT</version>
+ <packaging>library</packaging>
+ <name>NMaven.ProjectImporterEngine</name>
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-webdav</artifactId>
+ <version>1.0-beta-2</version>
+ </extension>
+ </extensions>
+ <sourceDirectory>src/main/csharp</sourceDirectory>
+ <testSourceDirectory>src/test/csharp</testSourceDirectory>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.dotnet.plugins</groupId>
+ <artifactId>maven-compile-plugin</artifactId>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>src</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>NUnit</groupId>
+ <artifactId>NUnit.Framework</artifactId>
+ <type>library</type>
+ <version>2.2.8.0</version>
+ </dependency>
+ </dependencies>
+</project>
Added: incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Generator/BasePomGenerator.cs
URL:
http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Generator/BasePomGenerator.cs?rev=673616&view=auto==============================================================================
--- incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Generator/BasePomGenerator.cs (added)
+++ incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Generator/BasePomGenerator.cs Thu Jul 3 01:27:01 2008
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ */
+
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Xml;
+
+namespace NMaven.ProjectImporter.NMaven.Generator
+{
+ public abstract class BasePomGenerator
+ {
+ protected XmlTextWriter writer;
+ protected string pomFile;
+
+ public string PomFile
+ {
+ get { return this.pomFile; }
+ set { this.pomFile = value; }
+ }
+
+ protected void initXmlWriter(String xmlFile)
+ {
+ this.pomFile = xmlFile;
+ writer = new XmlTextWriter(xmlFile, null);
+ //writer.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
+ writer.Formatting = Formatting.Indented;
+ writer.Indentation = 2;
+ }
+
+ protected void writeElementString(XmlWriter writer, String element, String value)
+ {
+ writer.WriteStartElement(element);
+ writer.WriteString(value);
+ writer.WriteEndElement();
+ }
+
+ protected void writeAttributeString(XmlWriter writer, String prefix, String localName, String ns, String value)
+ {
+ writer.WriteAttributeString(prefix, localName, ns, value);
+ }
+
+ protected void populateProjectAttribute(XmlWriter writer)
+ {
+ writeAttributeString(writer, null, "xmlns", null, "
http://maven.apache.org/POM/4.0.0");
+ writeAttributeString(writer, "xmlns", "xsi", null, "
http://www.w3.org/2001/XMLSchema-instance");
+ writeAttributeString(writer, "xsi", "schemaLocation", null, "
http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd");
+ }
+ }
+}
Added: incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Generator/ProjectPomGenerator.cs
URL:
http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Generator/ProjectPomGenerator.cs?rev=673616&view=auto==============================================================================
--- incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Generator/ProjectPomGenerator.cs (added)
+++ incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Generator/ProjectPomGenerator.cs Thu Jul 3 01:27:01 2008
@@ -0,0 +1,165 @@
+/*
+ * 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.
+ */
+
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NMaven.ProjectImporter.NMaven.Model;
+using System.IO;
+using System.Xml;
+using NMaven.ProjectImporter.NMaven.util;
+using System.Collections.Specialized;
+using System.Xml.XPath;
+
+namespace NMaven.ProjectImporter.NMaven.Generator
+{
+ public class ProjectPomGenerator : BasePomGenerator
+ {
+ private Project project;
+
+ private Solution solution;
+
+ private String nmavenSettingsFile = Environment.GetEnvironmentVariable("USERPROFILE") + "/.m2/nmaven-settings.xml";
+
+
+ public ProjectPomGenerator(Project project, Solution solution)
+ {
+ this.project = project;
+ this.solution = solution;
+ initXmlWriter(project.PathOfProjectBaseDir + Path.DirectorySeparatorChar + "pom.xml");
+ //Console.WriteLine("writing..... " + project.PathOfProjectBaseDir + Path.DirectorySeparatorChar + "pom.xml");
+ Utility.log("writing..... " + project.PathOfProjectBaseDir + Path.DirectorySeparatorChar + "pom.xml");
+ }
+
+ public void generatePom() //preserved indention for readability
+ {
+
+ try
+ {
+ writer.WriteStartElement("project");
+ populateProjectAttribute(writer);
+
+
+ if (!Constants.SOLUTION_STRUCTURE_FLAT.Equals(solution.SolutionStructureType) && (project.ParentArtifactId != "" || project.ParentGroupId != ""))
+ {
+ writer.WriteStartElement("parent");
+ writeElementString(writer, Constants.ARTIFACT_ID, project.ParentArtifactId);
+ writeElementString(writer, Constants.GROUP_ID, project.ParentGroupId);
+ writeElementString(writer, Constants.VERSION, "1.0-SNAPSHOT");
+ writeElementString(writer, Constants.RELATIVE_PATH, project.RelativePath);
+ writer.WriteEndElement();
+ }
+
+ writeElementString(writer, Constants.MODEL_VERSION, "4.0.0");
+ writeElementString(writer, Constants.GROUP_ID, project.GroupId);
+ writeElementString(writer, Constants.ARTIFACT_ID, project.ArtifactId);
+ writeElementString(writer, Constants.VERSION, project.Version);
+
+ writer.WriteStartElement("packaging");
+ writer.WriteString( Utility.normalizePackaging (project.Packaging) );
+ writer.WriteEndElement();
+
+ writeElementString(writer, Constants.NAME, project.ArtifactId);
+
+ writer.WriteStartElement("build");
+ writeElementString(writer, Constants.SOURCE_DIRECTORY, project.SourceDirectory);
+
+ writer.WriteStartElement("plugins");
+ writer.WriteStartElement("plugin");
+ writeElementString(writer, Constants.GROUP_ID, "org.apache.maven.dotnet.plugins");
+ writeElementString(writer, Constants.ARTIFACT_ID, "maven-compile-plugin");
+ //if (project.ProjectFile.FullName.EndsWith(Constants.CSPROJ))
+ // {
+ writeElementString(writer, "extensions", "true");
+ //}
+ writeConfigurationElementString(writer, project.ProjectFile);
+ writer.WriteEndElement();
+ writer.WriteEndElement();
+ writer.WriteEndElement();
+
+ writeDependency(writer);
+
+ writer.WriteEndElement();
+ }
+ catch (Exception e)
+ {
+ //Console.WriteLine("exception occured writing pom.xml:" + Environment.NewLine + e.Message + Environment.NewLine + e.StackTrace);
+ Utility.log("exception occured writing pom.xml:" + Environment.NewLine + e.Message + Environment.NewLine + e.StackTrace);
+ }
+ finally
+ {
+ writer.Close();
+ }
+ }
+
+ private void writeConfigurationElementString(XmlTextWriter writer, FileInfo projectFile)
+ {
+ if (project.ProjectFile.FullName.EndsWith(Constants.VBPROJ))
+ {
+ writer.WriteStartElement("configuration");
+ writeElementString(writer, Constants.LANGUAGE, Constants.VB);
+ writer.WriteEndElement();
+ }
+ }
+
+ private void writeDependency(XmlTextWriter writer )
+ {
+ String installRoot = "";
+ String hintPath = "";
+
+ XPathDocument doc = new XPathDocument(nmavenSettingsFile);
+ XPathNavigator nav = doc.CreateNavigator();
+ nav = doc.CreateNavigator();
+
+ //Get the Active Compiler
+ XPathNodeIterator iterator = nav.Select("//nmavenSettings/vendors/vendor[./vendorName = //nmavenSettings/defaultSetup/vendorName and ./vendorVersion = //nmavenSettings/defaultSetup/vendorVersion]/frameworks/framework/installRoot");
+ if (iterator.MoveNext())
+ {
+ installRoot = iterator.Current.Value;
+ }
+
+ writer.WriteStartElement("dependencies");
+ foreach(String key in project.References.Keys)
+ {
+ hintPath = project.References[key];
+
+ // no hintpath info, point to active compiler, concat w/ the dll
+ if (hintPath == null || hintPath.Length == 0)
+ {
+ hintPath = installRoot + Path.DirectorySeparatorChar + key + ".dll";
+ }
+ writer.WriteStartElement("dependency");
+ writeElementString(writer, Constants.GROUP_ID, key);
+ writeElementString(writer, Constants.ARTIFACT_ID, key);
+ writeElementString(writer, Constants.VERSION, "1.0");
+ writeElementString(writer, Constants.SCOPE, "system");
+ writeElementString(writer, Constants.SYSTEM_PATH, hintPath );
+ writer.WriteEndElement();
+ }
+ foreach (String dependencySnippet in project.DependencySnippets)
+ {
+ writer.WriteRaw(dependencySnippet);
+ }
+
+ writer.WriteEndElement();
+ }
+ }
+
+}
Added: incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Generator/SolutionPomGenerator.cs
URL:
http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Generator/SolutionPomGenerator.cs?rev=673616&view=auto==============================================================================
--- incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Generator/SolutionPomGenerator.cs (added)
+++ incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Generator/SolutionPomGenerator.cs Thu Jul 3 01:27:01 2008
@@ -0,0 +1,120 @@
+/*
+ * 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.
+ */
+
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NMaven.ProjectImporter.NMaven.Model;
+using System.Xml;
+using System.IO;
+using System.Windows.Forms;
+using NMaven.ProjectImporter.NMaven.util;
+
+
+namespace NMaven.ProjectImporter.NMaven.Generator
+{
+ public class SolutionPomGenerator : BasePomGenerator
+ {
+ private Solution solution;
+
+ private Project[] projectArray;
+
+ public SolutionPomGenerator(Solution solution)
+ {
+ this.solution = solution;
+ ///writer = new XmlTextWriter(solution.SolutionFile.DirectoryName + Path.DirectorySeparatorChar + "pom.xml" , null);
+ initXmlWriter(solution.SolutionFile.DirectoryName + Path.DirectorySeparatorChar + "pom.xml");
+ }
+
+ public void generatePom()
+ {
+ if (projectArray == null) throw new Exception("projectArray should be initialized.");
+
+ String module = "";
+ try
+ {
+ writer.WriteStartElement("project");
+ populateProjectAttribute(writer);
+
+ writeElementString(writer, Constants.MODEL_VERSION, "4.0.0");
+ writeElementString(writer, Constants.GROUP_ID, solution.GroupId);
+ writeElementString(writer, Constants.ARTIFACT_ID, solution.ArtifactId);
+ writeElementString(writer, Constants.VERSION, "1.0-SNAPSHOT");
+ writeElementString(writer, Constants.PACKAGING, solution.Packaging);
+ writeElementString(writer, Constants.NAME, solution.ArtifactId);
+
+ writer.WriteStartElement("modules");
+ /*foreach (String key in solution.Projects.Keys)
+ {
+ writer.WriteStartElement("module");
+
+ module = normalizeModuleName(key, solution.Projects[key]);
+
+ writer.WriteString(module);
+ writer.WriteEndElement();
+ }*/
+
+ int i =0;
+ foreach (String key in solution.Projects.Keys)
+ {
+ writer.WriteStartElement("module");
+
+ module = normalizeModuleName(projectArray[i++].AssemblyName.ToLower(), solution.Projects[key].ToLower() );
+
+ writer.WriteString(module);
+ writer.WriteEndElement();
+ }
+
+ writer.WriteEndElement();
+
+ writer.WriteEndElement();
+ }
+ catch (Exception e)
+ {
+ //Console.WriteLine("exception occured writing pom.xml:" + Environment.NewLine + e.Message + Environment.NewLine + e.StackTrace);
+ Utility.log("exception occured writing pom.xml:" + Environment.NewLine + e.Message + Environment.NewLine + e.StackTrace);
+ }
+ finally
+ {
+ writer.Close();
+ }
+ }
+
+ /*
+ *
+ */
+ private String normalizeModuleName(String projectName, String pathOfProjFile)
+ {
+ String temp = pathOfProjFile;
+ int indexProject = temp.IndexOf(projectName);
+
+ int totalLength = indexProject + projectName.Length;
+
+ return pathOfProjFile.Substring(0, totalLength);
+ }
+
+ public Project[] ProjectArray
+ {
+ get { return projectArray; }
+ set { projectArray = value; }
+ }
+
+ }
+}
Added: incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Model/DefaultDOMElement.cs
URL:
http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Model/DefaultDOMElement.cs?rev=673616&view=auto==============================================================================
--- incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Model/DefaultDOMElement.cs (added)
+++ incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Model/DefaultDOMElement.cs Thu Jul 3 01:27:01 2008
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+
+namespace NMaven.ProjectImporter.NMaven.Parser
+{
+ public class DefaultDOMElement
+ {
+ private String tagName;
+ private String text;
+ private StringDictionary attributes;
+ private DefaultDOMElements childElements;
+
+
+ public DefaultDOMElement(String tagName)
+ {
+ this.tagName = tagName;
+ attributes = new StringDictionary();
+ childElements = new DefaultDOMElements();
+ this.text="";
+ }
+
+ public String TagName {
+ get {
+ return tagName;
+ }
+ set {
+ this.tagName = value;
+ }
+ }
+ public string Text {
+ get {
+ return text;
+ }
+ set {
+ this.text = value;
+ }
+ }
+
+ public DefaultDOMElements ChildElements {
+ get {
+ return this.childElements;
+ }
+ }
+ public StringDictionary Attributes {
+ get {
+ return this.attributes;
+ }
+ }
+ public String Attribute(String name) {
+ return (String) attributes[name];
+ }
+
+ public void setAttribute(String name, String value) {
+ attributes.Add(name, value);
+ }
+ }
+}
Added: incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Model/DefaultDOMElements.cs
URL:
http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Model/DefaultDOMElements.cs?rev=673616&view=auto==============================================================================
--- incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Model/DefaultDOMElements.cs (added)
+++ incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Model/DefaultDOMElements.cs Thu Jul 3 01:27:01 2008
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections;
+
+namespace NMaven.ProjectImporter.NMaven.Parser
+{
+ public class DefaultDOMElements: CollectionBase {
+ public DefaultDOMElements()
+ {
+ }
+ public void Add(DefaultDOMElement se) {
+ this.List.Add(se);
+ }
+ public DefaultDOMElement Item(int index) {
+ return (DefaultDOMElement) this.List[index];
+ }
+ public Object[] ToArray() {
+ Object[] ar = new Object[this.List.Count];
+ for (int i=0; i < this.List.Count; i++) {
+ ar[i] = this.List[i];
+ }
+ return ar;
+ }
+ }
+}
Added: incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Model/Project.cs
URL:
http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Model/Project.cs?rev=673616&view=auto==============================================================================
--- incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Model/Project.cs (added)
+++ incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Model/Project.cs Thu Jul 3 01:27:01 2008
@@ -0,0 +1,165 @@
+/*
+ * 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.
+ */
+
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Collections.Specialized;
+using System.IO;
+
+namespace NMaven.ProjectImporter.NMaven.Model
+{
+ public class Project
+ {
+ private String rootNameSpace;
+ private String assemblyName;
+ private String packaging;
+
+ private String groupId;
+ private String artifactId;
+ private String parentGroupId;
+ private String parentArtifactId;
+ private String parentVersion;
+ private String sourceDirectory;
+ private StringDictionary references;
+ private List<String> dependencySnippets = new List<String>();
+
+ private FileInfo projectFile; //the csproj file
+
+ private String pathOfProjectBaseDir;
+
+ private String version;
+
+ private String relativePath;
+
+ public String RelativePath
+ {
+ get { return relativePath; }
+ set { relativePath = value; }
+ }
+
+ public List<String> DependencySnippets
+ {
+ get { return dependencySnippets; }
+ }
+
+ public void addDependencySnippet (String dependencySnippet)
+ {
+ dependencySnippets.Add(dependencySnippet);
+ }
+
+ public String Version
+ {
+ get { return version; }
+ set { version = value; }
+ }
+
+
+ public String PathOfProjectBaseDir
+ {
+ get { return pathOfProjectBaseDir; }
+ set { pathOfProjectBaseDir = value; }
+ }
+
+
+ public FileInfo ProjectFile
+ {
+ get { return projectFile; }
+ set { projectFile = value; }
+ }
+
+ public Project()
+ {
+ references = new StringDictionary();
+ }
+
+ public void addReference (String name, String value)
+ {
+ references.Add(name, value );
+ }
+
+ public StringDictionary References
+ {
+ get { return references; }
+ }
+
+ public String SourceDirectory
+ {
+ get { return sourceDirectory; }
+ set { sourceDirectory = value; }
+ }
+
+ public String ParentVersion
+ {
+ get { return parentVersion; }
+ set { parentVersion = value; }
+ }
+
+
+ public String ParentArtifactId
+ {
+ get { return parentArtifactId; }
+ set { parentArtifactId = value; }
+ }
+
+
+ public String ParentGroupId
+ {
+ get { return parentGroupId; }
+ set { parentGroupId = value; }
+ }
+
+
+ public String ArtifactId
+ {
+ get { return artifactId; }
+ set { artifactId = value; }
+ }
+
+
+ public String GroupId
+ {
+ get { return groupId; }
+ set { groupId = value; }
+ }
+
+
+ public String Packaging
+ {
+ get { return packaging; }
+ set { packaging = value; }
+ }
+
+
+ public String AssemblyName
+ {
+ get { return assemblyName; }
+ set { assemblyName = value; }
+ }
+
+
+ public String RootNameSpace
+ {
+ get { return rootNameSpace; }
+ set { rootNameSpace = value; }
+ }
+
+ }
+}
Added: incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Model/Solution.cs
URL:
http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Model/Solution.cs?rev=673616&view=auto==============================================================================
--- incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Model/Solution.cs (added)
+++ incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Model/Solution.cs Thu Jul 3 01:27:01 2008
@@ -0,0 +1,108 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Collections.Specialized;
+using System.IO;
+
+namespace NMaven.ProjectImporter.NMaven.Model
+{
+ public class Solution
+ {
+ public const String POM = "pom";
+ public const String DEFAULT_GROUP_ID = "com.mydefault.group";
+
+ private StringDictionary projects;
+ private String artifactId;
+ private String groupId;
+ private String packaging = POM;
+ private String version;
+
+ // derived field(s)
+ private String solutionStructureType;
+
+
+ public String SolutionStructureType
+ {
+ get { return solutionStructureType; }
+ set { solutionStructureType = value; }
+ }
+
+ public String Version
+ {
+ get { return version; }
+ set { version = value; }
+ }
+
+ private FileInfo solutionFile; // the *.sln file
+
+
+ public Solution(FileInfo solutionFile): this(solutionFile,null, null)
+ {
+ }
+
+ public Solution(FileInfo solutionFile, String artifactId, String groupId)
+ {
+ this.artifactId = artifactId;
+ this.groupId = groupId;
+ this.solutionFile = solutionFile;
+ projects = new StringDictionary();
+
+ //populate GroupId/ArtifactID to default values
+ ArtifactId = solutionFile.Name;
+ GroupId = DEFAULT_GROUP_ID;
+ }
+
+ public void addProject(String projectName, String relativePath)
+ {
+ projects.Add(projectName, relativePath);
+ }
+
+ public String GroupId
+ {
+ get{return groupId;}
+ set{groupId=value;}
+ }
+
+ public StringDictionary Projects
+ {
+ get { return projects; }
+ }
+
+ public String ArtifactId
+ {
+ get { return artifactId; }
+ set { artifactId = value; }
+ }
+
+ public FileInfo SolutionFile
+ {
+ get { return solutionFile; }
+ set { solutionFile = value; }
+ }
+
+ public String Packaging
+ {
+ get { return packaging; }
+ //set { packaging = value; }
+ }
+ }
+}
Added: incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/NMavenImporter.cs
URL:
http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/NMavenImporter.cs?rev=673616&view=auto==============================================================================
--- incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/NMavenImporter.cs (added)
+++ incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/NMavenImporter.cs Thu Jul 3 01:27:01 2008
@@ -0,0 +1,285 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.Text;
+using System.Xml;
+using System.IO;
+using NMaven.ProjectImporter.NMaven.Parser;
+using NMaven.ProjectImporter.NMaven.Model;
+using NMaven.ProjectImporter.NMaven.Generator;
+using NMaven.ProjectImporter.NMaven.util;
+using System.Reflection;
+
+
+namespace NMaven.ProjectImporter.NMaven
+{
+ public class NMavenImporter
+ {
+ private string solutionFile;
+ private string generatedSolutionPomFile;
+ private string[] generatedProjectPomFiles;
+ private string defaultGroupId;
+
+ public string SolutionFile
+ {
+ get { return this.solutionFile; }
+ set { this.solutionFile = value; }
+ }
+
+ public string GeneratedSolutionPomFile
+ {
+ get { return this.generatedSolutionPomFile; }
+ }
+
+ public string[] GeneratedProjectPomFiles
+ {
+ get { return this.generatedProjectPomFiles; }
+ }
+
+ // mandatory arg : solution file
+ // non-mandatory arg: groupId ; "-DgroupId=<my.company>"
+ //
+ // TODO: put these in hashtable.
+ public NMavenImporter(String[] args)
+ {
+
+ foreach (String arg in args)
+ {
+ if (arg.EndsWith (".sln") )
+ {
+ this.solutionFile = arg;
+ }
+ if (arg.StartsWith("-DgroupId="))
+ {
+ this.defaultGroupId = getParamValue(arg);
+ }
+ }
+
+ initDefaultGroupId();
+ }
+
+ private void initDefaultGroupId()
+ {
+ String company = "my.company";
+
+ if (defaultGroupId == null)
+ {
+ defaultGroupId = company;
+ }
+ }
+
+ private String getParamValue(String param)
+ {
+ String[] a = param.Split("=".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
+ if (a.Length > 1)
+ return a[1];
+
+ return null;
+ }
+
+
+ public NMavenImporter()
+ {
+ this.solutionFile = null;
+ }
+
+ /* Determines if the solution is :
+ * a.) flat = sln and csproj/vbproj are on the same directory
+ * b.) multi-module = csproj/vbproj is located >= 1 directory level down from sln file
+ * c.) flat and multi-module = combination of a) and b)
+ */
+ private String getSolutionStructure(Solution solution)
+ {
+ Project[] projects = new Project[solution.Projects.Count];
+ StringCollection projectPaths = new StringCollection();
+
+ foreach (string key in solution.Projects.Keys)
+ {
+ if ( (! solution.Projects[key].Contains(""+Path.DirectorySeparatorChar) ) && solution.Projects.Count==1 )
+ {
+ return Constants.SOLUTION_STRUCTURE_FLAT;
+ }
+ else if ((!solution.Projects[key].Contains("" + Path.DirectorySeparatorChar)) && solution.Projects.Count > 1)
+ {
+ return Constants.SOLUTION_STRUCTURE_FLAT_AND_MULTI_MODULE;
+ }
+ }
+
+ return Constants.SOLUTION_STRUCTURE_MULTI_MODULE;
+
+
+ }
+
+ private Project getParentProjectForFlatAndMultiModule(Solution solution)
+ {
+ string projectFile = "";
+ XmlTextReader reader = null;
+ DefaultDOMParser domParser = null;
+ DefaultDOMElement element = null;
+ Project project = null;
+ ProjectTransformer transformer = null;
+ foreach (string key in solution.Projects.Keys)
+ {
+ if (!Utility.pathContainsDirectory(solution.Projects[key]))
+ {
+ if (!solution.SolutionFile.DirectoryName.EndsWith("" + Path.DirectorySeparatorChar))
+ {
+ projectFile = solution.SolutionFile.DirectoryName + Path.DirectorySeparatorChar + solution.Projects[key];
+ }
+ try
+ {
+ reader = new XmlTextReader(projectFile);
+ domParser = new DefaultDOMParser();
+ element = domParser.parse(reader);
+
+ transformer = new ProjectTransformer(projectFile, element, solution);
+ project = transformer.transformFile();
+ return project;
+ }
+ finally
+ {
+ reader.Close();
+ }
+
+ }
+ }
+ return null;
+ }
+
+ public void GeneratePom()
+ {
+ try
+ {
+ string projectFile = "";
+ ProjectTransformer transformer = null;
+ XmlTextReader reader = null;
+ DefaultDOMParser domParser = null;
+ Project project = null;
+ ProjectPomGenerator pomGenerator = null;
+ DefaultDOMElement element = null;
+
+ FileInfo file = new FileInfo(this.solutionFile);
+
+ DefaultSolutionParser solutionParser = new DefaultSolutionParser(file);
+ Solution solution = solutionParser.parse();
+
+ solution.SolutionStructureType = getSolutionStructure(solution);
+
+ solution.ArtifactId = file.Name.Replace(".sln", "") + "-" + Constants.PARENT;
+ solution.GroupId = defaultGroupId;
+
+
+ Project[] projects = new Project[solution.Projects.Count];
+ StringCollection projectPoms = new StringCollection();
+
+ Project parentProject = null;
+ if (solution.SolutionStructureType.Equals(Constants.SOLUTION_STRUCTURE_FLAT_AND_MULTI_MODULE))
+ {
+ parentProject = getParentProjectForFlatAndMultiModule(solution);
+ }
+
+ int i = 0;
+ foreach (string key in solution.Projects.Keys)
+ {
+ if (! solution.SolutionFile.DirectoryName.EndsWith(""+Path.DirectorySeparatorChar))
+ {
+ projectFile = solution.SolutionFile.DirectoryName + Path.DirectorySeparatorChar + solution.Projects[key];
+ }
+ try
+ {
+ reader = new XmlTextReader(projectFile);
+ domParser = new DefaultDOMParser();
+ element = domParser.parse(reader);
+
+ transformer = new ProjectTransformer(projectFile, element, solution);
+ project = transformer.transformFile();
+
+ //modify again parent infos for flat and flat_and_multi_module
+ if (Constants.SOLUTION_STRUCTURE_FLAT.Equals(solution.SolutionStructureType))
+
+ {
+ project.ParentArtifactId = "";
+ project.ParentGroupId = "";
+ }
+ else if (Constants.SOLUTION_STRUCTURE_FLAT_AND_MULTI_MODULE.Equals(solution.SolutionStructureType) &&
+ Utility.pathContainsDirectory(solution.Projects[key]))
+ {
+ project.ParentGroupId = parentProject.GroupId;
+ project.ParentArtifactId = parentProject.ArtifactId;
+ project.RelativePath = Utility.computeRelativePath(parentProject.ProjectFile.DirectoryName, project.ProjectFile.DirectoryName);
+ }
+
+ else if (Constants.SOLUTION_STRUCTURE_FLAT_AND_MULTI_MODULE.Equals(solution.SolutionStructureType) &&
+ ! Utility.pathContainsDirectory(solution.Projects[key]))
+ {
+ // parent project, set this to empty so it won't be generated
+ project.ParentGroupId = "";
+ project.ParentArtifactId = "";
+
+ }
+
+ //end
+
+ pomGenerator = new ProjectPomGenerator(project, solution);
+ pomGenerator.generatePom();
+
+ projectPoms.Add(pomGenerator.PomFile);
+ projects[i++] = project;
+
+ }
+ finally
+ {
+ reader.Close();
+ }
+ }
+
+ if ( Constants.SOLUTION_STRUCTURE_MULTI_MODULE.Equals(solution.SolutionStructureType))
+ {
+ generateSolutionPom(solution, projects);
+ }
+
+
+
+ generatedProjectPomFiles = new string[projectPoms.Count];
+ projectPoms.CopyTo(generatedProjectPomFiles, 0);
+
+
+ }
+ catch (Exception e)
+ {
+ //Console.WriteLine("ERROR : " + e.Message + Environment.NewLine + e.StackTrace);
+ Utility.log("ERROR : " + e.Message + Environment.NewLine + e.StackTrace);
+ }
+ }
+
+ private void generateSolutionPom(Solution solution, Project[] projects)
+ {
+ SolutionPomGenerator parentGenerator = new SolutionPomGenerator(solution);
+ parentGenerator.ProjectArray = projects;
+
+ parentGenerator.generatePom();
+
+ this.generatedSolutionPomFile = parentGenerator.PomFile;
+ }
+
+ }
+}
Added: incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Parser/DefaultDOMParser.cs
URL:
http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Parser/DefaultDOMParser.cs?rev=673616&view=auto==============================================================================
--- incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Parser/DefaultDOMParser.cs (added)
+++ incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Parser/DefaultDOMParser.cs Thu Jul 3 01:27:01 2008
@@ -0,0 +1,110 @@
+/*
+ * 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.
+ */
+
+
+using System;
+using System.IO;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Xml;
+
+namespace NMaven.ProjectImporter.NMaven.Parser
+{
+ public class DefaultDOMParser
+ {
+ private Stack elements;
+ private DefaultDOMElement currentElement;
+ private DefaultDOMElement rootElement;
+
+ public DefaultDOMParser()
+ {
+ elements = new Stack();
+ currentElement = null;
+ }
+
+ public DefaultDOMElement parse(XmlTextReader reader)
+ {
+ DefaultDOMElement defaultElement = null;
+ //this.reader = reader;
+
+
+ while (!reader.EOF)
+ {
+ reader.Read();
+ switch (reader.NodeType)
+ {
+ case XmlNodeType.Element:
+ defaultElement = new DefaultDOMElement(reader.LocalName);
+ currentElement = defaultElement;
+ if (elements.Count == 0)
+ {
+ rootElement = defaultElement;
+ elements.Push(defaultElement);
+ }
+ else
+ {
+ DefaultDOMElement parent = (DefaultDOMElement)elements.Peek();
+ parent.ChildElements.Add(defaultElement);
+
+ if (reader.IsEmptyElement) // do nothing for "<element/>" entry
+ {
+ if (reader.HasAttributes)
+ {
+ while (reader.MoveToNextAttribute())
+ {
+
+ currentElement.setAttribute(reader.Name, reader.Value);
+ }
+ }
+ }
+ else
+ {
+ elements.Push(defaultElement);
+ }
+ }
+ if (reader.HasAttributes)
+ {
+ while (reader.MoveToNextAttribute())
+ {
+
+ currentElement.setAttribute(reader.Name, reader.Value);
+ }
+ }
+ break;
+ case XmlNodeType.Attribute:
+ defaultElement.setAttribute(reader.Name, reader.Value);
+ break;
+ case XmlNodeType.EndElement:
+ elements.Pop();
+ break;
+ case XmlNodeType.Text:
+ currentElement.Text = reader.Value;
+ break;
+ case XmlNodeType.CDATA:
+ currentElement.Text = reader.Value;
+ break;
+ default:
+ // ignore
+ break;
+ }
+ }
+ return rootElement;
+ }
+ }
+}
Added: incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Parser/DefaultSolutionParser.cs
URL:
http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Parser/DefaultSolutionParser.cs?rev=673616&view=auto==============================================================================
--- incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Parser/DefaultSolutionParser.cs (added)
+++ incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.ProjectImporter/Engine/src/main/csharp/NMaven/Parser/DefaultSolutionParser.cs Thu Jul 3 01:27:01 2008
@@ -0,0 +1,111 @@
+/*
+ * 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.
+ */
+
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.IO;
+using NMaven.ProjectImporter.NMaven.Model;
+using System.Collections.Specialized;
+using NMaven.ProjectImporter.NMaven.util;
+
+namespace NMaven.ProjectImporter.NMaven.Parser
+{
+ public class DefaultSolutionParser
+ {
+ private Solution solution;
+
+ public DefaultSolutionParser(FileInfo file)
+ {
+ if (file == null) throw new NullReferenceException("file reference should not be null");
+
+ solution = new Solution(file);
+ }
+
+ public Solution parse()
+ {
+ return parse(solution.SolutionFile.FullName);
+ }
+
+ private Solution parse(String fileName)
+ {
+ String contents = File.ReadAllText(fileName);
+
+ String[] splitContents = contents.Split(new string[]{System.Environment.NewLine}, System.StringSplitOptions.RemoveEmptyEntries);
+
+ foreach (String anEntry in splitContents)
+ {
+
+ if (anEntry.StartsWith(Constants.PREFIX_PROJ_SLN_ID))
+ {
+ String[] projectEntry = processProjectLine(anEntry);
+
+ if (projectEntry[1].EndsWith("." + Constants.CSPROJ) ||projectEntry[1].EndsWith( "." + Constants.VBPROJ))
+ {
+ //Console.WriteLine("project found... ");
+ //Console.WriteLine(" projectName :" + projectEntry[0]);
+ //Console.WriteLine(" relativePath :" + projectEntry[1]);
+ Utility.log("project found... ");
+ Utility.log(" projectName :" + projectEntry[0]);
+ Utility.log(" relativePath :" + projectEntry[1]);
+ solution.addProject(projectEntry[0], projectEntry[1]);
+ }
+ else
+ {
+ Utility.log("ignoring.. ");
+ Utility.log(" projectName :" + projectEntry[0]);
+ Utility.log(" relativePath :" + projectEntry[1]);
+
+ }
+
+
+ }
+ }
+ return solution;
+ }
+
+