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);
        }
        private static void SyncProjectValues(ref ProjectDigest projectDigest)
        {
            FileInfo pomFile = new FileInfo(Path.Combine(projectDigest.FullDirectoryName, "pom.xml"));

            if (projectDigest.ExistingPom == null || !pomFile.Exists)
            {
                return;
            }

            NPanday.Model.Pom.Model model = NPanday.Utils.PomHelperUtility.ReadPomAsModel(pomFile);

            projectDigest.UnitTest = IsProjectAnIntegrationTest(model);
        }
Example #3
0
        private void removeBtn_Click(object sender, EventArgs e)
        {
            String pomFileName = (new FileInfo(project.FileName).Directory).FullName + @"\..\..\..\pom.xml";

            if (!new FileInfo(pomFileName).Exists)
            {
                MessageBox.Show("Could not remove reference. Missing pom file: File = " + pomFileName);
                return;
            }

            XmlReader     reader     = XmlReader.Create(pomFileName);
            XmlSerializer serializer = new XmlSerializer(typeof(NPanday.Model.Pom.Model));

            if (!serializer.CanDeserialize(reader))
            {
                MessageBox.Show("Could not remove reference. Corrupted pom file: File = " + pomFileName);
                return;
            }

            NPanday.Model.Pom.Model model        = (NPanday.Model.Pom.Model)serializer.Deserialize(reader);
            List <Dependency>       dependencies = new List <Dependency>();

            ListView.SelectedIndexCollection indices = artifactsListView.SelectedIndices;

            //remove dependencies at the pom
            foreach (int indexItem   in artifactsListView.SelectedIndices)
            {
                //MessageBox.Show(dependenciesFromPom[indexItem]);
                dependenciesFromPom.RemoveAt(indexItem);

                //VSProject vsProject1 = (VSProject)project.Object;
                //File must exist
                //VSProject vsProject = (VSProject)project.Object;
                //vsProject.Imports.Re
            }

            reader.Close();

            model.dependencies = dependenciesFromPom.ToArray();
            TextWriter writer = new StreamWriter(pomFileName);

            serializer.Serialize(writer, model);

            writer.Close();

            this.Close();
        }
Example #4
0
        void GetReferencesFromPom(NPanday.Logging.Logger logger, ArtifactResyncSource artifactResyncSource)
        {
            Artifact.ArtifactRepository repository = new NPanday.Artifact.ArtifactContext().GetArtifactRepository();
            NPanday.Model.Pom.Model     m          = NPanday.Utils.PomHelperUtility.ReadPomAsModel(new FileInfo(pomFile));

            if (m.dependencies != null)
            {
                foreach (Dependency d in m.dependencies)
                {
                    // check if intra-project reference and copy artifacts
                    if (!IsIntraProject(m, d) && d.classifier == null)
                    {
                        Artifact.Artifact artifact = repository.GetArtifact(d);
                        CopyArtifactImpl(artifact, logger, artifactResyncSource);
                    }
                }
            }
        }
Example #5
0
        private void RemoveArtifactsForm_Load(object sender, EventArgs e)
        {
            String pomFileName = (new FileInfo(project.FileName).Directory).FullName + @"\..\..\..\pom.xml";

            if (!new FileInfo(pomFileName).Exists)
            {
                MessageBox.Show("Could not remove reference. Missing pom file: File = " + pomFileName);
                return;
            }

            XmlReader     reader     = XmlReader.Create(pomFileName);
            XmlSerializer serializer = new XmlSerializer(typeof(NPanday.Model.Pom.Model));

            if (!serializer.CanDeserialize(reader))
            {
                MessageBox.Show("Could not remove reference. Corrupted pom file: File = " + pomFileName);
                return;
            }

            NPanday.Model.Pom.Model model = (NPanday.Model.Pom.Model)serializer.Deserialize(reader);
            //List<Dependency> dependencies = new List<Dependency>();

            dependenciesFromPom = new List <Dependency>();

            if (model.dependencies != null)
            {
                dependenciesFromPom.AddRange(model.dependencies);
            }


            foreach (Dependency item in dependenciesFromPom)
            {
                System.Windows.Forms.ListViewItem viewitem = new System.Windows.Forms.ListViewItem(new string[] {
                    item.artifactId, item.version
                }, -1);

                viewitem.Tag = item;

                artifactsListView.Items.Add(viewitem);
            }
            //artifactsListBox.ClearSelected();
            reader.Close();
        }
Example #6
0
        private bool IsIntraProject(NPanday.Model.Pom.Model m, Dependency d)
        {
            string pomGroupId = (m.parent != null) ? m.parent.groupId : m.groupId;

            if (d.groupId == pomGroupId)
            {
                // loop through VS projects (instead of modules in parent POM) because
                // we need real-time list of project names in the solution
                foreach (Project project in solution.Projects)
                {
                    if (d.artifactId == project.Name)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #7
0
        public static NPanday.Model.Pom.Model[] ConvertProjectsToPomModels(ProjectDigest[] projectDigests, string mainPomFile, NPanday.Model.Pom.Model parent, string groupId, bool writePoms, string scmTag, List <Reference> missingReferences, List <string> nonPortableReferences)
        {
            try
            {
                string version = parent != null ? parent.version : null;

                List <NPanday.Model.Pom.Model> models = new List <NPanday.Model.Pom.Model>();
                foreach (ProjectDigest projectDigest in projectDigests)
                {
                    NPanday.Model.Pom.Model model = ConvertProjectToPomModel(projectDigest, mainPomFile, parent, groupId, writePoms, scmTag, missingReferences, nonPortableReferences);

                    models.Add(model);
                }
                return(models.ToArray());
            }
            catch
            {
                throw;
            }
        }
        static void SyncParentValues(ProjectStructureType structureType, string solutionFile, ref string groupId, ref string artifactId, ref string version)
        {
            string parentPomFileName = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(solutionFile), "pom.xml"));

            if (structureType == ProjectStructureType.FlatMultiModuleProject)
            {
                parentPomFileName = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(solutionFile), @"parent-pom.xml"));
            }

            FileInfo parentPomFile = new FileInfo(parentPomFileName);

            if (!parentPomFile.Exists)
            {
                throw new Exception("Project Must be Imported Atleast once before Re-Importing!");
            }

            NPanday.Model.Pom.Model model = NPanday.Utils.PomHelperUtility.ReadPomAsModel(parentPomFile);

            groupId    = model.groupId;
            artifactId = model.artifactId;
            version    = model.version;
        }
Example #9
0
        public AbstractPomConverter(ProjectDigest projectDigest, string mainPomFile, NPanday.Model.Pom.Model parent, string groupId)
        {
            artifactContext    = new ArtifactContext();
            this.projectDigest = projectDigest;
            this.mainPomFile   = mainPomFile;
            this.parent        = parent;
            this.groupId       = FilterID(groupId);
            this.version       = parent != null ? parent.version : null;

            this.rspUtil = new RspUtility();
            this.model   = new NPanday.Model.Pom.Model();

            // Add build Tag
            this.model.build = new NPanday.Model.Pom.Build();

            this.missingReferences = new List <Reference>();

            // TODO: this is a hack because of bad design. The things that talk to the local repository should be pulled out of here, and able to be stubbed/mocked instead
            if (testingArtifacts != null)
            {
                this.localArtifacts = testingArtifacts;
            }
        }
Example #10
0
 public NormalPomConverter(ProjectDigest projectDigest, string mainPomFile, NPanday.Model.Pom.Model parent, string groupId)
     : base(projectDigest, mainPomFile, parent, groupId)
 {
 }
Example #11
0
        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.");
            }
        }
Example #12
0
        public static NPanday.Model.Pom.Model ConvertProjectToPomModel(ProjectDigest projectDigest, string mainPomFile, NPanday.Model.Pom.Model parent, string groupId, bool writePom, string scmTag, List <Reference> missingReferences, List <string> nonPortableReferences)
        {
            if (!__converterAlgorithms.ContainsKey(projectDigest.ProjectType))
            {
                throw new NotSupportedException("Unsupported project type: " + projectDigest.ProjectType);
            }
            else
            {
                // fudge the project type - though overall this would be better with "capabilities" or some filters instead
                if ((projectDigest.ProjectType & VisualStudioProjectTypeEnum.Web_Application) != 0 && projectDigest.UseMsDeploy)
                {
                    projectDigest.ProjectType |= VisualStudioProjectTypeEnum.WebDeploy2;
                }
                if (projectDigest.RoleType != null && projectDigest.RoleType.Equals("Worker", StringComparison.InvariantCultureIgnoreCase))
                {
                    projectDigest.ProjectType |= VisualStudioProjectTypeEnum.WindowsAzure_Worker;
                }


                IPomConverter converter = (IPomConverter)System.Activator.CreateInstance(
                    __converterAlgorithms[projectDigest.ProjectType],
                    projectDigest,
                    mainPomFile,
                    parent,
                    groupId);

                converter.ConvertProjectToPomModel(scmTag);

                missingReferences.AddRange(converter.GetMissingReferences());

                foreach (string s in converter.GetNonPortableReferences())
                {
                    if (!nonPortableReferences.Contains(s))
                    {
                        nonPortableReferences.Add(s);
                    }
                }

                return(converter.Model);
            }
        }
Example #13
0
        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.");
            }
        }
Example #14
0
 public WebWithVbOrCsProjectFilePomConverter(ProjectDigest projectDigest, string mainPomFile, NPanday.Model.Pom.Model parent, string groupId)
     : base(projectDigest, mainPomFile, parent, groupId)
 {
 }
Example #15
0
        public AbstractPomConverter(ProjectDigest projectDigest, string mainPomFile, NPanday.Model.Pom.Model parent, string groupId)
        {
            artifactContext = new ArtifactContext();
            this.projectDigest = projectDigest;
            this.mainPomFile = mainPomFile;
            this.parent = parent;
            this.groupId = FilterID(groupId);
            this.version = parent != null ? parent.version : null;

            this.rspUtil = new RspUtility();
            this.model = new NPanday.Model.Pom.Model();

            // Add build Tag
            this.model.build = new NPanday.Model.Pom.Build();

            this.missingReferences = new List<Reference>();
            this.nonPortableReferences = new List<string>();

            // TODO: this is a hack because of bad design. The things that talk to the local repository should be pulled out of here, and able to be stubbed/mocked instead
            if (testingArtifacts != null)
            {
                this.localArtifacts = testingArtifacts;
            }
        }