public override void ConvertProjectToPomModel(bool writePom, string scmTag) { // just call the base, but dont write it we still need some minor adjustments for it base.ConvertProjectToPomModel(false, scmTag); List <string> goals = new List <string>(); goals.Add("assemble-package-files"); goals.Add("process-configs"); goals.Add("create-package"); Plugin plugin = AddPlugin("org.apache.npanday.plugins", "application-maven-plugin", null, false); AddPluginExecution(plugin, "package-application", goals.ToArray(), null); if (projectDigest.Contents.Length > 0) { AddPluginConfiguration(plugin, "mixinAssemblyComponentDescriptors", "mixinAssemblyComponentDescriptor", new string[] { "npanday-content.xml" }); WriteAssemblyDescriptor(new FileInfo(Path.GetDirectoryName(projectDigest.FullFileName) + @"\npanday-content.xml"), projectDigest.Contents); } if (writePom) { PomHelperUtility.WriteModelToPom(new FileInfo(Path.GetDirectoryName(projectDigest.FullFileName) + @"\pom.xml"), Model); } }
public override void ConvertProjectToPomModel(bool writePom, string scmTag) { // just call the base, but dont write it we still need some minor adjustments for it base.ConvertProjectToPomModel(false, scmTag); Model.packaging = "asp"; Model.build.sourceDirectory = "."; // change the outputDirectory of the plugin Plugin compilePlugin = PomHelperUtility.FindPlugin(model, "org.apache.npanday.plugins", "maven-compile-plugin"); AddPluginConfiguration(compilePlugin, "outputDirectory", "bin"); // Add NPanday compile plugin Plugin aspxPlugin = AddPlugin("org.apache.npanday.plugins", "maven-aspx-plugin"); if (!string.IsNullOrEmpty(projectDigest.TargetFramework)) { AddPluginConfiguration(aspxPlugin, "frameworkVersion", projectDigest.TargetFramework); } if (writePom) { PomHelperUtility.WriteModelToPom(new FileInfo(Path.GetDirectoryName(projectDigest.FullFileName) + @"\pom.xml"), Model); } }
public override void ConvertProjectToPomModel(bool writePom, string scmTag) { // relies on this being set everywhere - if it were set per project, this would need to be evaluated on the project references if (!projectDigest.UseMsDeploy) { throw new Exception("You must use Web Deploy 2.0 to package web applications when using Azure projects"); } GenerateHeader("azure-cloud-service"); //Add SCM Tag if (scmTag != null && scmTag != string.Empty && Model.parent == null) { Scm scmHolder = new Scm(); scmHolder.connection = string.Format("scm:svn:{0}", scmTag); scmHolder.developerConnection = string.Format("scm:svn:{0}", scmTag); scmHolder.url = scmTag; Model.scm = scmHolder; } // Add Com Reference Dependencies if (projectDigest.ComReferenceList.Length > 0) { AddComReferenceDependency(); } //Add Project WebReferences AddWebReferences(); //Add EmbeddedResources maven-resgen-plugin AddEmbeddedResources(); // Add Project Inter-dependencies foreach (ProjectReference projectRef in projectDigest.ProjectReferences) { AddProjectReference(projectRef); } // Add Project Reference Dependencies // override the one from the parent to add new types for Azure AddProjectReferenceDependenciesToList(); Plugin plugin = AddPlugin("org.apache.npanday.plugins", "azure-maven-plugin"); if (!string.IsNullOrEmpty(projectDigest.TargetFramework)) { AddPluginConfiguration(plugin, "frameworkVersion", projectDigest.TargetFramework); } else { // TODO: crude hack until the plugin doesn't require this and picks the right minimum default AddPluginConfiguration(plugin, "frameworkVersion", "4.0"); } if (writePom) { PomHelperUtility.WriteModelToPom(new FileInfo(Path.Combine(projectDigest.FullDirectoryName, "pom.xml")), Model); } }
public override void ConvertProjectToPomModel(bool writePom, string scmTag) { // just call the base, but dont write it we still need some minor adjustments for it base.ConvertProjectToPomModel(false, scmTag); List <string> goals = new List <string>(); goals.Add("assemble-package-files"); goals.Add("process-web-config"); Plugin aspnetPlugin = AddPlugin("org.apache.npanday.plugins", "aspnet-maven-plugin", null, false); AddPluginExecution(aspnetPlugin, "prepare-package", goals.ToArray(), null); // TODO: until XDT works, just use Web.config itself AddPluginConfiguration(aspnetPlugin, "webConfig", "Web.config"); Plugin msdeployPlugin = AddPlugin("org.apache.npanday.plugins", "msdeploy-maven-plugin", null, false); AddPluginExecution(msdeployPlugin, "create-msdeploy-package", new string[] { "create-package" }, null); if (writePom) { PomHelperUtility.WriteModelToPom(new FileInfo(Path.GetDirectoryName(projectDigest.FullFileName) + @"\pom.xml"), Model); } }
public static bool IsSameFile(string dir1, string dir2) { string str1 = PomHelperUtility.NormalizeFileToWindowsStyle(Path.GetFullPath(dir1)); string str2 = PomHelperUtility.NormalizeFileToWindowsStyle(Path.GetFullPath(dir2)); return(str1.Equals(str2, StringComparison.OrdinalIgnoreCase)); }
protected string GetSourceDir() { if (projectDigest.Compiles.Length == 0) { return("./"); } DirectoryInfo common = new DirectoryInfo(Path.GetDirectoryName(projectDigest.Compiles[0].IncludeFullPath)); foreach (Compile compile in projectDigest.Compiles) { DirectoryInfo srcInclude = new DirectoryInfo(Path.GetDirectoryName(compile.IncludeFullPath)); common = PomHelperUtility.GetCommonDirectory(common, srcInclude); } DirectoryInfo prjDir = new DirectoryInfo(Path.GetDirectoryName(projectDigest.FullFileName)); string srcDir = PomHelperUtility.GetRelativePath(prjDir, common); if (string.IsNullOrEmpty(srcDir)) { return("./"); } if (srcDir.Contains("..")) { return("./"); } return(srcDir); }
static bool IsProjectAnIntegrationTest(NPanday.Model.Pom.Model model) { Plugin plugin = PomHelperUtility.FindPlugin( model, "org.apache.npanday.plugins", "maven-test-plugin" ); if (plugin == null) { return(false); } foreach (XmlElement elem in (ICollection <XmlElement>)plugin.configuration.Any) { if ("integrationTest".Equals(elem.Name)) { if (string.IsNullOrEmpty(elem.InnerText)) { return(false); } return("true".Equals(elem.InnerText.Trim(), StringComparison.OrdinalIgnoreCase)); } } return(false); }
public void TestSetUp() { File.Copy(pomPath, pomCopyPath, true); File.Copy(pomPath2, pomCopyPath2, true); pomCopy = new PomHelperUtility(pomCopyPath); pomCopy2 = new PomHelperUtility(pomCopyPath2); }
public void TestSetUp() { pomPath = (new FileInfo(Directory.GetCurrentDirectory().Substring(0, Directory.GetCurrentDirectory().LastIndexOf("target")) + "\\src\\test\\resource\\ClassLibrary1\\ClassLibrary1\\pom.xml").FullName); pomCopyPath = pomPath.Replace("pom.xml", "pomCopy.xml"); pomCopy = new PomHelperUtility(pomCopyPath); File.Copy(pomPath, pomCopyPath); }
public NPandaySignAssembly(Project project, ArtifactContext container, FileInfo pom) { this.project = project; this.artifactContext = container; InitializeComponent(); this.pom = pom; this.pomUtility = new PomHelperUtility(pom); this.txtBrowseAssemblySignKey.Text = pomUtility.CompilerPluginConfigurationKeyfile; }
public RenameWebReferenceTest() { pomPath = (new FileInfo(Directory.GetCurrentDirectory().Substring(0, Directory.GetCurrentDirectory().LastIndexOf("target")) + "\\src\\test\\resource\\ClassLibrary1\\ClassLibrary1\\pom.xml").FullName); pomCopyPath = pomPath.Replace("pom.xml", "pomCopy.xml"); pomCopy = new PomHelperUtility(pomCopyPath); File.Copy(pomPath, pomCopyPath); fullPath = (new FileInfo(Directory.GetCurrentDirectory().Substring(0, Directory.GetCurrentDirectory().LastIndexOf("target")) + "\\src\\test\\resource\\ClassLibrary1\\ClassLibrary1\\Web References\\WebRef").FullName); fullPathCopy = fullPath.Replace(oldName, newName); path = "Web References\\" + oldName + "\\demoService.wsdl"; }
public override void ConvertProjectToPomModel(bool writePom, string scmTag) { // just call the base, but dont write it we still need some minor adjustments for it base.ConvertProjectToPomModel(false, scmTag); string profile = ".NETPortable," + projectDigest.TargetFrameworkProfile; Plugin compilePlugin = GetPlugin("org.apache.npanday.plugins", "maven-compile-plugin"); AddPluginConfiguration(compilePlugin, "profile", profile); if (writePom) { PomHelperUtility.WriteModelToPom(new FileInfo(Path.GetDirectoryName(projectDigest.FullFileName) + @"\pom.xml"), Model); } }
void addArtifactToPom(Artifact.Artifact artifact) { try { if (pom != null) { PomHelperUtility pomUtil = new PomHelperUtility(pom); pomUtil.AddPomDependency(artifact.GroupId, artifact.ArtifactId, artifact.Version); } } catch (Exception err) { MessageBox.Show(this, err.Message, "NPanday Add Dependency Warning:", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } }
public override void ConvertProjectToPomModel(bool writePom, string scmTag) { // just call the base, but dont write it we still need some minor adjustments for it base.ConvertProjectToPomModel(false, scmTag); List <string> goals = new List <string>(); goals.Add("assemble-package-files"); goals.Add("process-configs"); Plugin aspnetPlugin = AddPlugin("org.apache.npanday.plugins", "aspnet-maven-plugin", null, false); AddPluginExecution(aspnetPlugin, "prepare-package", goals.ToArray(), null); if (!string.IsNullOrEmpty(projectDigest.TargetFramework)) { AddPluginConfiguration(aspnetPlugin, "frameworkVersion", projectDigest.TargetFramework); } if (!string.IsNullOrEmpty(projectDigest.Configuration)) { AddPluginConfiguration(aspnetPlugin, "transformationHint", projectDigest.Configuration); } Plugin msdeployPlugin = AddPlugin("org.apache.npanday.plugins", "msdeploy-maven-plugin", null, false); AddPluginExecution(msdeployPlugin, "create-msdeploy-package", new string[] { "create-content-package" }, null); if (projectDigest.SilverlightApplicationList != null) { // add silverlight dependencies and copy them into the desired location foreach (SilverlightApplicationReference app in projectDigest.SilverlightApplicationList) { Dependency dep = CreateInterProjectDependency(app.Project.AssemblyName, app.Project); dep.type = "silverlight-application"; dep.scope = "runtime"; AddDependency(dep); } } if (writePom) { PomHelperUtility.WriteModelToPom(new FileInfo(Path.GetDirectoryName(projectDigest.FullFileName) + @"\pom.xml"), Model); } }
public override void ConvertProjectToPomModel(bool writePom, string scmTag) { GenerateHeader("asp"); Model.build.sourceDirectory = "."; if (scmTag != null && scmTag != string.Empty && Model.parent == null) { Scm scmHolder = new Scm(); scmHolder.connection = string.Format("scm:svn:{0}", scmTag); scmHolder.developerConnection = string.Format("scm:svn:{0}", scmTag); scmHolder.url = scmTag; Model.scm = scmHolder; } // Add NPanday compile plugin Plugin aspxPlugin = AddPlugin("org.apache.npanday.plugins", "maven-aspx-plugin"); if (!string.IsNullOrEmpty(projectDigest.TargetFramework)) { AddPluginConfiguration(aspxPlugin, "frameworkVersion", projectDigest.TargetFramework); } //Add Project WebReferences //AddWebReferences(); // Add Project Inter-dependencies //AddInterProjectDependenciesToList(); // Add Project Reference Dependencies //AddProjectReferenceDependenciesToList(); if (writePom) { PomHelperUtility.WriteModelToPom(new FileInfo(Path.Combine(projectDigest.FullDirectoryName, "pom.xml")), Model); } }
protected void GenerateHeader(string packaging) { // Add Parent Header if (parent != null) { model.parent = new NPanday.Model.Pom.Parent(); model.parent.artifactId = FilterID(parent.artifactId); model.parent.groupId = FilterID(parent.groupId); model.parent.version = parent.version; if (!string.IsNullOrEmpty(mainPomFile)) { DirectoryInfo dir = new DirectoryInfo(Path.GetDirectoryName(projectDigest.FullFileName)); FileInfo file = new FileInfo(mainPomFile); model.parent.relativePath = PomHelperUtility.GetRelativePath(dir, file); } } else { model.groupId = !string.IsNullOrEmpty(groupId) ? FilterID(groupId) : FilterID(projectDigest.ProjectName); model.version = string.IsNullOrEmpty(version) ? "1.0-SNAPSHOT" : version; } string projectName = projectDigest.ProjectName; if (HasSpecialCharacters(projectDigest.ProjectName)) { FileInfo f = new FileInfo(ProjectDigest.FullFileName); projectName = f.Name.Substring(0, f.Name.Length - f.Extension.Length); } model.modelVersion = "4.0.0"; model.artifactId = FilterID(projectName); model.name = string.Format("{0} : {1}", !string.IsNullOrEmpty(groupId) ? groupId : FilterID(projectDigest.ProjectName), FilterID(projectDigest.ProjectName)); model.packaging = packaging; }
public ProjectDigest DigestProject(Dictionary <string, object> projectMap) { Project project = (Project)projectMap["Project"]; if (!projectMap.ContainsKey("ProjectType")) { if (project.FullFileName.ToUpper().EndsWith(".CSPROJ")) { projectMap.Add("ProjectType", VisualStudioProjectTypeEnum.Windows__CSharp); } else if (project.FullFileName.ToUpper().EndsWith(".VBPROJ")) { projectMap.Add("ProjectType", VisualStudioProjectTypeEnum.Windows__VbDotNet); } } ProjectDigest projectDigest = new ProjectDigest(); string projectBasePath = Path.GetDirectoryName(project.FullFileName); projectDigest.ProjectType = (VisualStudioProjectTypeEnum)projectMap["ProjectType"]; projectDigest.FullFileName = project.FullFileName; projectDigest.FullDirectoryName = Path.GetDirectoryName(project.FullFileName); FileInfo existingPomFile = new FileInfo(Path.Combine(projectDigest.FullDirectoryName, "pom.xml")); if (existingPomFile.Exists) { projectDigest.ExistingPom = PomHelperUtility.ReadPomAsModel(existingPomFile); } if ((projectDigest.ProjectType & VisualStudioProjectTypeEnum.Windows__CSharp) == VisualStudioProjectTypeEnum.Windows__CSharp) { projectDigest.Language = "csharp"; } else if ((projectDigest.ProjectType & VisualStudioProjectTypeEnum.Windows__VbDotNet) == VisualStudioProjectTypeEnum.Windows__VbDotNet) { projectDigest.Language = "vb"; } List <Reference> references = new List <Reference>(); List <ProjectReference> projectReferences = new List <ProjectReference>(); if (projectMap.ContainsKey("InterProjectReferences") && projectMap["InterProjectReferences"] != null && projectMap["InterProjectReferences"] is Microsoft.Build.BuildEngine.Project[] ) { Microsoft.Build.BuildEngine.Project[] interProjectReferences = (Microsoft.Build.BuildEngine.Project[])projectMap["InterProjectReferences"]; foreach (Microsoft.Build.BuildEngine.Project p in interProjectReferences) { ProjectReference prjRef = new ProjectReference(projectBasePath); prjRef.ProjectPath = p.FullFileName; prjRef.Name = GetProjectAssemblyName(Path.GetFullPath(prjRef.ProjectFullPath)); projectReferences.Add(prjRef); } } List <Compile> compiles = new List <Compile>(); List <None> nones = new List <None>(); List <WebReferenceUrl> webReferenceUrls = new List <WebReferenceUrl>(); List <Content> contents = new List <Content>(); List <WebReferences> webReferencesList = new List <WebReferences>(); List <EmbeddedResource> embeddedResources = new List <EmbeddedResource>(); List <BootstrapperPackage> bootstrapperPackages = new List <BootstrapperPackage>(); List <Folder> folders = new List <Folder>(); List <string> globalNamespaceImports = new List <string>(); List <ComReference> comReferenceList = new List <ComReference>(); DigestBuildProperties(project, projectDigest); DigestBuildItems(project, projectDigest, projectBasePath, projectReferences, references, compiles, nones, webReferenceUrls, contents, folders, webReferencesList, embeddedResources, bootstrapperPackages, globalNamespaceImports, comReferenceList); DigestImports(project); projectDigest.ProjectReferences = projectReferences.ToArray(); projectDigest.References = references.ToArray(); projectDigest.Compiles = compiles.ToArray(); projectDigest.Contents = contents.ToArray(); projectDigest.Nones = nones.ToArray(); projectDigest.WebReferenceUrls = webReferenceUrls.ToArray(); projectDigest.WebReferences = webReferencesList.ToArray(); projectDigest.EmbeddedResources = embeddedResources.ToArray(); projectDigest.BootstrapperPackages = bootstrapperPackages.ToArray(); projectDigest.Folders = folders.ToArray(); projectDigest.GlobalNamespaceImports = globalNamespaceImports.ToArray(); projectDigest.ComReferenceList = comReferenceList.ToArray(); return(projectDigest); }
public static NPanday.Model.Pom.Model MakeProjectsParentPomModel(ProjectDigest[] projectDigests, string pomFileName, string groupId, string artifactId, string version, string scmTag, bool writePom) { string errorPrj = string.Empty; try { NPanday.Model.Pom.Model model = new NPanday.Model.Pom.Model(); model.modelVersion = "4.0.0"; model.packaging = "pom"; model.groupId = groupId; model.artifactId = artifactId; model.version = version; model.name = string.Format("{0} : {1}", groupId, artifactId); if (scmTag == null) { scmTag = string.Empty; } if (scmTag.ToUpper().Contains("OPTIONAL")) { scmTag = string.Empty; } if (scmTag.Contains("scm:svn:")) { scmTag = scmTag.Remove(scmTag.IndexOf("scm:svn:"), 8); } Uri repoUri; bool isValidUrl = true; try { if (!scmTag.Equals(string.Empty)) { repoUri = new Uri(scmTag); } } catch (Exception) { isValidUrl = false; log.InfoFormat("SCM Tag was not added, because the url {0} was not accessible", scmTag); } if (!string.Empty.Equals(scmTag) && scmTag != null && isValidUrl) { scmTag = scmTag.Trim(); Scm scmHolder = new Scm(); scmHolder.connection = string.Format("scm:svn:{0}", scmTag); scmHolder.developerConnection = string.Format("scm:svn:{0}", scmTag); //why forcibly Subversion? (scm:hg for example). Need to add more fields to configure. scmHolder.url = scmTag; model.scm = scmHolder; } List <string> modules = new List <string>(); foreach (ProjectDigest projectDigest in projectDigests) { DirectoryInfo prjDir = new DirectoryInfo ( projectDigest.ProjectType == VisualStudioProjectTypeEnum.Web_Site ? projectDigest.FullFileName : Path.GetDirectoryName(projectDigest.FullFileName) ); DirectoryInfo pomDir = new DirectoryInfo(Path.GetDirectoryName(pomFileName)); string moduleDir = PomHelperUtility.GetRelativePath(pomDir, prjDir); if (string.IsNullOrEmpty(moduleDir)) { moduleDir = "."; errorPrj += projectDigest.FullFileName; } modules.Add(moduleDir.Replace(@"\", "/")); } modules.Sort(); model.modules = modules.ToArray(); if (writePom) { PomHelperUtility.WriteModelToPom(new FileInfo(pomFileName), model); } return(model); } catch (Exception e) { throw new Exception("Project Importer failed with project \"" + errorPrj + "\". Project directory structure may not be supported."); } }
public override void ConvertProjectToPomModel(bool writePom, string scmTag) { // relies on this being set everywhere - if it were set per project, this would need to be evaluated on the project references if (!projectDigest.UseMsDeploy) { throw new Exception("You must use Web Deploy 2.0 to package web applications when using Azure projects"); } GenerateHeader("azure-cloud-service"); //Add SCM Tag if (scmTag != null && scmTag != string.Empty && Model.parent == null) { Scm scmHolder = new Scm(); scmHolder.connection = string.Format("scm:svn:{0}", scmTag); scmHolder.developerConnection = string.Format("scm:svn:{0}", scmTag); scmHolder.url = scmTag; Model.scm = scmHolder; } // Add Com Reference Dependencies if (projectDigest.ComReferenceList.Length > 0) { AddComReferenceDependency(); } //Add Project WebReferences AddWebReferences(); //Add EmbeddedResources maven-resgen-plugin AddEmbeddedResources(); // Add Project Inter-dependencies foreach (ProjectReference projectRef in projectDigest.ProjectReferences) { AddProjectReference(projectRef); } // Add Project Reference Dependencies // override the one from the parent to add new types for Azure AddProjectReferenceDependenciesToList(true); Plugin plugin = AddPlugin("org.apache.npanday.plugins", "azure-maven-plugin"); if (!string.IsNullOrEmpty(projectDigest.TargetFramework)) { AddPluginConfiguration(plugin, "frameworkVersion", projectDigest.TargetFramework); } else { // TODO: crude hack until the plugin doesn't require this and picks the right minimum default AddPluginConfiguration(plugin, "frameworkVersion", "4.0"); } if (!string.IsNullOrEmpty(projectDigest.ProductVersion) && projectDigest.ProductVersion != "1.6") { AddPluginConfiguration(plugin, "executableVersion", projectDigest.ProductVersion); } if (!string.IsNullOrEmpty(projectDigest.CloudConfig)) { 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); } }
public override void ConvertProjectToPomModel(bool writePom, string scmTag) { string packaging = projectDigest.SilverlightApplication ? "silverlight-application" : "silverlight-library"; GenerateHeader(packaging); Model.build.sourceDirectory = GetSourceDir(); //Add SCM Tag if (scmTag != null && scmTag != string.Empty && Model.parent == null) { Scm scmHolder = new Scm(); scmHolder.connection = string.Format("scm:svn:{0}", scmTag); scmHolder.developerConnection = string.Format("scm:svn:{0}", scmTag); scmHolder.url = scmTag; Model.scm = scmHolder; } // don't configure framework version for MSBuild since it's the Silverlight version, not the .NET Framework and not needed // add for types only AddPlugin("org.apache.npanday.plugins", "maven-compile-plugin", null, true); // add integration test plugin if project is a test if (projectDigest.UnitTest) { Plugin testPlugin = AddPlugin( "org.apache.npanday.plugins", "maven-test-plugin", null, false ); AddPluginConfiguration(testPlugin, "integrationTest", "true"); // for running .net framework 4.0 unit tests add new parameter in order to tell NUnit which runtime to // use. If there is a way to get this parameter from maven-compile-plugin use it if (projectDigest.TargetFramework == "4.5.1" || projectDigest.TargetFramework == "4.5" || projectDigest.TargetFramework == "4.0") { AddPluginConfiguration(testPlugin, "executionFrameworkVersion", projectDigest.TargetFramework); } } // Add Com Reference Dependencies if (projectDigest.ComReferenceList.Length > 0) { AddComReferenceDependency(); } //Add Project WebReferences AddWebReferences(); //Add EmbeddedResources maven-resgen-plugin AddEmbeddedResources(); // Add Project Inter-dependencies AddInterProjectDependenciesToList(); // Add Project Reference Dependencies // do not resolve any dependencies from the GAC for silverlight projects AddProjectReferenceDependenciesToList(false); if (writePom) { PomHelperUtility.WriteModelToPom(new FileInfo(Path.GetDirectoryName(projectDigest.FullFileName) + @"\pom.xml"), Model); } }
public override void ConvertProjectToPomModel(bool writePom, string scmTag) { string packaging = "dotnet-library"; if (!string.IsNullOrEmpty(projectDigest.OutputType)) { string type = projectDigest.OutputType.ToLower(); if (npandayTypeMap.ContainsKey(type)) { packaging = npandayTypeMap[type]; } } GenerateHeader(packaging); Model.build.sourceDirectory = GetSourceDir(); //Add SCM Tag if (scmTag != null && scmTag != string.Empty && Model.parent == null) { Scm scmHolder = new Scm(); scmHolder.connection = string.Format("scm:svn:{0}", scmTag); scmHolder.developerConnection = string.Format("scm:svn:{0}", scmTag); scmHolder.url = scmTag; Model.scm = scmHolder; } // Add NPanday compile plugin Plugin compilePlugin = AddPlugin( "org.apache.npanday.plugins", "maven-compile-plugin", null, true ); if (!string.IsNullOrEmpty(projectDigest.TargetFramework)) { AddPluginConfiguration(compilePlugin, "frameworkVersion", projectDigest.TargetFramework); } if (projectDigest.Language.Equals("vb", StringComparison.OrdinalIgnoreCase)) { AddPluginConfiguration(compilePlugin, "language", "VB"); AddPluginConfiguration(compilePlugin, "rootNamespace", projectDigest.RootNamespace); string define = GetVBDefineConfigurationValue(); if (!string.IsNullOrEmpty(define)) { AddPluginConfiguration(compilePlugin, "define", define); } } else { if (!string.IsNullOrEmpty(projectDigest.DefineConstants)) { AddPluginConfiguration(compilePlugin, "define", projectDigest.DefineConstants); } } if (projectDigest.StartupObject != "Sub Main") { AddPluginConfiguration(compilePlugin, "main", projectDigest.StartupObject); } AddPluginConfiguration(compilePlugin, "doc", projectDigest.DocumentationFile); //AddPluginConfiguration(compilePlugin, "noconfig", "true"); AddPluginConfiguration(compilePlugin, "imports", "import", projectDigest.GlobalNamespaceImports); // add include list for the compiling DirectoryInfo baseDir = new DirectoryInfo(Path.GetDirectoryName(projectDigest.FullFileName)); List <string> compiles = new List <string>(); Plugin msBuildPlugin = null; foreach (Compile compile in projectDigest.Compiles) { string compilesFile = PomHelperUtility.GetRelativePath(baseDir, new FileInfo(compile.IncludeFullPath)); compiles.Add(compilesFile); // if it's a xaml file, include the auto-generated file in object\Debug\ if (compilesFile.EndsWith(".xaml.cs") || compilesFile.EndsWith(".xaml.vb")) { //add the MsBuild plugin to auto generate the .g.cs/g.vb files string platform = null; // ignore AnyCPU or unknown values if (projectDigest.Platform == "x64" || projectDigest.Platform == "x86" || projectDigest.Platform == "Itanium") { platform = projectDigest.Platform; } string configuration = projectDigest.Configuration; if (msBuildPlugin == null) { msBuildPlugin = AddPlugin("org.apache.npanday.plugins", "NPanday.Plugin.Msbuild.JavaBinding", null, false); AddPluginExecution(msBuildPlugin, "compile", "validate"); if (platform != null) { AddPluginConfiguration(msBuildPlugin, "platform", platform); } if (configuration != null && configuration != "Debug") { AddPluginConfiguration(msBuildPlugin, "configuration", configuration); } } } } // Add XBAP artifacts if relevant if (projectDigest.HostInBrowser) { if (msBuildPlugin == null) { msBuildPlugin = AddPlugin("org.apache.npanday.plugins", "NPanday.Plugin.Msbuild.JavaBinding", null, false); } AddPluginConfiguration(msBuildPlugin, "attachXBAP", "true"); } AddPluginConfiguration(compilePlugin, "includeSources", "includeSource", compiles.ToArray()); if ("true".Equals(projectDigest.SignAssembly, StringComparison.OrdinalIgnoreCase) && !string.IsNullOrEmpty(projectDigest.AssemblyOriginatorKeyFile) ) { if (Path.IsPathRooted(projectDigest.AssemblyOriginatorKeyFile)) { AddPluginConfiguration(compilePlugin, "keyfile", PomHelperUtility.GetRelativePath(baseDir, new FileInfo(projectDigest.AssemblyOriginatorKeyFile))); } else { AddPluginConfiguration(compilePlugin, "keyfile", PomHelperUtility.GetRelativePath(baseDir, new FileInfo(baseDir.FullName + @"\" + projectDigest.AssemblyOriginatorKeyFile))); } } // add integration test plugin if project is a test if (projectDigest.UnitTest) { Plugin testPlugin = AddPlugin( "org.apache.npanday.plugins", "maven-test-plugin", null, false ); AddPluginConfiguration(testPlugin, "integrationTest", "true"); // for running .net framework 4.0+ unit tests add new parameter in order to tell NUnit which runtime to // use. If there is a way to get this parameter from maven-compile-plugin use it if (projectDigest.TargetFramework == "4.5.1" || projectDigest.TargetFramework == "4.5" || projectDigest.TargetFramework == "4.0") { AddPluginConfiguration(testPlugin, "executionFrameworkVersion", projectDigest.TargetFramework); } } // Add Com Reference Dependencies if (projectDigest.ComReferenceList.Length > 0) { AddComReferenceDependency(); } //Add Project WebReferences AddWebReferences(); //Add EmbeddedResources maven-resgen-plugin AddEmbeddedResources(); // Add Project Inter-dependencies AddInterProjectDependenciesToList(); // filter the rsp included assemblies FilterReferences(); // Add Project Reference Dependencies AddProjectReferenceDependenciesToList(true); if (writePom) { PomHelperUtility.WriteModelToPom(new FileInfo(Path.Combine(projectDigest.FullDirectoryName, "pom.xml")), Model); } }
public ProjectDigest DigestProject(Dictionary <string, object> projectMap) { ProjectDigest projectDigest = new ProjectDigest(); projectDigest.ProjectType = (VisualStudioProjectTypeEnum)projectMap["ProjectType"]; projectDigest.FullFileName = projectMap["ProjectFullPath"].ToString(); projectDigest.FullDirectoryName = projectDigest.FullFileName; if (projectMap.ContainsKey("TargetFramework")) { projectDigest.TargetFramework = projectMap["TargetFramework"].ToString(); } FileInfo existingPomFile = new FileInfo(Path.Combine(projectDigest.FullDirectoryName, "pom.xml")); if (existingPomFile.Exists) { projectDigest.ExistingPom = PomHelperUtility.ReadPomAsModel(existingPomFile); } // get Assembly name if (projectMap.ContainsKey("Release.AspNetCompiler.VirtualPath")) { projectDigest.Name = projectMap["Release.AspNetCompiler.VirtualPath"].ToString() .Replace(@"/", "") .Replace(@"\\", ""); } else if (projectMap.ContainsKey("Debug.AspNetCompiler.VirtualPath")) { projectDigest.Name = projectMap["Debug.AspNetCompiler.VirtualPath"].ToString() .Replace(@"/", "") .Replace(@"\\", ""); } else if (projectMap.ContainsKey("ProjectFullPath")) { projectDigest.Name = new DirectoryInfo(projectMap["ProjectFullPath"].ToString()).Name; } // InterProjectReferences List <ProjectReference> prjRefList = new List <ProjectReference>(); if (projectMap.ContainsKey("InterProjectReferences")) { foreach (Project var in (Project[])projectMap["InterProjectReferences"]) { ProjectReference prjRef = new ProjectReference(projectMap["ProjectFullPath"].ToString()); prjRef.Name = GetProjectAssemblyName(Path.GetFullPath(var.FullFileName)); prjRef.ProjectPath = Path.GetFullPath(var.FullFileName); prjRefList.Add(prjRef); } } projectDigest.ProjectReferences = prjRefList.ToArray(); //WebConfigAssemblies List <Reference> webConfigRefList = new List <Reference>(); //if (projectMap.ContainsKey("WebConfigAssemblies")) //{ // foreach (string var in (string[]) projectMap["WebConfigAssemblies"]) // { // Reference reference = new Reference(projectMap["ProjectFullPath"].ToString(), gac); // reference.AssemblyInfo = var; // webConfigRefList.Add(reference); // } //} //WebReferenceURL //if (projectMap.ContainsKey("WebReferencesUrl")) //{ // List<WebReferenceUrl> webReferenceUrls = new List<WebReferenceUrl>(); // if (projectDigest.WebReferenceUrls != null && projectDigest.WebReferenceUrls.Length > 0) // { // webReferenceUrls.AddRange(projectDigest.WebReferenceUrls); // } // foreach (WebReferenceUrl webReferenceUrl in (WebReferenceUrl[])projectMap["WebReferencesUrl"]) // { // if (webReferenceUrl != null && !string.IsNullOrEmpty(webReferenceUrl.RelPath) && !string.IsNullOrEmpty(webReferenceUrl.UpdateFromURL)) // webReferenceUrls.Add(webReferenceUrl); // } // projectDigest.WebReferenceUrls = webReferenceUrls.ToArray(); //} //BinAssemblies List <Reference> binRefList = new List <Reference>(); //if (projectMap.ContainsKey("BinAssemblies")) //{ // foreach (string var in (string[])projectMap["BinAssemblies"]) // { // // exclude if its already in the webconfig // Reference reference = new Reference(projectMap["ProjectFullPath"].ToString(), gac); // reference.HintPath = var; // // check if its not in project-reference or webconfig-assemblies references // if (!ReferenceInReferenceList(reference, webConfigRefList) && !ReferenceInProjectReferenceList(reference, prjRefList)) // { // binRefList.Add(reference); // } // } //} // combine both web and bin assemblies List <Reference> referenceList = new List <Reference>(); //referenceList.AddRange(webConfigRefList); //referenceList.AddRange(binRefList); projectDigest.References = referenceList.ToArray(); return(projectDigest); }