incubator-nmaven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r672971 - in /incubator/nmaven/branches/NMAVEN_0.14: assemblies/NMaven.Solution/ plugins/maven-compile-plugin/src/main/java/org/apache/maven/dotnet/plugin/compile/ plugins/netplugins/NMaven.Plugin.Solution/src/main/csharp/NMaven/Plugin/Solu...
Date Tue, 01 Jul 2008 01:39:34 GMT
Author: brett
Date: Mon Jun 30 18:39:33 2008
New Revision: 672971

URL: http://svn.apache.org/viewvc?rev=672971&view=rev
Log:
[NMAVEN-110] Ability to generate .vbproj files in the Solution generator
Submitted by: Maria Catherine Tan

Modified:
    incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.Solution/IProjectReference.cs
    incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.Solution/ProjectGeneratorImpl.cs
    incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.Solution/ProjectReferenceImpl.cs
    incubator/nmaven/branches/NMAVEN_0.14/plugins/maven-compile-plugin/src/main/java/org/apache/maven/dotnet/plugin/compile/TestSourceProcessorMojo.java
    incubator/nmaven/branches/NMAVEN_0.14/plugins/netplugins/NMaven.Plugin.Solution/src/main/csharp/NMaven/Plugin/Solution/SolutionMojo.cs

Modified: incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.Solution/IProjectReference.cs
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.Solution/IProjectReference.cs?rev=672971&r1=672970&r2=672971&view=diff
==============================================================================
--- incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.Solution/IProjectReference.cs
(original)
+++ incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.Solution/IProjectReference.cs
Mon Jun 30 18:39:33 2008
@@ -25,12 +25,12 @@
 namespace NMaven.Solution
 {
 	/// <summary>
-	/// Provides services for obtaining information about a project (.csproj) reference
+	/// Provides services for obtaining information about a project (.csproj or .vbproj) reference
 	/// </summary>
 	public interface IProjectReference
 	{
         		
-		FileInfo CSProjectFile
+		FileInfo ProjectFile
 		{
 			get;
 			set;

Modified: incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.Solution/ProjectGeneratorImpl.cs
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.Solution/ProjectGeneratorImpl.cs?rev=672971&r1=672970&r2=672971&view=diff
==============================================================================
--- incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.Solution/ProjectGeneratorImpl.cs
(original)
+++ incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.Solution/ProjectGeneratorImpl.cs
Mon Jun 30 18:39:33 2008
@@ -39,12 +39,22 @@
 	/// </summary>
 	internal sealed class ProjectGeneratorImpl : IProjectGenerator
 	{
+        private Dictionary<String, String> directoryToFileNameExtensionMapping;
+
+        private Dictionary<String, String> directoryToImportProject;
 		
         /// <summary>
         /// Constructor
         /// </summary>
 		internal ProjectGeneratorImpl()
 		{
+            directoryToFileNameExtensionMapping = new Dictionary<string,string>();
+            directoryToFileNameExtensionMapping.Add("csharp", ".csproj");
+            directoryToFileNameExtensionMapping.Add("vb", ".vbproj");
+
+            directoryToImportProject = new Dictionary<string, string>();
+            directoryToImportProject.Add("csharp", @"$(MSBuildBinPath)\Microsoft.CSharp.Targets");
+            directoryToImportProject.Add("vb", @"$(MSBuildBinPath)\Microsoft.VisualBasic.Targets");
 		}
 		
 	    public IProjectReference GenerateProjectFor(NMaven.Model.Pom.Model model, 
@@ -68,11 +78,12 @@
 			                                         @"..\..\..\target\obj\",
 			                                         projectReferences,
 			                                         localRepository);
-			FileInfo fileInfo = new FileInfo(sourceFileDirectory.FullName + @"\" + projectFileName
+ ".csproj");
+            String fileNameExtension = directoryToFileNameExtensionMapping[sourceFileDirectory.Name];
+            FileInfo fileInfo = new FileInfo(sourceFileDirectory.FullName + @"\" + projectFileName
+ fileNameExtension);
 		    project.Save(fileInfo.FullName);
 
             IProjectReference projectReference = Factory.createDefaultProjectReference();
-		    projectReference.CSProjectFile = fileInfo;
+		    projectReference.ProjectFile = fileInfo;
 		    projectReference.ProjectGuid = projectGuid;
 		    projectReference.ProjectName = projectFileName;
 			return projectReference;	    	
@@ -90,12 +101,23 @@
 			Guid solutionGuid = Guid.NewGuid();
 			foreach(IProjectReference projectReference in projectReferences) 
 			{
-				writer.Write("Project(\"{");
-				writer.Write("FAE04EC0-301F-11D3-BF4B-00C04F79EFBC");
+                string projectType = null;
+                string projectFileExtension = projectReference.ProjectFile.Extension;
+                if (projectFileExtension == ".csproj")
+                {
+                    projectType = "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC";
+                }
+                else if (projectFileExtension == ".vbproj")
+                {
+                    projectType = "F184B08F-C81C-45F6-A57F-5ABD9991F28F";
+                }
+
+                writer.Write("Project(\"{");
+                writer.Write(projectType);
 				writer.Write("}\") = \"");
 				writer.Write(projectReference.ProjectName);
 				writer.Write("\", \"");
-				writer.Write(projectReference.CSProjectFile.FullName);
+				writer.Write(projectReference.ProjectFile.FullName);
 				writer.Write("\", \"{");
 				writer.Write(projectReference.ProjectGuid.ToString());
 				writer.WriteLine("}\"");
@@ -142,9 +164,11 @@
             Engine engine = new Engine(Environment.GetEnvironmentVariable("SystemRoot") +
@"\Microsoft.NET\Framework\v2.0.50727");
             Project project = new Project(engine);
 
+            string outputType = GetOutputType(model.packaging, "test".Equals(sourceFileDirectory.Parent.Name));
+
             Console.WriteLine("ProjectGuid = " + projectGuid.ToString() + ", RootNameSpace
= " +
                 model.groupId + ", AssemblyName = " + assemblyName + ", BaseIntPath = " +
-                baseIntermediateOutputPath + ", OutputType = " + GetOutputType(model.packaging)
+ 
+                baseIntermediateOutputPath + ", OutputType = " + outputType + 
                 ", Packaging = " + model.packaging);
             //Main Properties
             BuildPropertyGroup groupProject = project.AddNewPropertyGroup(false);
@@ -154,14 +178,14 @@
             groupProject.AddNewProperty("RootNameSpace", model.groupId);
             groupProject.AddNewProperty("AssemblyName", assemblyName);
             groupProject.AddNewProperty("BaseIntermediateOutputPath", baseIntermediateOutputPath);
-            groupProject.AddNewProperty("OutputType", GetOutputType(model.packaging));
+            groupProject.AddNewProperty("OutputType", outputType);
             
             //Debug Properties
             groupProject = project.AddNewPropertyGroup(false);
             buildProperty.Condition = " '$(Configuration)' == '' ";
             groupProject.AddNewProperty( "OutputPath", assemblyOutputPath, false);
-            
-            project.AddNewImport(@"$(MSBuildBinPath)\Microsoft.CSharp.Targets", null);
+
+            project.AddNewImport(directoryToImportProject[sourceFileDirectory.Name], null);
             DirectoryInfo configDirectory = new DirectoryInfo(Environment.CurrentDirectory
+ @"\src\main\config");
             if(configDirectory.Exists)
             {
@@ -187,7 +211,7 @@
 			BuildItemGroup itemGroup = project.AddNewItemGroup();
 			foreach(IProjectReference projectReference in projectReferences)
 			{
-				BuildItem buildItem = itemGroup.AddNewItem("ProjectReference", projectReference.CSProjectFile.FullName);
+				BuildItem buildItem = itemGroup.AddNewItem("ProjectReference", projectReference.ProjectFile.FullName);
 				buildItem.SetMetadata("Project", "{" + projectReference.ProjectGuid.ToString() + "}");
 				buildItem.SetMetadata("Name", projectName);		
 			}
@@ -313,15 +337,15 @@
             }
 		}
 		
-		private String GetOutputType(String type)
-		{
-			if (type.Equals("library") || type.Equals("netplugin") || type.Equals("visual-studio-addin")
+		private String GetOutputType(String type,bool isATest)
+        {
+            if (type.Equals("library") || type.Equals("netplugin") || type.Equals("visual-studio-addin")
                 || type.Equals("sharp-develop-addin") || type.Equals("nar")) return "Library";
-			else if (type.Equals("exe")) return "Exe";
-			else if (type.Equals("winexe")) return "WinExe";
-			else if (type.Equals("module")) return "Module";
-			return null;
-		}
+            else if (type.Equals("exe")) return isATest ? "Library" : "Exe";
+            else if (type.Equals("winexe")) return "WinExe";
+            else if (type.Equals("module")) return "Module";
+            return null;
+        }
 		
 		private String GetExtension(String type)
 		{

Modified: incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.Solution/ProjectReferenceImpl.cs
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.Solution/ProjectReferenceImpl.cs?rev=672971&r1=672970&r2=672971&view=diff
==============================================================================
--- incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.Solution/ProjectReferenceImpl.cs
(original)
+++ incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.Solution/ProjectReferenceImpl.cs
Mon Jun 30 18:39:33 2008
@@ -30,7 +30,7 @@
 	internal sealed class ProjectReferenceImpl : IProjectReference
 	{
 		
-		private FileInfo csProjFile;
+		private FileInfo projFile;
 		
 		private string projectName;
 		
@@ -40,16 +40,16 @@
 		{
 		}
 		
-		public FileInfo CSProjectFile
+		public FileInfo ProjectFile
 		{
 			get
 			{
-				return csProjFile;	
+				return projFile;	
 			}
 			
 			set
 			{
-				csProjFile = value;	
+				projFile = value;	
 			}
 		}
 		

Modified: incubator/nmaven/branches/NMAVEN_0.14/plugins/maven-compile-plugin/src/main/java/org/apache/maven/dotnet/plugin/compile/TestSourceProcessorMojo.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN_0.14/plugins/maven-compile-plugin/src/main/java/org/apache/maven/dotnet/plugin/compile/TestSourceProcessorMojo.java?rev=672971&r1=672970&r2=672971&view=diff
==============================================================================
--- incubator/nmaven/branches/NMAVEN_0.14/plugins/maven-compile-plugin/src/main/java/org/apache/maven/dotnet/plugin/compile/TestSourceProcessorMojo.java
(original)
+++ incubator/nmaven/branches/NMAVEN_0.14/plugins/maven-compile-plugin/src/main/java/org/apache/maven/dotnet/plugin/compile/TestSourceProcessorMojo.java
Mon Jun 30 18:39:33 2008
@@ -77,6 +77,7 @@
         List<String> excludeList = new ArrayList<String>();
         excludeList.add( "*.suo" );
         excludeList.add( "*.csproj" );
+        excludeList.add( "*.vbproj" );
         excludeList.add( "*.sln" );
         excludeList.add( "obj/**" );
         for ( int i = 0; i < testExcludes.length; ++i )

Modified: incubator/nmaven/branches/NMAVEN_0.14/plugins/netplugins/NMaven.Plugin.Solution/src/main/csharp/NMaven/Plugin/Solution/SolutionMojo.cs
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN_0.14/plugins/netplugins/NMaven.Plugin.Solution/src/main/csharp/NMaven/Plugin/Solution/SolutionMojo.cs?rev=672971&r1=672970&r2=672971&view=diff
==============================================================================
--- incubator/nmaven/branches/NMAVEN_0.14/plugins/netplugins/NMaven.Plugin.Solution/src/main/csharp/NMaven/Plugin/Solution/SolutionMojo.cs
(original)
+++ incubator/nmaven/branches/NMAVEN_0.14/plugins/netplugins/NMaven.Plugin.Solution/src/main/csharp/NMaven/Plugin/Solution/SolutionMojo.cs
Mon Jun 30 18:39:33 2008
@@ -99,35 +99,41 @@
 			} 
 			else
 			{
-				IProjectReference mainProjectReference = null;
-				if(new DirectoryInfo(currentDirectory.FullName + @"\src\main\csharp\").Exists)
-				{
-					mainProjectReference = 
-			 			projectGenerator.GenerateProjectFor(model,
-			 	                                    new DirectoryInfo(currentDirectory.FullName + @"\src\main\csharp\"),
-			 	                                    model.artifactId, null, new DirectoryInfo(localRepository));
-					Console.WriteLine("NMAVEN-000-000: Generated project: File Name = "
-					                  + mainProjectReference.CSProjectFile.FullName);
-					projectReferences.Add(mainProjectReference);
-				}
-				if(new DirectoryInfo( currentDirectory.FullName + @"\src\test\csharp\").Exists)
-				{
-					List<IProjectReference> mainRef = new List<IProjectReference>();
-					if(mainProjectReference != null)
-					{
-						mainRef.Add(mainProjectReference);
-					}
-					IProjectReference projectReference = 
-			 			projectGenerator.GenerateProjectFor(model,
-			 	                                    new DirectoryInfo(currentDirectory.FullName + @"\src\test\csharp\"),
-			 	                                    model.artifactId + "-Test", mainRef, new DirectoryInfo(localRepository));
-					Console.WriteLine("NMAVEN-000-000: Generated test project: File Name = "
-					                  + projectReference.CSProjectFile.FullName);
-					projectReferences.Add(projectReference);					
-				}
+                createMainAndTestProjectFiles(currentDirectory, model, projectReferences,
projectGenerator, "csharp");
+                createMainAndTestProjectFiles(currentDirectory, model, projectReferences,
projectGenerator, "vb");
 			}	
 			return projectReferences;
 		}
+
+        private void createMainAndTestProjectFiles(DirectoryInfo currentDirectory, NMaven.Model.Pom.Model
model, List<IProjectReference> projectReferences, IProjectGenerator projectGenerator,
string projType)
+        {
+            IProjectReference mainProjectReference = null;
+            if (new DirectoryInfo(currentDirectory.FullName + @"\src\main\" + projType +
@"\").Exists)
+            {
+                mainProjectReference =
+                    projectGenerator.GenerateProjectFor(model,
+                                                new DirectoryInfo(currentDirectory.FullName
+ @"\src\main\" + projType + @"\"),
+                                                model.artifactId, null, new DirectoryInfo(localRepository));
+                Console.WriteLine("NMAVEN-000-000: Generated project: File Name = "
+                                  + mainProjectReference.ProjectFile.FullName);
+                projectReferences.Add(mainProjectReference);
+            }
+            if (new DirectoryInfo(currentDirectory.FullName + @"\src\test\" + projType +
@"\").Exists)
+            {
+                List<IProjectReference> mainRef = new List<IProjectReference>();
+                if (mainProjectReference != null)
+                {
+                    mainRef.Add(mainProjectReference);
+                }
+                IProjectReference projectReference =
+                    projectGenerator.GenerateProjectFor(model,
+                                                new DirectoryInfo(currentDirectory.FullName
+ @"\src\test\" + projType + @"\"),
+                                                model.artifactId + "-Test", mainRef, new
DirectoryInfo(localRepository));
+                Console.WriteLine("NMAVEN-000-000: Generated test project: File Name = "
+                                  + projectReference.ProjectFile.FullName);
+                projectReferences.Add(projectReference);
+            }
+        }
 		
 		private string GetArgFor(string name, string[] args)
 		{



Mime
View raw message