aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2014-02-21 10:44:10 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2014-02-21 10:44:21 +0100
commitea0a41dd25de46517145bf69c24f0cabdc7470cc (patch)
tree5416321249116f758f722023684ee947657fee2a /sonar-batch
parent4eee1b480d16bc61bb0d370f9ab70c6793eeb100 (diff)
downloadsonarqube-ea0a41dd25de46517145bf69c24f0cabdc7470cc.tar.gz
sonarqube-ea0a41dd25de46517145bf69c24f0cabdc7470cc.zip
SONAR-926 Fix usage of file system by Initializers
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java18
1 files changed, 13 insertions, 5 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 b537de96bf4..daac1be3c4e 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
@@ -24,6 +24,8 @@ import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.sonar.api.CoreProperties;
import org.sonar.api.batch.fs.FilePredicate;
import org.sonar.api.batch.fs.FilePredicates;
@@ -49,8 +51,10 @@ import java.util.Map;
*/
public class DefaultModuleFileSystem extends DefaultFileSystem implements ModuleFileSystem {
+ private static final Logger LOG = LoggerFactory.getLogger(DefaultModuleFileSystem.class);
+
private final String moduleKey;
- private final FileIndexer index;
+ private final FileIndexer indexer;
private final Settings settings;
private File buildDir;
@@ -62,13 +66,13 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module
private ComponentIndexer componentIndexer;
private boolean initialized;
- public DefaultModuleFileSystem(ModuleInputFileCache moduleInputFileCache, Project module, Settings settings, FileIndexer index, ModuleFileSystemInitializer initializer,
+ public DefaultModuleFileSystem(ModuleInputFileCache moduleInputFileCache, Project module, Settings settings, FileIndexer indexer, ModuleFileSystemInitializer initializer,
ComponentIndexer componentIndexer) {
super(moduleInputFileCache);
this.componentIndexer = componentIndexer;
this.moduleKey = module.getKey();
this.settings = settings;
- this.index = index;
+ this.indexer = indexer;
if (initializer.baseDir() != null) {
setBaseDir(initializer.baseDir());
}
@@ -174,6 +178,10 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module
@Override
public List<File> files(FileQuery query) {
+ if (!initialized) {
+ LOG.warn("Accessing the filesystem before the Sensor phase is deprecated and will not be supported in the future. Please update your plugin.");
+ indexer.index(this);
+ }
Collection<FilePredicate> predicates = Lists.newArrayList();
for (Map.Entry<String, Collection<String>> entry : query.attributes().entrySet()) {
predicates.add(fromDeprecatedAttribute(entry.getKey(), entry.getValue()));
@@ -183,7 +191,7 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module
public void resetDirs(File basedir, File buildDir, List<File> sourceDirs, List<File> testDirs, List<File> binaryDirs) {
if (initialized) {
- throw new SonarException("Module filesystem is already initialized. Modification of the filesystem are only allowed during Initializer phase.");
+ throw new SonarException("Module filesystem is already initialized. Modifications of filesystem are only allowed during Initializer phase.");
}
setBaseDir(basedir);
this.buildDir = buildDir;
@@ -196,7 +204,7 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module
if (initialized) {
throw new SonarException("Module filesystem can only be indexed once");
}
- index.index(this);
+ indexer.index(this);
componentIndexer.execute(this);
initialized = true;
}