]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4417 Fix regression between ProjectBuilder and ProjectExclusions
authorJulien HENRY <julien.henry@sonarsource.com>
Fri, 21 Jun 2013 07:41:30 +0000 (09:41 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Fri, 21 Jun 2013 09:51:03 +0000 (11:51 +0200)
ProjectBuilders should be executed before ProjectExclusions

sonar-batch/src/main/java/org/sonar/batch/scan/ProjectExclusions.java
sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorReady.java
sonar-batch/src/test/java/org/sonar/batch/scan/ProjectExclusionsTest.java

index a408ec8d4007a7d0492c9d76896299e82a4a5a8b..c61fb7137d781b8cb7e27283c454e80aba52e42c 100644 (file)
@@ -57,7 +57,7 @@ public class ProjectExclusions implements TaskComponent {
     this(settings, reactor, settingsReady, new ProjectBuilder[0]);
   }
 
-  public void start() {
+  public void apply() {
     if (reactor.getProjects().size() > 0 && StringUtils.isNotBlank(reactor.getProjects().get(0).getKey())) {
       LOG.info("Apply project exclusions");
       for (ProjectDefinition project : reactor.getProjects()) {
index bf535ddf90abd21f7d03048fd17c3e4021a6214f..2302c5757b2c68a861ff0f655e5ec2aba49813f9 100644 (file)
@@ -42,8 +42,10 @@ public class ProjectReactorReady {
   private final ProjectReactor reactor;
   private final Settings settings;
   private ProjectBuilder[] projectBuilders;
+  private ProjectExclusions exclusions;
 
   public ProjectReactorReady(ProjectExclusions exclusions, ProjectReactor reactor, Settings settings, @Nullable ProjectBuilder[] projectBuilders) {
+    this.exclusions = exclusions;
     this.reactor = reactor;
     this.settings = settings;
     this.projectBuilders = projectBuilders;
@@ -54,6 +56,7 @@ public class ProjectReactorReady {
   }
 
   public void start() {
+    // 1 Apply project builders
     ProjectBuilderContext context = new ProjectBuilderContext() {
 
       @Override
@@ -65,6 +68,11 @@ public class ProjectReactorReady {
     for (ProjectBuilder projectBuilder : projectBuilders) {
       projectBuilder.build(context);
     }
+
+    // 2 Apply project exclusions
+    exclusions.apply();
+
+    // 3 Validate final reactor
     ProjectReactorValidator validator = new ProjectReactorValidator(settings);
     validator.validate(reactor);
   }
index 9b709cf7bc10d913daae5a7dce69aa69469c8606..e7be2b09bc99e25638cfa3313421dac9a2af6e24 100644 (file)
@@ -45,7 +45,7 @@ public class ProjectExclusionsTest {
     ProjectReactor reactor = newReactor("root", "sub1", "sub2");
 
     ProjectExclusions exclusions = new ProjectExclusions(settings, reactor, null);
-    exclusions.start();
+    exclusions.apply();
 
     assertThat(reactor.getProject("root")).isNotNull();
     assertThat(reactor.getProject("sub1")).isNull();
@@ -57,7 +57,7 @@ public class ProjectExclusionsTest {
     Settings settings = new Settings();
     ProjectReactor reactor = newReactor("root", "sub1", "sub2");
     ProjectExclusions exclusions = new ProjectExclusions(settings, reactor, null);
-    exclusions.start();
+    exclusions.apply();
 
     assertThat(reactor.getProject("root")).isNotNull();
     assertThat(reactor.getProject("sub1")).isNotNull();
@@ -70,7 +70,7 @@ public class ProjectExclusionsTest {
     settings.setProperty("sonar.includedModules", "sub1");
     ProjectReactor reactor = newReactor("root", "sub1", "sub2");
     ProjectExclusions exclusions = new ProjectExclusions(settings, reactor, null);
-    exclusions.start();
+    exclusions.apply();
 
     assertThat(reactor.getProject("root")).isNotNull();
     assertThat(reactor.getProject("sub1")).isNotNull();
@@ -88,7 +88,7 @@ public class ProjectExclusionsTest {
 
     ProjectReactor reactor = new ProjectReactor(root);
     ProjectExclusions exclusions = new ProjectExclusions(settings, reactor, null);
-    exclusions.start();
+    exclusions.apply();
 
     assertThat(reactor.getProject("root")).isNotNull();
     assertThat(reactor.getProject("sub1")).isNull();
@@ -102,7 +102,7 @@ public class ProjectExclusionsTest {
 
     ProjectReactor reactor = newReactor("root", "sub1", "sub2");
     ProjectExclusions exclusions = new ProjectExclusions(settings, reactor, null);
-    exclusions.start();
+    exclusions.apply();
   }
 
   @Test
@@ -113,7 +113,7 @@ public class ProjectExclusionsTest {
     settings.setProperty("sonar.skippedModules", "struts-taglib");
 
     ProjectExclusions exclusions = new ProjectExclusions(settings, reactor, null);
-    exclusions.start();
+    exclusions.apply();
 
     assertThat(reactor.getProject("org.apache.struts:struts")).isNotNull();
     assertThat(reactor.getProject("org.apache.struts:struts-core")).isNotNull();