incubator-nmaven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sisb...@apache.org
Subject svn commit: r509334 [1/3] - in /incubator/nmaven/branches/SI_IDE/assemblies: ./ NMaven.Core/ NMaven.Core/src/ NMaven.Core/src/main/ NMaven.Core/src/main/csharp/ NMaven.Core/src/main/csharp/Core/ NMaven.Core/src/main/csharp/Core/Impl/ NMaven.Core/src/te...
Date Mon, 19 Feb 2007 21:10:31 GMT
Author: sisbell
Date: Mon Feb 19 13:10:29 2007
New Revision: 509334

URL: http://svn.apache.org/viewvc?view=rev&rev=509334
Log:
First Version of the IDE: pom.xml to csproj converter. Does the basics such as setting up
the folders, pom dependencies, etc. Still has some hard-coded values and needs a lot more
work. Did this in .NET since the MS Project structure already has object bindings and .NET
has good support for binding the Maven pom.

Added:
    incubator/nmaven/branches/SI_IDE/assemblies/
    incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/
    incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/pom.xml   (with props)
    incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/src/
    incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/src/main/
    incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/src/main/csharp/
    incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/src/main/csharp/Core/
    incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/src/main/csharp/Core/Impl/
    incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/src/main/csharp/Core/Impl/NMavenContextImpl.cs
    incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/src/main/csharp/Core/NMavenContext.cs
    incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/src/test/
    incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/src/test/csharp/
    incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/src/test/csharp/NMaven/
    incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/src/test/csharp/NMaven/Core/
    incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/src/test/csharp/NMaven/Core/NMavenContextImplTest.cs
    incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Model/
    incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Model/Pom/
    incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Model/Pom/Pom.xsd   (with props)
    incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Model/Pom/pom.xml   (with props)
    incubator/nmaven/branches/SI_IDE/assemblies/pom.xml   (with props)

Added: incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/pom.xml?view=auto&rev=509334
==============================================================================
--- incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/pom.xml (added)
+++ incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/pom.xml Mon Feb 19 13:10:29 2007
@@ -0,0 +1,40 @@
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>NMaven.Core</groupId>
+  <artifactId>NMaven.Core</artifactId>
+  <packaging>library</packaging>
+  <version>0.14</version>
+  <name>NMaven.Core</name>
+  <dependencies>
+    <dependency>
+      <groupId>NMaven.Model</groupId>
+      <artifactId>NMaven.Model.Pom</artifactId>
+      <type>library</type>
+      <version>0.14</version>
+    </dependency>
+    <dependency>
+      <groupId>Microsoft.Build.Engine</groupId>
+      <artifactId>Microsoft.Build.Engine</artifactId>
+      <type>gac</type>
+      <version>2.0.0.0__b03f5f7f11d50a3a</version>
+    </dependency>
+    <dependency>
+      <groupId>org.nunit</groupId>
+      <artifactId>nunit.framework</artifactId>
+      <version>2.2.8.0</version>
+      <type>library</type>
+    </dependency>
+  </dependencies>
+  <build>
+    <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>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file

Propchange: incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/src/main/csharp/Core/Impl/NMavenContextImpl.cs
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/src/main/csharp/Core/Impl/NMavenContextImpl.cs?view=auto&rev=509334
==============================================================================
--- incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/src/main/csharp/Core/Impl/NMavenContextImpl.cs
(added)
+++ incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/src/main/csharp/Core/Impl/NMavenContextImpl.cs
Mon Feb 19 13:10:29 2007
@@ -0,0 +1,124 @@
+using System;
+using System.IO;
+using System.Xml.Serialization;
+using NMaven.Model;
+using NMaven.Core;
+using Microsoft.Build.BuildEngine;
+
+namespace NMaven.Core.Impl {
+
+	public class NMavenContextImpl : NMavenContext
+	{
+		private string localRepository;
+		
+		private string basedir;
+		
+		public NMaven.Model.Model createPomModelFor(string fileName)
+		{
+			TextReader reader = new StreamReader(fileName);
+		    XmlSerializer serializer = new XmlSerializer(typeof(NMaven.Model.Model));
+			return (NMaven.Model.Model) serializer.Deserialize(reader);	
+		}
+		
+		public Project createProjectFor(string fileName) 
+		{
+            Engine engine = new Engine(@"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727");
+            Project project = new Project(engine);
+            project.Load(@fileName);
+            return project;
+		}
+		
+		private void addFoldersToProject(Project project, BuildItemGroup folderGroup, DirectoryInfo
rootDirectoryInfo) 
+		{
+			DirectoryInfo sourcedir = new DirectoryInfo(basedir + @"src\main\csharp");
+            DirectoryInfo[] directoryInfos = rootDirectoryInfo.GetDirectories();
+            if(directoryInfos != null && directoryInfos.Length > 0)
+            {
+            	if(folderGroup == null) folderGroup = project.AddNewItemGroup();
+            	
+            	foreach(DirectoryInfo di in directoryInfos) 
+            	{
+            		folderGroup.AddNewItem("Folder", di.FullName.Substring(sourcedir.FullName.Length
+ 1));
+                	addFoldersToProject(project, folderGroup, di);
+            	}           	
+            }			
+		}
+		
+		private void addClassFilesToProject(Project project, BuildItemGroup compileGroup, DirectoryInfo
rootDirectoryInfo) 
+		{
+			DirectoryInfo sourcedir = new DirectoryInfo(basedir + @"src\main\csharp");
+            DirectoryInfo[] directoryInfos = rootDirectoryInfo.GetDirectories();
+            if(directoryInfos != null && directoryInfos.Length > 0)
+            {
+            	if(compileGroup == null) compileGroup = project.AddNewItemGroup();
+            	
+            	foreach(DirectoryInfo di in directoryInfos) 
+            	{  
+	            	foreach(FileInfo fileInfo in di.GetFiles()) 
+	            	{
+	            		BuildItem buildItem = 
+	            			compileGroup.AddNewItem("Compile", 
+	            			                        fileInfo.FullName.Substring(sourcedir.FullName.Length
+ 1));
+	            		buildItem.SetMetadata("Link", fileInfo.FullName.Substring(sourcedir.FullName.Length
+ 1));
+	            	}            		
+                	addClassFilesToProject(project, compileGroup, di);
+            	}           	
+            }				
+		}
+		
+		private string getOutputType(String type)
+		{
+			if (type.Equals("library")) return "Library";
+			else if (type.Equals("exe")) return "Exe";
+			else if (type.Equals("winexe")) return "WinExe";
+			return null;
+		}
+		
+		public Project getProjectFromPomModel(NMaven.Model.Model model)
+		{
+            Engine engine = new Engine(@"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727");
+            Project project = new Project(engine);
+            
+            //Main Properties
+            BuildPropertyGroup groupProject = project.AddNewPropertyGroup(false);
+            BuildProperty buildProperty = groupProject.AddNewProperty("Configuration", "Debug");
+            buildProperty.Condition = " '$(Configuration)' == '' ";
+            groupProject.AddNewProperty("RootNameSpace", model.groupId);
+            groupProject.AddNewProperty("AssemblyName", model.artifactId);
+            groupProject.AddNewProperty("OutputType", getOutputType(model.packaging));
+            
+            //Debug Properties
+            groupProject = project.AddNewPropertyGroup(false);
+            buildProperty.Condition = " '$(Configuration)' == '' ";
+            groupProject.AddNewProperty( "OutputPath", @"..\..\..\target\main\bin\Debug\",
false);
+            
+            project.AddNewImport(@"$(MSBuildBinPath)\Microsoft.CSharp.Targets", null);
+
+            DirectoryInfo rootDirectoryInfo = new DirectoryInfo(basedir + @"src\main\csharp");
           
+            addFoldersToProject(project, null, rootDirectoryInfo);
+            addClassFilesToProject(project, null, rootDirectoryInfo);
+            
+			BuildItemGroup group = project.AddNewItemGroup();
+			foreach(Dependency dependency in model.dependencies) {
+				String repoPath = @localRepository + dependency.groupId.Replace(".", "\\")
+					+ "\\" + dependency.artifactId + "\\" + dependency.version + "\\" + dependency.artifactId
+ ".dll";
+				BuildItem buildItem = group.AddNewItem("Reference", dependency.artifactId);
+				if(!dependency.GetType().Equals("gac")) buildItem.SetMetadata("HintPath", repoPath, true);
+			}
+			
+			return project;
+			
+		}
+		
+		public void init(string localRepository) 
+		{
+			this.localRepository = localRepository;	
+			this.basedir =  new DirectoryInfo(Environment.CurrentDirectory).Parent.Parent.Parent.Parent.FullName
+ @"\";
+		}
+		
+		private class ClassParser {
+			
+		
+		}
+	}
+}

Added: incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/src/main/csharp/Core/NMavenContext.cs
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/src/main/csharp/Core/NMavenContext.cs?view=auto&rev=509334
==============================================================================
--- incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/src/main/csharp/Core/NMavenContext.cs
(added)
+++ incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/src/main/csharp/Core/NMavenContext.cs
Mon Feb 19 13:10:29 2007
@@ -0,0 +1,18 @@
+using System;
+using System.IO;
+using NMaven.Model;
+using Microsoft.Build.BuildEngine;
+
+namespace NMaven.Core {
+
+	public interface NMavenContext
+	{
+		NMaven.Model.Model createPomModelFor(string fileName);
+		
+		Project createProjectFor(string fileName);		
+		
+		Project getProjectFromPomModel(NMaven.Model.Model model);
+		
+		void init(string localRepository);
+	}
+}

Added: incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/src/test/csharp/NMaven/Core/NMavenContextImplTest.cs
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/src/test/csharp/NMaven/Core/NMavenContextImplTest.cs?view=auto&rev=509334
==============================================================================
--- incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/src/test/csharp/NMaven/Core/NMavenContextImplTest.cs
(added)
+++ incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Core/src/test/csharp/NMaven/Core/NMavenContextImplTest.cs
Mon Feb 19 13:10:29 2007
@@ -0,0 +1,34 @@
+/*
+ * Created by SharpDevelop.
+ * User: shane
+ * Date: 2/17/2007
+ * Time: 11:41 PM
+ * 
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+
+using NUnit.Framework;
+using System;
+using NMaven.Core.Impl;
+using NMaven.Model;
+using Microsoft.Build.BuildEngine;
+
+namespace NMaven.Core
+{
+	[TestFixture]
+	public class TestNMavenContextImplTest
+	{
+		[Test]
+		public void TestMethod()
+		{
+		/*
+			NMavenContext nmavenContext = new NMavenContextImpl();
+			nmavenContext.init(@"C:\Documents and Settings\shane\.m2\repository\");
+
+			NMaven.Model.Model model = nmavenContext.createPomModelFor(@"..\..\..\..\pom.xml");
+			Project project = nmavenContext.getProjectFromPomModel(model);
+			project.Save(@"C:\Documents and Settings\shane\nmaven-apache\SI_IDE\assemblies\NMaven.Core\src\main\csharp\sample3.csproj");
+						*/
+		}
+	}
+}



Mime
View raw message