aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2013-10-16 15:36:20 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2013-10-16 15:36:29 +0200
commit325dc6593f008727bce103ed95b3f0abd7870465 (patch)
treec19debfb5ba5398fb199738b01bcac3a27e5e98e
parent18a4c15b060d1b56f08826bf6006d08eaf2625ec (diff)
downloadsonarqube-325dc6593f008727bce103ed95b3f0abd7870465.tar.gz
sonarqube-325dc6593f008727bce103ed95b3f0abd7870465.zip
Experimental detection of source dir changes - no unit tests yet
Waiting for integration tests to pass before going further
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java7
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/ModuleFileSystem.java5
2 files changed, 9 insertions, 3 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java
index b1b75858284..46f28c45b97 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java
@@ -58,6 +58,7 @@ public class DefaultModuleFileSystem implements ModuleFileSystem, Startable {
private List<File> sourceFiles = Lists.newArrayList();
private List<File> testFiles = Lists.newArrayList();
private AnalysisMode analysisMode;
+ private boolean dirsChanged = false;
public DefaultModuleFileSystem(ProjectDefinition module, Settings settings, FileIndex index, ModuleFileSystemInitializer initializer, AnalysisMode analysisMode) {
this(module.getKey(), settings, index, initializer, analysisMode);
@@ -129,6 +130,7 @@ public class DefaultModuleFileSystem implements ModuleFileSystem, Startable {
@Deprecated
void addSourceDir(File dir) {
sourceDirs.add(dir);
+ dirsChanged = true;
}
/**
@@ -137,6 +139,7 @@ public class DefaultModuleFileSystem implements ModuleFileSystem, Startable {
@Deprecated
void addTestDir(File dir) {
testDirs.add(dir);
+ dirsChanged = true;
}
@Override
@@ -160,6 +163,10 @@ public class DefaultModuleFileSystem implements ModuleFileSystem, Startable {
*/
@Override
public Iterable<InputFile> inputFiles(FileQuery query) {
+ if (dirsChanged) {
+ index();
+ dirsChanged = false;
+ }
List<InputFile> result = Lists.newArrayList();
FileQueryFilter filter = new FileQueryFilter(analysisMode, query);
for (InputFile input : index.inputFiles(moduleKey)) {
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/ModuleFileSystem.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/ModuleFileSystem.java
index f6bcadbb070..7a1921cea13 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/ModuleFileSystem.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/ModuleFileSystem.java
@@ -19,6 +19,7 @@
*/
package org.sonar.api.scan.filesystem;
+import com.google.common.annotations.Beta;
import org.sonar.api.BatchComponent;
import javax.annotation.CheckForNull;
@@ -54,14 +55,12 @@ public interface ModuleFileSystem extends BatchComponent {
* Source directories. Non-existing directories are excluded.
* Example in Maven : ${project.basedir}/src/main/java
*/
- // TODO mark as dangerous to use
List<File> sourceDirs();
/**
* Test directories. Non-existing directories are excluded.
* Example in Maven : ${project.basedir}/src/test/java
*/
- // TODO mark as dangerous to use
List<File> testDirs();
/**
@@ -78,12 +77,12 @@ public interface ModuleFileSystem extends BatchComponent {
/**
* Search for files. Never return null.
*/
- // TODO deprecate
List<File> files(FileQuery query);
/**
* @since 4.0
*/
+ @Beta
Iterable<InputFile> inputFiles(FileQuery query);
/**