Ejemplo n.º 1
0
        private void AAOpenMergedMI_Click(object sender, EventArgs e)
        {
            if ((sourceFile == null) || (!System.IO.File.Exists(sourceFile)))
            {
                sourceFile = new TempFile(_selectedItem.ResolveRecord.FromFileSpec);
                if (Scm.GetFileVersion(sourceFile, _selectedItem.ResolveRecord.FromFileSpec) == null)
                {
                    sourceFile.Dispose();
                    sourceFile = null;
                    return;
                }
            }

            if ((baseFile == null) || (!System.IO.File.Exists(baseFile)))
            {
                baseFile = new TempFile(_selectedItem.ResolveRecord.BaseFileSpec);
                if (Scm.GetFileVersion(baseFile, _selectedItem.ResolveRecord.BaseFileSpec) == null)
                {
                    baseFile = null;
                    return;
                }
            }
            string targetFile = _selectedItem.ResolveRecord.LocalFilePath.Path;

            if ((mergedFile == null) || (!System.IO.File.Exists(mergedFile)))
            {
                string mergedFileName = string.Format("{0}(merged {1}[{2}]){3}",
                                                      System.IO.Path.GetFileNameWithoutExtension(_selectedItem.ResolveRecord.LocalFilePath.Path),
                                                      ((P4.VersionRange)_selectedItem.ResolveRecord.FromFileSpec.Version).Upper,
                                                      _selectedItem.ResolveRecord.BaseFileSpec.Version,
                                                      System.IO.Path.GetExtension(_selectedItem.ResolveRecord.LocalFilePath.Path));

                mergedFile = new TempFile(mergedFileName);

                if (Scm.MergeLocalFiles(baseFile, sourceFile, targetFile, mergedFile) == false)
                {
                    MessageBox.Show(Resources.ResolveFileInteractiveControl_CannotCreateMergedFile, Resources.PerforceSCM, MessageBoxButtons.OK);
                    mergedFile.Dispose();
                    mergedFile = null;
                    return;
                }
            }
            if (Preferences.LocalSettings.GetBool("OpenShelvedFileInEditor", true))
            {
                EnvDTE.DTE dte = P4VsProvider.GetDTE();
                dte.ItemOperations.OpenFile(mergedFile, null);
            }
            else
            {
                ShowFileContentsDlg dlg = new ShowFileContentsDlg();

                dlg.TempFile = mergedFile;
                dlg.Title    = string.Format(Resources.ResolveFileInteractiveControl_MergeOfFiles,
                                             _selectedItem.ResolveRecord.FromFileSpec.ToString(),
                                             _selectedItem.ResolveRecord.LocalFilePath.Path);

                // Show modeless
                dlg.Show();
            }
        }
Ejemplo n.º 2
0
 public void FetchChangeData()
 {
     if (ChangeDataFetched == false)
     {
         P4.Options describeOptions = new P4.ChangeCmdOptions(P4.ChangeCmdFlags.IncludeJobs);
         if (_changeData.Id > 0)
         {
             describeOptions = new P4.DescribeCmdOptions(P4.DescribeChangelistCmdFlags.Shelved | P4.DescribeChangelistCmdFlags.Omit, -1, -1);
         }
         P4.Changelist sc = Scm.GetChangelist(_changeData.Id, describeOptions);
         if (sc != null)
         {
             if ((sc.ShelvedFiles != null) && (sc.ShelvedFiles.Count > 0))
             {
                 _changeData.ShelvedFiles = sc.ShelvedFiles;
             }
             else
             {
                 _changeData.ShelvedFiles = null;
             }
             if ((sc.Jobs != null) && (sc.Jobs.Count > 0))
             {
                 _changeData.Jobs = sc.Jobs;
             }
             else
             {
                 _changeData.Jobs = null;
             }
         }
         ChangeDataFetched = true;
     }
 }
Ejemplo n.º 3
0
        private void AAOpenSourceMI_Click(object sender, EventArgs e)
        {
            if ((sourceFile == null) || (!System.IO.File.Exists(sourceFile)))
            {
                sourceFile = new TempFile(_selectedItem.ResolveRecord.FromFileSpec);
                if (Scm.GetFileVersion(sourceFile, _selectedItem.ResolveRecord.FromFileSpec) == null)
                {
                    sourceFile.Dispose();
                    sourceFile = null;
                    return;
                }
            }

            if (Preferences.LocalSettings.GetBool("OpenShelvedFileInEditor", true))
            {
                EnvDTE.DTE dte = P4VsProvider.GetDTE();
                dte.ItemOperations.OpenFile(sourceFile, null);
            }
            else
            {
                ShowFileContentsDlg dlg = new ShowFileContentsDlg();

                dlg.TempFile = sourceFile;
                dlg.Title    = _selectedItem.ResolveRecord.FromFileSpec.ToString();

                // Show modeless
                dlg.Show();
            }
        }
Ejemplo n.º 4
0
        private void AADiffBaseVsSourceMI_Click(object sender, EventArgs e)
        {
            if ((sourceFile == null) || (!System.IO.File.Exists(sourceFile)))
            {
                sourceFile = new TempFile(_selectedItem.ResolveRecord.FromFileSpec);
                if (Scm.GetFileVersion(sourceFile, _selectedItem.ResolveRecord.FromFileSpec) == null)
                {
                    sourceFile.Dispose();
                    sourceFile = null;
                    return;
                }
            }

            if ((baseFile == null) || (!System.IO.File.Exists(baseFile)))
            {
                baseFile = new TempFile(_selectedItem.ResolveRecord.BaseFileSpec);
                if (Scm.GetFileVersion(baseFile, _selectedItem.ResolveRecord.BaseFileSpec) == null)
                {
                    baseFile.Dispose();
                    baseFile = null;
                    return;
                }
            }

            Scm.Diff2Files(baseFile,
                           string.Format(Resources.ResolveFileInteractiveControl_BaseFile,
                                         _selectedItem.ResolveRecord.BaseFileSpec),
                           sourceFile,
                           string.Format(Resources.ResolveFileInteractiveControl_SourceFile,
                                         _selectedItem.ResolveRecord.FromFileSpec)
                           );
        }
Ejemplo n.º 5
0
        private P4.P4ClientMerge.MergeStatus MergeCallBackHandler(P4.FileResolveRecord resolveRecord,
                                                                  P4.Client.AutoResolveDelegate AutoResolve, string sourcePath, string targetPath, string basePath, string resultsPath)
        {
            if (ResolveResult == P4.P4ClientMerge.MergeStatus.CMS_EDIT)
            {
                if (resolveRecord.Analysis.ResolveType == P4.ResolveType.Content)
                {
                    while (true)
                    {
                        Scm.MergeFiles(
                            sourcePath, _selectedItem.ResolveRecord.FromFileSpec.ToString(),
                            targetPath, _selectedItem.ResolveRecord.LocalFilePath.ToString(),
                            basePath, _selectedItem.ResolveRecord.BaseFileSpec.ToString(),
                            resultsPath);

                        DialogResult answer = MessageBox.Show(Resources.ResolveFileInteractiveControl_ResolveSaveChanges, Resources.PerforceSCM, MessageBoxButtons.YesNoCancel);

                        if (answer == DialogResult.Cancel)
                        {
                            // user wants to cancel
                            return(P4.P4ClientMerge.MergeStatus.CMS_SKIP);
                        }
                        if (answer == DialogResult.No)
                        {
                            // user wants to try again
                            continue;
                        }
                        // user wants to keep merged file
                        return(P4.P4ClientMerge.MergeStatus.CMS_MERGED);
                    }
                }
            }
            return(ResolveResult);
        }
Ejemplo n.º 6
0
        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);
            }
        }
Ejemplo n.º 7
0
        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);
            }
        }
Ejemplo n.º 8
0
        private void groupGridP4ObjectTreeListView_BeforeExpand(object Sender, TreeListViewEventArgs args)
        {
            TreeListViewItem tlvi = args.Node;

            tlvi.ChildNodes.Clear();
            P4.Group group = Scm.GetGroup(tlvi.Name);

            if (group.UserNames != null)
            {
                foreach (string user in group.UserNames)
                {
                    TreeListViewItem groupMemeber = new TreeListViewItem();
                    groupMemeber.Name       = user;
                    groupMemeber.Text       = user;
                    groupMemeber.ImageIndex = 1;
                    tlvi.ChildNodes.Add(groupMemeber);
                }
            }

            if (group.SubGroups != null)
            {
                foreach (string subGroup in group.SubGroups)
                {
                    P4.Group         groupSpec    = new P4.Group(subGroup);
                    TreeListViewItem groupMemeber = new TreeListViewItem();
                    groupMemeber.Tag        = groupSpec;
                    groupMemeber.Name       = subGroup;
                    groupMemeber.Text       = subGroup;
                    groupMemeber.ImageIndex = 0;
                    groupMemeber.ChildNodes.Add(new TreeListViewItem());
                    groupMemeber.Collapse();
                    tlvi.ChildNodes.Add(groupMemeber);
                }
            }
        }
Ejemplo n.º 9
0
    public static Mesh LoadModel(string scd, string LocalPath, bool SetUnreadable = true)
    {
        string ModelKey = scd + "_" + LocalPath;

        if (LoadedMeshes.ContainsKey(ModelKey))
        {
            return(LoadedMeshes[ModelKey]);
        }

        byte[] FinalMeshBytes = LoadBytes(scd, LocalPath);

        if (FinalMeshBytes == null || FinalMeshBytes.Length == 0)
        {
            return(null);            // File is empty
        }
        Mesh ToReturn = new Mesh()
        {
            indexFormat = UnityEngine.Rendering.IndexFormat.UInt16
        };

        // Create stream from bytes, to read it as binary file
        BinaryReader Stream = new BinaryReader(new MemoryStream(FinalMeshBytes));


        Scm NewScmModel = new Scm();

        NewScmModel.LoadFromStream(Stream);

        // Create Unity Mesh from Scm data
        ToReturn.name = NewScmModel.BoneNames[0];

        ToReturn.vertices = NewScmModel.GetVerts();
        //ToReturn.normals = NewScmModel.GetNormals();
        ToReturn.uv  = NewScmModel.GetUv0();
        ToReturn.uv2 = NewScmModel.GetUv1();

        //ToReturn.subMeshCount = 1;
        ToReturn.subMeshCount = 1;
        ToReturn.SetIndices(NewScmModel.GetTris(), MeshTopology.Triangles, 0);

        ToReturn.RecalculateBounds();
        ToReturn.RecalculateNormals();

        if (SetUnreadable)
        {
            ToReturn.UploadMeshData(true);
        }

        LoadedMeshes.Add(ModelKey, ToReturn);

        NewScmModel = null;

        return(ToReturn);
    }
Ejemplo n.º 10
0
        private void AADiffTargetVsMergedMI_Click(object sender, EventArgs e)
        {
            if ((sourceFile == null) || (!System.IO.File.Exists(sourceFile)))
            {
                sourceFile = new TempFile(_selectedItem.ResolveRecord.FromFileSpec);
                if (Scm.GetFileVersion(sourceFile, _selectedItem.ResolveRecord.FromFileSpec) == null)
                {
                    sourceFile.Dispose();
                    sourceFile = null;
                    return;
                }
            }

            if ((baseFile == null) || (!System.IO.File.Exists(baseFile)))
            {
                baseFile = new TempFile(_selectedItem.ResolveRecord.BaseFileSpec);
                if (Scm.GetFileVersion(baseFile, _selectedItem.ResolveRecord.BaseFileSpec) == null)
                {
                    baseFile.Dispose();
                    baseFile = null;
                    return;
                }
            }

            string targetFile = _selectedItem.ResolveRecord.LocalFilePath.Path;

            if ((mergedFile == null) || (!System.IO.File.Exists(mergedFile)))
            {
                string mergedFileName = string.Format("{0}(merged {1}[{2}]){3}",
                                                      System.IO.Path.GetFileNameWithoutExtension(_selectedItem.ResolveRecord.LocalFilePath.Path),
                                                      ((P4.VersionRange)_selectedItem.ResolveRecord.FromFileSpec.Version).Upper,
                                                      _selectedItem.ResolveRecord.BaseFileSpec.Version,
                                                      System.IO.Path.GetExtension(_selectedItem.ResolveRecord.LocalFilePath.Path));

                mergedFile = new TempFile(mergedFileName);

                if (Scm.MergeLocalFiles(baseFile, sourceFile, targetFile, mergedFile) == false)
                {
                    MessageBox.Show(Resources.ResolveFileInteractiveControl_CannotCreateMergedFile, Resources.PerforceSCM, MessageBoxButtons.OK);
                    mergedFile.Dispose();
                    mergedFile = null;
                    return;
                }
            }
            Scm.Diff2Files(targetFile,
                           string.Format(Resources.ResolveFileInteractiveControl_TargetFile,
                                         targetFile),
                           mergedFile,
                           Resources.ResolveFileInteractiveControl_MergedSourceTarget);
        }
Ejemplo n.º 11
0
        private void AAOpenSourceMI_Click(object sender, EventArgs e)
        {
            if (sourceFile == null)
            {
                sourceFile = new TempFile();
                if (Scm.GetFileVersion(sourceFile, _selectedItem.ResolveRecord.FromFileSpec) == null)
                {
                    return;
                }
            }

            ShowFileContentsDlg dlg = new ShowFileContentsDlg();

            dlg.TempFile = sourceFile;
            dlg.Title    = _selectedItem.ResolveRecord.FromFileSpec.ToString();

            // Show modeless
            dlg.Show();
        }
Ejemplo n.º 12
0
        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);
            }
        }
Ejemplo n.º 13
0
        private void AAOpenMergedMI_Click(object sender, EventArgs e)
        {
            if (sourceFile == null)
            {
                sourceFile = new TempFile();
                if (Scm.GetFileVersion(sourceFile, _selectedItem.ResolveRecord.FromFileSpec) == null)
                {
                    return;
                }
            }

            if (baseFile == null)
            {
                baseFile = new TempFile();
                if (Scm.GetFileVersion(baseFile, _selectedItem.ResolveRecord.BaseFileSpec) == null)
                {
                    return;
                }
            }

            string targetFile = _selectedItem.ResolveRecord.LocalFilePath.Path;

            if (mergedFile == null)
            {
                mergedFile = new TempFile();

                if (Scm.MergeLocalFiles(baseFile, sourceFile, targetFile, mergedFile) == false)
                {
                    return;
                }
            }
            ShowFileContentsDlg dlg = new ShowFileContentsDlg();

            dlg.TempFile = mergedFile;
            dlg.Title    = string.Format(Resources.ResolveFileInteractiveControl_MergeOfFiles,
                                         _selectedItem.ResolveRecord.FromFileSpec.ToString(),
                                         _selectedItem.ResolveRecord.LocalFilePath.Path);

            // Show modeless
            dlg.Show();
        }
Ejemplo n.º 14
0
        private void AADiffBaseVsTargetMI_Click(object sender, EventArgs e)
        {
            if (baseFile == null)
            {
                baseFile = new TempFile();
                if (Scm.GetFileVersion(baseFile, _selectedItem.ResolveRecord.BaseFileSpec) == null)
                {
                    return;
                }
            }

            string targetFile = _selectedItem.ResolveRecord.LocalFilePath.Path;

            Scm.Diff2Files(baseFile,
                           string.Format(Resources.ResolveFileInteractiveControl_SourceFile,
                                         _selectedItem.ResolveRecord.BaseFileSpec),
                           targetFile,
                           string.Format(Resources.ResolveFileInteractiveControl_TargetFile,
                                         targetFile)
                           );
        }
Ejemplo n.º 15
0
        private void AADiffSourceVsTargetMI_Click(object sender, EventArgs e)
        {
            if ((sourceFile == null) || (!System.IO.File.Exists(sourceFile)))
            {
                sourceFile = new TempFile(_selectedItem.ResolveRecord.FromFileSpec);
                if (Scm.GetFileVersion(sourceFile, _selectedItem.ResolveRecord.FromFileSpec) == null)
                {
                    sourceFile.Dispose();
                    sourceFile = null;
                    return;
                }
            }
            string targetFile = _selectedItem.ResolveRecord.LocalFilePath.Path;

            Scm.Diff2Files(sourceFile,
                           string.Format(Resources.ResolveFileInteractiveControl_SourceFile,
                                         _selectedItem.ResolveRecord.FromFileSpec),
                           targetFile,
                           string.Format(Resources.ResolveFileInteractiveControl_TargetFile,
                                         targetFile)
                           );
        }
Ejemplo n.º 16
0
        private void AADiffSourceVsMergedMI_Click(object sender, EventArgs e)
        {
            if (sourceFile == null)
            {
                sourceFile = new TempFile();
                if (Scm.GetFileVersion(sourceFile, _selectedItem.ResolveRecord.FromFileSpec) == null)
                {
                    return;
                }
            }

            if (baseFile == null)
            {
                baseFile = new TempFile();
                if (Scm.GetFileVersion(baseFile, _selectedItem.ResolveRecord.BaseFileSpec) == null)
                {
                    return;
                }
            }

            string targetFile = _selectedItem.ResolveRecord.LocalFilePath.Path;

            if (mergedFile == null)
            {
                mergedFile = new TempFile();

                if (Scm.MergeLocalFiles(baseFile, sourceFile, targetFile, mergedFile) == false)
                {
                    return;
                }
            }
            Scm.Diff2Files(sourceFile,
                           string.Format(Resources.ResolveFileInteractiveControl_SourceFile,
                                         _selectedItem.ResolveRecord.FromFileSpec),
                           mergedFile,
                           "Merged Source/Target");
        }
Ejemplo n.º 17
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.");
            }
        }
Ejemplo n.º 18
0
        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);
            }
        }
Ejemplo n.º 19
0
        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);
            }
        }
Ejemplo n.º 20
0
        private void AutoResolveBtn_Click(object sender, EventArgs e)
        {
            if (SelectedItems == null)
            {
                return;
            }

            AutoResolveMethod method = SelectedMethod;

            P4.ResolveFilesCmdFlags flags = P4.ResolveFilesCmdFlags.None;
            if (MergeBinaryAsText)
            {
                flags |= P4.ResolveFilesCmdFlags.ForceTextualMerge;
            }
            switch (method)
            {
            default:
            case AutoResolveMethod.Safe:
                flags |= P4.ResolveFilesCmdFlags.AutomaticSafeMode;
                break;

            case AutoResolveMethod.SafeMerge:
                flags |= P4.ResolveFilesCmdFlags.AutomaticMergeMode;
                break;

            case AutoResolveMethod.Source:
                flags |= P4.ResolveFilesCmdFlags.AutomaticTheirsMode;
                break;

            case AutoResolveMethod.Target:
                flags |= P4.ResolveFilesCmdFlags.AutomaticYoursMode;
                break;

            case AutoResolveMethod.MergeWithConflicts:
                flags |= P4.ResolveFilesCmdFlags.AutomaticForceMergeMode;
                break;
            }
            P4.Options options = new P4.ResolveCmdOptions(flags, -1);

            //Dictionary<string, ResolveFileDlg.FileListViewItem> itemMap = new Dictionary<string, ResolveFileDlg.FileListViewItem>();

            int failedResolves = 0;

            foreach (ResolveFileDlg.FileListViewItem item in SelectedItems)
            {
                try
                {
                    IList <P4.FileResolveRecord> records =
                        Scm.Connection.Repository.Connection.Client.ResolveFiles(
                            null, options, item.ResolveRecord.LocalFilePath);

                    //bool resolveFailed = true;
                    //if (records != null)
                    //{
                    //    foreach (P4.FileResolveRecord r in records)
                    //    {
                    //        if (r.Action != P4.FileAction.None)
                    //        {
                    //            resolveFailed = false;
                    //            break;
                    //        }
                    //    }
                    //}
                    //if (resolveFailed)
                    //{
                    //    failedResolves++;
                    //}
                    P4.P4CommandResult results = null;
                    P4.FileMetaData    newMd   = Scm.GetFileMetaData(null, item.ResolveRecord.LocalFilePath.Path, out results);
                    if (newMd.Unresolved)
                    {
                        failedResolves++;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, Resources.PerforceSCM, MessageBoxButtons.OK);
                    return;
                }
            }
            if (UpdateListView != null)
            {
                UpdateListView();
            }
            if (failedResolves > 0)
            {
                string msg = string.Format(Resources.ResolveFileAutoControl_FilesNotResolvedWarning, failedResolves);
                MessageBox.Show(msg, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 21
0
        private void AARevisionGraphSourceMI_Click(object sender, EventArgs e)
        {
            string sourceFile = _selectedItem.ResolveRecord.FromFileSpec.DepotPath.Path;

            Scm.LaunchRevisionGraphView(sourceFile);
        }
Ejemplo n.º 22
0
        private void AARevisionGraphTargetMI_Click(object sender, EventArgs e)
        {
            string targetFile = _selectedItem.ResolveRecord.LocalFilePath.Path;

            Scm.LaunchRevisionGraphView(targetFile);
        }
Ejemplo n.º 23
0
        private void AATimeLapseTargetMI_Click(object sender, EventArgs e)
        {
            string targetFile = _selectedItem.ResolveRecord.LocalFilePath.Path;

            Scm.LaunchTimeLapseView(targetFile);
        }
Ejemplo n.º 24
0
        private void AATimeLapseSourceMI_Click(object sender, EventArgs e)
        {
            string sourceFile = _selectedItem.ResolveRecord.FromFileSpec.DepotPath.Path;

            Scm.LaunchTimeLapseView(sourceFile);
        }
Ejemplo n.º 25
0
        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);
            }
        }
Ejemplo n.º 26
0
        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);
            }
        }
Ejemplo n.º 27
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.");
            }
        }
Ejemplo n.º 28
0
        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);
            }
        }
Ejemplo n.º 29
0
        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);
            }
        }