Ejemplo n.º 1
0
        public void TwoProjectsParentTest()
        {
            var projectA = new Project
            {
                GroupId    = "group",
                ArtifactId = "a",
                Version    = "1.0.0".ToVersion()
            };

            var projectB = new Project
            {
                GroupId    = "group",
                ArtifactId = "b",
                Version    = "1.0.1".ToVersion(),
                Parent     = new ParentReference {
                    GroupId    = "group",
                    ArtifactId = "a",
                    Version    = "1.0.0".ToVersion()
                },
            };

            var repo = new Mock <IProjectsRepository>();

            repo.SetupGet(r => r.AllProjects).Returns(new IProject[] { projectA, projectB });

            var action = new CascadeSwitchAction(repo.Object);

            action.ExecuteFor(projectA);

            Assert.That(projectA.Version.Value, Is.EqualTo("1.0.1-SNAPSHOT"));
            Assert.That(projectB.Version.Value, Is.EqualTo("1.0.2-SNAPSHOT"));
        }
Ejemplo n.º 2
0
        // TODO: use current folder to identify project if current folder is under repo

        public void Execute()
        {
            var solutionManagement = new SolutionManagement(GetActionLog());
            var solution           = solutionManagement.OpenSolution(Path, LoadAllProjects);

            IProject target;

            if (!solution.TryGetProject(GroupId, ArtifactId, Version, out target, !string.IsNullOrEmpty(Version)))
            {
                Console.Error.WriteLine("Could not find project");
                return;
            }

            Console.WriteLine("Switch to SNAPSHOT project {0} and all dependent in folder {1}", target, Path);
            if (Position != -1)
            {
                Console.WriteLine($"Increment {Position} position");
            }
            else
            {
                Console.WriteLine("Increment last version position");
            }

            Debug.WriteLine(solution.AllProjects.Count() + " projects loaded");

            CascadeSwitchAction cascade = new CascadeSwitchAction(solution);
            int?position = null;

            if (Position >= 0)
            {
                position = Position;
            }

            int?stopAtPosition = null;

            if (Position >= 0)
            {
                stopAtPosition = StopAtPosition;
                if (!position.HasValue)
                {
                    Console.Error.WriteLine("Position has to be specified");
                    return;
                }

                if (position.Value > StopAtPosition)
                {
                    Console.Error.WriteLine("Stop position has to be less or equal to position");
                    return;
                }
            }

            cascade.ExecuteFor(target, position, stopAtPosition);

            solution.ForceSaveAll();
        }
Ejemplo n.º 3
0
        public void SingleProjectPositionTest()
        {
            var project = new Project
            {
                GroupId    = "group",
                ArtifactId = "a",
                Version    = "1.0.0".ToVersion()
            };

            var repo = new Mock <IProjectsRepository>();

            repo.SetupGet(r => r.AllProjects).Returns(new IProject[] { project });

            var action = new CascadeSwitchAction(repo.Object);

            action.ExecuteFor(project, 0);

            Assert.That(project.Version.Value, Is.EqualTo("2.0.0-SNAPSHOT"));
        }
Ejemplo n.º 4
0
        private void CascadeSwitchToSnapshotOnClick(object sender, EventArgs e)
        {
            if (CurrentProjectView == null)
            {
                return;
            }

            _listPoms.BeginUpdate();
            _treePoms.BeginUpdate();

            try
            {
                var action = new CascadeSwitchAction(ProjectsRepo);
                action.ExecuteFor(CurrentProjectView.ProjectNode);
            }
            finally
            {
                _listPoms.EndUpdate();
                _treePoms.EndUpdate();
            }

            RefreshPropertyGrid();
            UpdateAllProjectViews();
        }
Ejemplo n.º 5
0
        public override void Do()
        {
            var action = new CascadeSwitchAction(_projectsRepo);

            action.ExecuteFor(_project);
        }