aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2013-06-21 09:41:30 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2013-06-21 11:51:03 +0200
commit8bd7fdb357ba265381a7b013c3a06dc4729e5ec5 (patch)
tree719dcff0962faec72686b96644d23395f2bf6754 /sonar-batch
parent1fdf944c476e3fe1dc989ca3faeced229a643a6b (diff)
downloadsonarqube-8bd7fdb357ba265381a7b013c3a06dc4729e5ec5.tar.gz
sonarqube-8bd7fdb357ba265381a7b013c3a06dc4729e5ec5.zip
SONAR-4417 Fix regression between ProjectBuilder and ProjectExclusions
ProjectBuilders should be executed before ProjectExclusions
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ProjectExclusions.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorReady.java8
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/ProjectExclusionsTest.java12
3 files changed, 15 insertions, 7 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectExclusions.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectExclusions.java
index a408ec8d400..c61fb7137d7 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectExclusions.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectExclusions.java
@@ -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()) {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorReady.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorReady.java
index bf535ddf90a..2302c5757b2 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorReady.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorReady.java
@@ -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);
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectExclusionsTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectExclusionsTest.java
index 9b709cf7bc1..e7be2b09bc9 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectExclusionsTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectExclusionsTest.java
@@ -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();