Repository: vackosar/gitflow-incremental-builder
Pull request #107 (2020-01-08 22:43:16)

 Issue #105: fix order of forceBuildModules 


Patch:
diff --git a/src/main/java/com/vackosar/gitflowincrementalbuild/boundary/Configuration.java b/src/main/java/com/vackosar/gitflowincrementalbuild/boundary/Configuration.java
index 46fe65c..6cc4922 100644
--- a/src/main/java/com/vackosar/gitflowincrementalbuild/boundary/Configuration.java
+++ b/src/main/java/com/vackosar/gitflowincrementalbuild/boundary/Configuration.java
@@ -186,7 +186,7 @@ public class Configuration {
     }
 
     @Singleton
-    @Named("gib.configurationProvider")
+    @Named
     public static class Provider implements javax.inject.Provider<Configuration> {
 
         private final MavenSession mavenSession;
diff --git a/src/main/java/com/vackosar/gitflowincrementalbuild/boundary/MavenLifecycleParticipant.java b/src/main/java/com/vackosar/gitflowincrementalbuild/boundary/MavenLifecycleParticipant.java
index 71fc36e..493ce25 100644
--- a/src/main/java/com/vackosar/gitflowincrementalbuild/boundary/MavenLifecycleParticipant.java
+++ b/src/main/java/com/vackosar/gitflowincrementalbuild/boundary/MavenLifecycleParticipant.java
@@ -13,7 +13,7 @@ import javax.inject.Named;
 import javax.inject.Singleton;
 
 @Singleton
-@Named("gib")
+@Named
 public class MavenLifecycleParticipant extends AbstractMavenLifecycleParticipant {
 
     private Logger logger = LoggerFactory.getLogger(MavenLifecycleParticipant.class);
diff --git a/src/main/java/com/vackosar/gitflowincrementalbuild/boundary/UnchangedProjectsRemover.java b/src/main/java/com/vackosar/gitflowincrementalbuild/boundary/UnchangedProjectsRemover.java
index 0d6c051..a74d7f3 100644
--- a/src/main/java/com/vackosar/gitflowincrementalbuild/boundary/UnchangedProjectsRemover.java
+++ b/src/main/java/com/vackosar/gitflowincrementalbuild/boundary/UnchangedProjectsRemover.java
@@ -18,7 +18,7 @@ import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
 @Singleton
-@Named("gib.unchangedProjectsRemover")
+@Named
 class UnchangedProjectsRemover {
 
     private static final String MAVEN_TEST_SKIP = "maven.test.skip";
@@ -62,12 +62,14 @@ class UnchangedProjectsRemover {
             mavenSession.getGoals().clear();
             mavenSession.getGoals().add("validate");
         } else if (!configProvider.get().forceBuildModules.isEmpty()) {
-            Stream<MavenProject> forceBuildModules = mavenSession.getProjects().stream()
+            Set<MavenProject> forceBuildModules = mavenSession.getProjects().stream()
                     .filter(p -> matchesAny(p.getArtifactId(), configProvider.get().forceBuildModules))
                     .filter(p -> !rebuild.contains(p))
-                    .map(this::applyUpstreamModuleArgs);
-            mavenSession.setProjects(
-                    Stream.concat(forceBuildModules, rebuild.stream()).collect(Collectors.toList()));
+                    .map(this::applyUpstreamModuleArgs)
+                    .collect(Collectors.toCollection(LinkedHashSet::new));
+            mavenSession.setProjects(mavenSession.getProjects().stream()
+                    .filter(prj -> forceBuildModules.contains(prj) || rebuild.contains(prj))
+                    .collect(Collectors.toList()));
         } else {
             mavenSession.setProjects(new ArrayList<>(rebuild));
         }
diff --git a/src/main/java/com/vackosar/gitflowincrementalbuild/control/ChangedProjects.java b/src/main/java/com/vackosar/gitflowincrementalbuild/control/ChangedProjects.java
index de8c74b..29f2ec2 100644
--- a/src/main/java/com/vackosar/gitflowincrementalbuild/control/ChangedProjects.java
+++ b/src/main/java/com/vackosar/gitflowincrementalbuild/control/ChangedProjects.java
@@ -17,7 +17,7 @@ import java.util.Set;
 import java.util.stream.Collectors;
 
 @Singleton
-@Named("gib.changedProjects")
+@Named
 public class ChangedProjects {
 
     private Logger logger = LoggerFactory.getLogger(ChangedProjects.class);
diff --git a/src/main/java/com/vackosar/gitflowincrementalbuild/control/DifferentFiles.java b/src/main/java/com/vackosar/gitflowincrementalbuild/control/DifferentFiles.java
index d9dade5..f955e93 100644
--- a/src/main/java/com/vackosar/gitflowincrementalbuild/control/DifferentFiles.java
+++ b/src/main/java/com/vackosar/gitflowincrementalbuild/control/DifferentFiles.java
@@ -31,7 +31,7 @@ import java.util.Set;
 import java.util.stream.Collectors;
 
 @Singleton
-@Named("gib.differentFiles")
+@Named
 public class DifferentFiles {
 
     public static final String UNSUPPORTED_WORKTREE = "JGit unsupported separate worktree checkout detected from current git dir path: ";
diff --git a/src/main/java/com/vackosar/gitflowincrementalbuild/control/Modules.java b/src/main/java/com/vackosar/gitflowincrementalbuild/control/Modules.java
index ae262a9..e3001b9 100644
--- a/src/main/java/com/vackosar/gitflowincrementalbuild/control/Modules.java
+++ b/src/main/java/com/vackosar/gitflowincrementalbuild/control/Modules.java
@@ -11,7 +11,7 @@ import javax.inject.Named;
 import javax.inject.Singleton;
 
 @Singleton
-@Named("gib.modules")
+@Named
 public class Modules {
 
     public Map<Path, MavenProject> createPathMap(MavenSession session) {


Test patch:
diff --git a/src/test/java/com/vackosar/gitflowincrementalbuild/boundary/UnchangedProjectsRemoverTest.java b/src/test/java/com/vackosar/gitflowincrementalbuild/boundary/UnchangedProjectsRemoverTest.java
index f5abe38..c2bd05b 100644
--- a/src/test/java/com/vackosar/gitflowincrementalbuild/boundary/UnchangedProjectsRemoverTest.java
+++ b/src/test/java/com/vackosar/gitflowincrementalbuild/boundary/UnchangedProjectsRemoverTest.java
@@ -365,7 +365,7 @@ public class UnchangedProjectsRemoverTest {
         underTest.act();
 
         verify(mavenSessionMock).setProjects(
-                Arrays.asList(mavenProjectMock, unchangedModuleMock, changedModuleMock));
+                Arrays.asList(mavenProjectMock, changedModuleMock, unchangedModuleMock));
     }
 
     @Test
@@ -378,7 +378,7 @@ public class UnchangedProjectsRemoverTest {
         underTest.act();
 
         verify(mavenSessionMock).setProjects(
-                Arrays.asList(mavenProjectMock, unchangedModuleMock, changedModuleMock));
+                Arrays.asList(mavenProjectMock, changedModuleMock, unchangedModuleMock));
     }
 
     @Test
@@ -391,7 +391,7 @@ public class UnchangedProjectsRemoverTest {
         underTest.act();
 
         verify(mavenSessionMock).setProjects(
-                Arrays.asList(mavenProjectMock, unchangedModuleMock, changedModuleMock));
+                Arrays.asList(mavenProjectMock, changedModuleMock, unchangedModuleMock));
     }
 
     @Test
@@ -470,7 +470,7 @@ public class UnchangedProjectsRemoverTest {
         underTest.act();
 
         verify(mavenSessionMock).setProjects(
-                Arrays.asList(dependentWar, changedProjectMock));
+                Arrays.asList(changedProjectMock, dependentWar));
     }
 
     @Test