diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2014-01-27 11:47:19 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2014-01-27 12:28:40 +0100 |
commit | df04c42a7d286b89cf9fa602b4aa03af0125dae9 (patch) | |
tree | 9c61ff3442bbb75fbfc2897ea9e8ade0c5dd30b0 | |
parent | 593a0d77a318f5cd35e4efb0a2ec5bf62e2f6d83 (diff) | |
download | sonarqube-df04c42a7d286b89cf9fa602b4aa03af0125dae9.tar.gz sonarqube-df04c42a7d286b89cf9fa602b4aa03af0125dae9.zip |
SONAR-926 Expose new FileSystem API based on InputFile/InputDir
51 files changed, 559 insertions, 157 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/ignore/scanner/SourceScanner.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/ignore/scanner/SourceScanner.java index f8b3b001453..23a61888fee 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/ignore/scanner/SourceScanner.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/ignore/scanner/SourceScanner.java @@ -20,13 +20,14 @@ package org.sonar.plugins.core.issue.ignore.scanner; +import org.sonar.api.scan.filesystem.InputFile; + import org.sonar.api.batch.Phase; import org.sonar.api.batch.Sensor; import org.sonar.api.batch.SensorContext; import org.sonar.api.resources.Project; import org.sonar.api.scan.filesystem.FileQuery; import org.sonar.api.scan.filesystem.internal.DefaultInputFile; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.api.utils.SonarException; import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem; import org.sonar.plugins.core.issue.ignore.pattern.ExclusionPatternInitializer; diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/FileHashSensor.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/FileHashSensor.java index 97eecd33f5e..fd14c7b7f06 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/FileHashSensor.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/FileHashSensor.java @@ -19,11 +19,13 @@ */ package org.sonar.plugins.core.sensors; +import org.sonar.api.scan.filesystem.internal.DefaultInputFile; + +import org.sonar.api.scan.filesystem.InputFile; import com.google.common.collect.Maps; import org.sonar.api.batch.Sensor; import org.sonar.api.batch.SensorContext; import org.sonar.api.resources.Project; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.api.utils.KeyValueFormat; import org.sonar.batch.index.ComponentDataCache; import org.sonar.batch.scan.filesystem.InputFileCache; @@ -58,7 +60,7 @@ public final class FileHashSensor implements Sensor { public void analyse(Project project, SensorContext context) { Map<String, String> map = Maps.newHashMap(); for (InputFile inputFile : fileCache.byModule(project.key())) { - String hash = inputFile.attribute(InputFile.ATTRIBUTE_HASH); + String hash = inputFile.attribute(DefaultInputFile.ATTRIBUTE_HASH); if (hash != null) { map.put(inputFile.path(), hash); } diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/FileHashSensorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/FileHashSensorTest.java index e7760be8de4..073db76b693 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/FileHashSensorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/FileHashSensorTest.java @@ -19,6 +19,8 @@ */ package org.sonar.plugins.core.sensors; +import org.sonar.api.scan.filesystem.InputFile; + import com.google.common.base.Charsets; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; @@ -29,7 +31,6 @@ import org.junit.rules.TemporaryFolder; import org.sonar.api.batch.SensorContext; import org.sonar.api.resources.Project; import org.sonar.api.scan.filesystem.internal.DefaultInputFile; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.batch.index.ComponentDataCache; import org.sonar.batch.scan.filesystem.InputFileCache; import org.sonar.core.source.SnapshotDataTypes; @@ -58,8 +59,8 @@ public class FileHashSensorTest { @Test public void store_file_hashes() throws Exception { when(fileCache.byModule("struts")).thenReturn(Lists.<InputFile>newArrayList( - DefaultInputFile.create(temp.newFile(), Charsets.UTF_8, "src/Foo.java", ImmutableMap.of(InputFile.ATTRIBUTE_HASH, "ABC")), - DefaultInputFile.create(temp.newFile(), Charsets.UTF_8, "src/Bar.java", ImmutableMap.of(InputFile.ATTRIBUTE_HASH, "DEF")) + DefaultInputFile.create(temp.newFile(), Charsets.UTF_8, "src/Foo.java", ImmutableMap.of(DefaultInputFile.ATTRIBUTE_HASH, "ABC")), + DefaultInputFile.create(temp.newFile(), Charsets.UTF_8, "src/Bar.java", ImmutableMap.of(DefaultInputFile.ATTRIBUTE_HASH, "DEF")) )); SensorContext sensorContext = mock(SensorContext.class); @@ -73,8 +74,8 @@ public class FileHashSensorTest { public void store_file_hashes_for_branches() throws Exception { project = new Project("struts", "branch-2.x", "Struts 2.x"); when(fileCache.byModule("struts:branch-2.x")).thenReturn(Lists.<InputFile>newArrayList( - DefaultInputFile.create(temp.newFile(), Charsets.UTF_8, "src/Foo.java", ImmutableMap.of(InputFile.ATTRIBUTE_HASH, "ABC")), - DefaultInputFile.create(temp.newFile(), Charsets.UTF_8, "src/Bar.java", ImmutableMap.of(InputFile.ATTRIBUTE_HASH, "DEF")) + DefaultInputFile.create(temp.newFile(), Charsets.UTF_8, "src/Foo.java", ImmutableMap.of(DefaultInputFile.ATTRIBUTE_HASH, "ABC")), + DefaultInputFile.create(temp.newFile(), Charsets.UTF_8, "src/Bar.java", ImmutableMap.of(DefaultInputFile.ATTRIBUTE_HASH, "DEF")) )); SensorContext sensorContext = mock(SensorContext.class); diff --git a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarBridgeEngine.java b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarBridgeEngine.java index 9750b2fa206..b093558edba 100644 --- a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarBridgeEngine.java +++ b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarBridgeEngine.java @@ -19,6 +19,8 @@ */ package org.sonar.plugins.cpd; +import org.sonar.api.scan.filesystem.InputFile; + import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; @@ -32,7 +34,6 @@ import org.sonar.api.resources.Language; import org.sonar.api.resources.Project; import org.sonar.api.scan.filesystem.FileQuery; import org.sonar.api.scan.filesystem.internal.DefaultInputFile; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.api.utils.SonarException; import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem; import org.sonar.duplications.DuplicationPredicates; @@ -43,6 +44,7 @@ import org.sonar.plugins.cpd.index.IndexFactory; import org.sonar.plugins.cpd.index.SonarDuplicationsIndex; import javax.annotation.CheckForNull; + import java.util.Collection; import java.util.List; import java.util.concurrent.ExecutionException; diff --git a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java index 832b4e7ab82..62878f1467e 100644 --- a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java +++ b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java @@ -20,6 +20,8 @@ package org.sonar.plugins.cpd; +import org.sonar.api.scan.filesystem.InputFile; + import com.google.common.collect.Iterables; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringEscapeUtils; @@ -36,7 +38,6 @@ import org.sonar.api.resources.Language; import org.sonar.api.resources.Project; import org.sonar.api.scan.filesystem.FileQuery; import org.sonar.api.scan.filesystem.internal.DefaultInputFile; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.api.utils.SonarException; import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem; import org.sonar.duplications.block.Block; diff --git a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/index/DbDuplicationsIndex.java b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/index/DbDuplicationsIndex.java index 2ef72e7cae6..83475fbb861 100644 --- a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/index/DbDuplicationsIndex.java +++ b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/index/DbDuplicationsIndex.java @@ -19,11 +19,12 @@ */ package org.sonar.plugins.cpd.index; +import org.sonar.api.scan.filesystem.InputFile; + import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.sonar.api.database.model.Snapshot; import org.sonar.api.resources.Project; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.batch.index.ResourcePersister; import org.sonar.core.duplication.DuplicationDao; import org.sonar.core.duplication.DuplicationUnitDto; diff --git a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/index/SonarDuplicationsIndex.java b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/index/SonarDuplicationsIndex.java index cd554934c04..6a54af3503b 100644 --- a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/index/SonarDuplicationsIndex.java +++ b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/index/SonarDuplicationsIndex.java @@ -19,8 +19,9 @@ */ package org.sonar.plugins.cpd.index; +import org.sonar.api.scan.filesystem.InputFile; + import com.google.common.collect.Lists; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.duplications.block.Block; import org.sonar.duplications.block.ByteArray; import org.sonar.duplications.index.AbstractCloneIndex; diff --git a/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/SonarEngineTest.java b/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/SonarEngineTest.java index f22eabb3a81..18c80b5dcfc 100644 --- a/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/SonarEngineTest.java +++ b/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/SonarEngineTest.java @@ -19,12 +19,13 @@ */ package org.sonar.plugins.cpd; +import org.sonar.api.scan.filesystem.InputFile; + import com.google.common.base.Charsets; import org.junit.Before; import org.junit.Test; import org.sonar.api.batch.SensorContext; import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.api.scan.filesystem.internal.InputFileBuilder; import org.sonar.api.test.IsMeasure; import org.sonar.duplications.index.CloneGroup; diff --git a/plugins/sonar-maven-batch-plugin/src/main/java/org/sonar/plugins/maven/DefaultMavenPluginExecutor.java b/plugins/sonar-maven-batch-plugin/src/main/java/org/sonar/plugins/maven/DefaultMavenPluginExecutor.java index 4dea1968071..cab684b55c6 100644 --- a/plugins/sonar-maven-batch-plugin/src/main/java/org/sonar/plugins/maven/DefaultMavenPluginExecutor.java +++ b/plugins/sonar-maven-batch-plugin/src/main/java/org/sonar/plugins/maven/DefaultMavenPluginExecutor.java @@ -56,8 +56,8 @@ public class DefaultMavenPluginExecutor implements MavenPluginExecutor { } MavenPlugin plugin = MavenPlugin.getPlugin(project.getPom(), handler.getGroupId(), handler.getArtifactId()); execute(project, - fs, - getGoal(handler.getGroupId(), handler.getArtifactId(), plugin != null && plugin.getPlugin() != null ? plugin.getPlugin().getVersion() : null, goal)); + fs, + getGoal(handler.getGroupId(), handler.getArtifactId(), plugin != null && plugin.getPlugin() != null ? plugin.getPlugin().getVersion() : null, goal)); } return handler; } @@ -76,20 +76,21 @@ public class DefaultMavenPluginExecutor implements MavenPluginExecutor { Thread.currentThread().setContextClassLoader(currentClassLoader); profiler.stop(); } - - MavenProjectConverter.synchronizeFileSystem(project.getPom(), fs); + if (!fs.isInitialized()) { + MavenProjectConverter.synchronizeFileSystem(project.getPom(), fs); + } } } static String getGoal(String groupId, String artifactId, @Nullable String version, String goal) { String defaultVersion = version == null ? "" : version; return new StringBuilder() - .append(groupId).append(":") - .append(artifactId).append(":") - .append(defaultVersion) - .append(":") - .append(goal) - .toString(); + .append(groupId).append(":") + .append(artifactId).append(":") + .append(defaultVersion) + .append(":") + .append(goal) + .toString(); } public void concreteExecute(MavenProject pom, String goal) { @@ -130,14 +131,14 @@ public class DefaultMavenPluginExecutor implements MavenPluginExecutor { try { ReactorManager reactor = new ReactorManager(Arrays.asList(pom)); MavenSession clonedSession = new MavenSession(mavenSession.getContainer(), - mavenSession.getSettings(), - mavenSession.getLocalRepository(), - mavenSession.getEventDispatcher(), - reactor, - Arrays.asList(goal), - mavenSession.getExecutionRootDirectory(), - mavenSession.getExecutionProperties(), - mavenSession.getStartTime()); + mavenSession.getSettings(), + mavenSession.getLocalRepository(), + mavenSession.getEventDispatcher(), + reactor, + Arrays.asList(goal), + mavenSession.getExecutionRootDirectory(), + mavenSession.getExecutionProperties(), + mavenSession.getStartTime()); executeMethod.invoke(lifecycleExecutor, clonedSession, reactor, clonedSession.getEventDispatcher()); } catch (Exception e) { throw new SonarException("Unable to execute Maven 2 plugin", e); diff --git a/sonar-batch/src/main/java/org/sonar/batch/DefaultSensorContext.java b/sonar-batch/src/main/java/org/sonar/batch/DefaultSensorContext.java index 5fabba61dbc..36e84cea339 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/DefaultSensorContext.java +++ b/sonar-batch/src/main/java/org/sonar/batch/DefaultSensorContext.java @@ -19,6 +19,9 @@ */ package org.sonar.batch; +import org.sonar.api.scan.filesystem.internal.DefaultInputFile; + +import org.sonar.api.scan.filesystem.InputFile; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,7 +41,6 @@ import org.sonar.api.resources.ProjectLink; import org.sonar.api.resources.Resource; import org.sonar.api.resources.Scopes; import org.sonar.api.rules.Violation; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.api.utils.SonarException; import org.sonar.core.measure.MeasurementFilters; @@ -258,9 +260,9 @@ public class DefaultSensorContext implements SensorContext { String languageKey = inputFile.attribute(InputFile.ATTRIBUTE_LANGUAGE); boolean unitTest = InputFile.TYPE_TEST.equals(inputFile.attribute(InputFile.ATTRIBUTE_TYPE)); if (Java.KEY.equals(languageKey)) { - return JavaFile.create(inputFile.path(), inputFile.attribute(InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH), unitTest); + return JavaFile.create(inputFile.path(), inputFile.attribute(DefaultInputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH), unitTest); } else { - return File.create(inputFile.path(), inputFile.attribute(InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH), languages.get(languageKey), unitTest); + return File.create(inputFile.path(), inputFile.attribute(DefaultInputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH), languages.get(languageKey), unitTest); } } } diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java index 4931060321c..f387bebe1b6 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java @@ -19,6 +19,9 @@ */ package org.sonar.batch.index; +import org.sonar.api.scan.filesystem.internal.DefaultInputFile; + +import org.sonar.api.scan.filesystem.InputFile; import com.google.common.collect.Maps; import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.StringUtils; @@ -34,7 +37,6 @@ import org.sonar.api.resources.Qualifiers; import org.sonar.api.resources.Resource; import org.sonar.api.resources.ResourceUtils; import org.sonar.api.resources.Scopes; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.api.security.ResourcePermissions; import org.sonar.api.utils.SonarException; @@ -145,9 +147,9 @@ public final class DefaultResourcePersister implements ResourcePersister { String languageKey = inputFile.attribute(InputFile.ATTRIBUTE_LANGUAGE); boolean unitTest = InputFile.TYPE_TEST.equals(inputFile.attribute(InputFile.ATTRIBUTE_TYPE)); if (Java.KEY.equals(languageKey)) { - return JavaFile.create(inputFile.path(), inputFile.attribute(InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH), unitTest); + return JavaFile.create(inputFile.path(), inputFile.attribute(DefaultInputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH), unitTest); } else { - return File.create(inputFile.path(), inputFile.attribute(InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH), null, unitTest); + return File.create(inputFile.path(), inputFile.attribute(DefaultInputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH), null, unitTest); } } diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java b/sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java index ae97d13aa4e..0fe99a889ad 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java @@ -19,6 +19,8 @@ */ package org.sonar.batch.index; +import org.sonar.api.scan.filesystem.InputFile; + import com.google.common.annotations.VisibleForTesting; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; @@ -34,7 +36,6 @@ import org.sonar.api.resources.Qualifiers; import org.sonar.api.resources.Resource; import org.sonar.api.resources.Scopes; import org.sonar.api.scan.filesystem.internal.DefaultInputFile; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.api.utils.PathUtils; import java.util.HashMap; diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/ResourcePersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/ResourcePersister.java index 8e41528ba36..100c8b34273 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/ResourcePersister.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/ResourcePersister.java @@ -19,10 +19,11 @@ */ package org.sonar.batch.index; +import org.sonar.api.scan.filesystem.InputFile; + import org.sonar.api.database.model.Snapshot; import org.sonar.api.resources.Project; import org.sonar.api.resources.Resource; -import org.sonar.api.scan.filesystem.internal.InputFile; public interface ResourcePersister { diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/AttributeFilter.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/AttributeFilter.java index f7f0ecfa831..1276c11168a 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/AttributeFilter.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/AttributeFilter.java @@ -19,8 +19,9 @@ */ package org.sonar.batch.scan.filesystem; +import org.sonar.api.scan.filesystem.InputFile; + import com.google.common.annotations.VisibleForTesting; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.api.scan.filesystem.internal.InputFileFilter; import java.util.Collection; diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java index c1e97a05f56..ad0064f565c 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java @@ -19,6 +19,9 @@ */ package org.sonar.batch.scan.filesystem; +import org.sonar.api.scan.filesystem.internal.DefaultInputFile; + +import org.sonar.api.scan.filesystem.InputFile; import com.google.common.base.CharMatcher; import com.google.common.io.Files; import org.apache.commons.lang.StringUtils; @@ -34,7 +37,6 @@ import org.sonar.api.resources.Languages; import org.sonar.api.resources.Project; import org.sonar.api.resources.Resource; import org.sonar.api.scan.filesystem.FileQuery; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.api.utils.SonarException; import org.sonar.batch.index.ResourceKeyMigration; import org.sonar.batch.scan.language.DefaultModuleLanguages; @@ -76,9 +78,9 @@ public class ComponentIndexer implements BatchComponent { boolean unitTest = InputFile.TYPE_TEST.equals(inputFile.attribute(InputFile.ATTRIBUTE_TYPE)); Resource sonarFile; if (Java.KEY.equals(languageKey)) { - sonarFile = JavaFile.create(inputFile.path(), inputFile.attribute(InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH), unitTest); + sonarFile = JavaFile.create(inputFile.path(), inputFile.attribute(DefaultInputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH), unitTest); } else { - sonarFile = File.create(inputFile.path(), inputFile.attribute(InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH), languages.get(languageKey), unitTest); + sonarFile = File.create(inputFile.path(), inputFile.attribute(DefaultInputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH), languages.get(languageKey), unitTest); } if (sonarFile != null) { moduleLanguages.addLanguage(languageKey); 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 80bc58ad5eb..7d624ed8b89 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 @@ -27,8 +27,9 @@ import org.sonar.api.CoreProperties; import org.sonar.api.config.Settings; import org.sonar.api.resources.Project; import org.sonar.api.scan.filesystem.FileQuery; +import org.sonar.api.scan.filesystem.InputDir; +import org.sonar.api.scan.filesystem.InputFile; import org.sonar.api.scan.filesystem.ModuleFileSystem; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.api.scan.filesystem.internal.InputFiles; import org.sonar.api.utils.SonarException; import org.sonar.batch.bootstrap.AnalysisMode; @@ -58,7 +59,7 @@ public class DefaultModuleFileSystem implements ModuleFileSystem { private List<File> testFiles = Lists.newArrayList(); private AnalysisMode analysisMode; private ComponentIndexer componentIndexer; - private boolean indexed; + private boolean initialized; public DefaultModuleFileSystem(Project module, Settings settings, FileIndex index, ModuleFileSystemInitializer initializer, AnalysisMode analysisMode, ComponentIndexer componentIndexer) { @@ -77,6 +78,10 @@ public class DefaultModuleFileSystem implements ModuleFileSystem { this.testFiles = initializer.additionalTestFiles(); } + public boolean isInitialized() { + return initialized; + } + public String moduleKey() { return moduleKey; } @@ -157,7 +162,11 @@ public class DefaultModuleFileSystem implements ModuleFileSystem { /** * @since 4.0 */ + @Override public Iterable<InputFile> inputFiles(FileQuery query) { + if (!initialized) { + throw new SonarException("Module filesystem is not initialized"); + } List<InputFile> result = Lists.newArrayList(); FileQueryFilter filter = new FileQueryFilter(analysisMode, query); for (InputFile input : index.inputFiles(moduleKey)) { @@ -169,11 +178,30 @@ public class DefaultModuleFileSystem implements ModuleFileSystem { } @Override + public InputFile inputFile(File ioFile) { + if (!ioFile.isFile()) { + throw new SonarException(ioFile.getAbsolutePath() + "is not a file"); + } + return index.inputFile(this, ioFile); + } + + @Override + public InputDir inputDir(File ioFile) { + if (!ioFile.isDirectory()) { + throw new SonarException(ioFile.getAbsolutePath() + "is not a directory"); + } + return index.inputDir(this, ioFile); + } + + @Override public List<File> files(FileQuery query) { return InputFiles.toFiles(inputFiles(query)); } public void resetDirs(File basedir, File buildDir, List<File> sourceDirs, List<File> testDirs, List<File> binaryDirs) { + if (initialized) { + throw new SonarException("Module filesystem is locked"); + } Preconditions.checkNotNull(basedir, "Basedir can't be null"); this.baseDir = basedir; this.buildDir = buildDir; @@ -183,10 +211,10 @@ public class DefaultModuleFileSystem implements ModuleFileSystem { } public void index() { - if (indexed) { + if (initialized) { throw new SonarException("Module filesystem can only be indexed once"); } - indexed = true; + initialized = true; index.index(this); componentIndexer.execute(this); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DeprecatedFileFilters.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DeprecatedFileFilters.java index 1c49ec7e85f..5ce26537016 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DeprecatedFileFilters.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DeprecatedFileFilters.java @@ -19,8 +19,9 @@ */ package org.sonar.batch.scan.filesystem; +import org.sonar.api.scan.filesystem.internal.DefaultInputFile; + import org.sonar.api.scan.filesystem.*; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.api.scan.filesystem.internal.InputFileFilter; import java.io.File; @@ -69,13 +70,13 @@ public class DeprecatedFileFilters implements InputFileFilter { @Override public File relativeDir() { - String path = inputFile.attribute(InputFile.ATTRIBUTE_SOURCEDIR_PATH); + String path = inputFile.attribute(DefaultInputFile.ATTRIBUTE_SOURCEDIR_PATH); return path != null ? new File(path) : null; } @Override public String relativePath() { - return inputFile.attribute(InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH); + return inputFile.attribute(DefaultInputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH); } @Override diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilter.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilter.java index 4f04f6b41d0..8ce2feff037 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilter.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilter.java @@ -19,7 +19,8 @@ */ package org.sonar.batch.scan.filesystem; -import org.sonar.api.scan.filesystem.internal.InputFile; +import org.sonar.api.scan.filesystem.InputFile; + import org.sonar.api.scan.filesystem.internal.InputFileFilter; class ExclusionFilter implements InputFileFilter { diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java index 432ba2a695b..f52cd807076 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java @@ -19,6 +19,8 @@ */ package org.sonar.batch.scan.filesystem; +import org.sonar.api.scan.filesystem.InputFile; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.api.BatchComponent; @@ -26,7 +28,6 @@ import org.sonar.api.batch.ResourceFilter; import org.sonar.api.resources.Resource; import org.sonar.api.resources.ResourceUtils; import org.sonar.api.scan.filesystem.FileExclusions; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.api.scan.filesystem.internal.InputFileFilter; public class ExclusionFilters implements InputFileFilter, ResourceFilter, BatchComponent { @@ -58,7 +59,7 @@ public class ExclusionFilters implements InputFileFilter, ResourceFilter, BatchC String type = inputFile.attribute(InputFile.ATTRIBUTE_TYPE); PathPattern[] inclusionPatterns = null; PathPattern[] exclusionPatterns = null; - if (InputFile.TYPE_SOURCE.equals(type)) { + if (InputFile.TYPE_MAIN.equals(type)) { inclusionPatterns = sourceInclusions(); exclusionPatterns = sourceExclusions(); } else if (InputFile.TYPE_TEST.equals(type)) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndex.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndex.java index 34d117be2ee..a6d34469019 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndex.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndex.java @@ -31,10 +31,12 @@ import org.sonar.api.BatchComponent; import org.sonar.api.resources.Java; import org.sonar.api.resources.JavaFile; import org.sonar.api.resources.Project; +import org.sonar.api.scan.filesystem.InputDir; +import org.sonar.api.scan.filesystem.InputFile; import org.sonar.api.scan.filesystem.ModuleFileSystem; import org.sonar.api.scan.filesystem.PathResolver; +import org.sonar.api.scan.filesystem.internal.DefaultInputDir; import org.sonar.api.scan.filesystem.internal.DefaultInputFile; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.api.scan.filesystem.internal.InputFileFilter; import org.sonar.api.utils.PathUtils; @@ -73,7 +75,7 @@ public class FileIndex implements BatchComponent { private final PathResolver pathResolver; private final List<InputFileFilter> filters; private final LanguageRecognizer languageRecognizer; - private final InputFileCache cache; + private final InputFileCache fileCache; private final FileHashes fileHashes; private final Project project; @@ -81,7 +83,7 @@ public class FileIndex implements BatchComponent { InputFileCache cache, FileHashes fileHashes, PathResolver pathResolver, Project project) { this.filters = filters; this.languageRecognizer = languageRecognizer; - this.cache = cache; + this.fileCache = cache; this.fileHashes = fileHashes; this.pathResolver = pathResolver; this.project = project; @@ -92,16 +94,16 @@ public class FileIndex implements BatchComponent { logger.info("Index files"); // TODO log configuration too (replace FileSystemLogger) - Progress progress = new Progress(cache.fileRelativePaths(fileSystem.moduleKey())); + Progress progress = new Progress(fileCache.fileRelativePaths(fileSystem.moduleKey())); if (fileSystem.sourceFiles().isEmpty()) { // index directories for (File sourceDir : fileSystem.sourceDirs()) { - indexDirectory(fileSystem, progress, sourceDir, InputFile.TYPE_SOURCE); + indexDirectory(fileSystem, progress, sourceDir, InputFile.TYPE_MAIN); } } else { // index only given files - indexFiles(fileSystem, progress, fileSystem.sourceDirs(), fileSystem.sourceFiles(), InputFile.TYPE_SOURCE); + indexFiles(fileSystem, progress, fileSystem.sourceDirs(), fileSystem.sourceFiles(), InputFile.TYPE_MAIN); } if (fileSystem.testFiles().isEmpty()) { @@ -116,7 +118,7 @@ public class FileIndex implements BatchComponent { // Remove files that have been removed since previous indexation for (String path : progress.removedPaths) { - cache.remove(fileSystem.moduleKey(), path); + fileCache.remove(fileSystem.moduleKey(), path); } logger.info(String.format("%d files indexed", progress.count)); @@ -137,7 +139,22 @@ public class FileIndex implements BatchComponent { } Iterable<InputFile> inputFiles(String moduleKey) { - return cache.byModule(moduleKey); + return fileCache.byModule(moduleKey); + } + + InputFile inputFile(DefaultModuleFileSystem fileSystem, File ioFile) { + String path = computeFilePath(fileSystem, ioFile); + return fileCache.byPath(fileSystem.moduleKey(), path); + } + + InputDir inputDir(DefaultModuleFileSystem fileSystem, File ioFile) { + String path = computeFilePath(fileSystem, ioFile); + // TODO no cache for InputDir + Map<String, String> attributes = Maps.newHashMap(); + // paths + String resourceKey = PathUtils.sanitize(path); + set(attributes, DefaultInputFile.ATTRIBUTE_COMPONENT_KEY, project.getEffectiveKey() + ":" + resourceKey); + return DefaultInputDir.create(ioFile, path, attributes); } private void indexDirectory(DefaultModuleFileSystem fileSystem, Progress status, File sourceDir, String type) { @@ -148,18 +165,23 @@ public class FileIndex implements BatchComponent { } private void indexFile(DefaultModuleFileSystem fileSystem, Progress status, File sourceDir, File file, String type) { - String path = pathResolver.relativePath(fileSystem.baseDir(), file); + String path = computeFilePath(fileSystem, file); if (path == null) { LoggerFactory.getLogger(getClass()).warn(String.format("File '%s' is not in basedir '%s'", file.getAbsolutePath(), fileSystem.baseDir())); } else { InputFile input = newInputFile(fileSystem, sourceDir, type, file, path); if (input != null && accept(input)) { - cache.put(fileSystem.moduleKey(), input); + fileCache.put(fileSystem.moduleKey(), input); status.markAsIndexed(path); } } } + private String computeFilePath(DefaultModuleFileSystem fileSystem, File file) { + String path = pathResolver.relativePath(fileSystem.baseDir(), file); + return path; + } + @CheckForNull private InputFile newInputFile(ModuleFileSystem fileSystem, File sourceDir, String type, File file, String path) { @@ -167,9 +189,9 @@ public class FileIndex implements BatchComponent { set(attributes, InputFile.ATTRIBUTE_TYPE, type); // paths - set(attributes, InputFile.ATTRIBUTE_SOURCEDIR_PATH, PathUtils.canonicalPath(sourceDir)); + set(attributes, DefaultInputFile.ATTRIBUTE_SOURCEDIR_PATH, PathUtils.canonicalPath(sourceDir)); String sourceRelativePath = pathResolver.relativePath(sourceDir, file); - set(attributes, InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, sourceRelativePath); + set(attributes, DefaultInputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, sourceRelativePath); String resourceKey = PathUtils.sanitize(path); set(attributes, DefaultInputFile.ATTRIBUTE_COMPONENT_KEY, project.getEffectiveKey() + ":" + resourceKey); @@ -193,7 +215,7 @@ public class FileIndex implements BatchComponent { private void initStatus(File file, Charset charset, String baseRelativePath, Map<String, String> attributes) { String hash = fileHashes.hash(file, charset); - set(attributes, InputFile.ATTRIBUTE_HASH, hash); + set(attributes, DefaultInputFile.ATTRIBUTE_HASH, hash); String remoteHash = fileHashes.remoteHash(baseRelativePath); // currently no need to store this remote hash in attributes diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileQueryFilter.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileQueryFilter.java index 4dad09db531..38affb34c3e 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileQueryFilter.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileQueryFilter.java @@ -19,10 +19,11 @@ */ package org.sonar.batch.scan.filesystem; +import org.sonar.api.scan.filesystem.InputFile; + import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Lists; import org.sonar.api.scan.filesystem.FileQuery; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.api.scan.filesystem.internal.InputFileFilter; import org.sonar.batch.bootstrap.AnalysisMode; diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InclusionFilter.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InclusionFilter.java index 4e622372333..c9fe825027c 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InclusionFilter.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InclusionFilter.java @@ -19,7 +19,8 @@ */ package org.sonar.batch.scan.filesystem; -import org.sonar.api.scan.filesystem.internal.InputFile; +import org.sonar.api.scan.filesystem.InputFile; + import org.sonar.api.scan.filesystem.internal.InputFileFilter; class InclusionFilter implements InputFileFilter { diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileCache.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileCache.java index bf360a7e419..7ab06aec59b 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileCache.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileCache.java @@ -20,10 +20,12 @@ package org.sonar.batch.scan.filesystem; import org.sonar.api.BatchComponent; -import org.sonar.api.scan.filesystem.internal.InputFile; +import org.sonar.api.scan.filesystem.InputFile; import org.sonar.batch.index.Cache; import org.sonar.batch.index.Caches; +import javax.annotation.CheckForNull; + import java.util.Set; /** @@ -43,6 +45,11 @@ public class InputFileCache implements BatchComponent { return cache.values(moduleKey); } + @CheckForNull + public InputFile byPath(String moduleKey, String path) { + return cache.get(moduleKey, path); + } + public InputFileCache removeModule(String moduleKey) { cache.clear(moduleKey); return this; diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/LanguageRecognizer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/LanguageRecognizer.java index 26d898ff2ea..ff4fd3c3006 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/LanguageRecognizer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/LanguageRecognizer.java @@ -19,6 +19,8 @@ */ package org.sonar.batch.scan.filesystem; +import org.sonar.api.scan.filesystem.InputFile; + import com.google.common.collect.HashMultimap; import com.google.common.collect.Maps; import com.google.common.collect.SetMultimap; @@ -32,7 +34,6 @@ import org.sonar.api.CoreProperties; import org.sonar.api.config.Settings; import org.sonar.api.resources.Language; import org.sonar.api.resources.Languages; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.api.utils.SonarException; import javax.annotation.CheckForNull; diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/PathPattern.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/PathPattern.java index 650f447e476..4ac66004469 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/PathPattern.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/PathPattern.java @@ -19,9 +19,10 @@ */ package org.sonar.batch.scan.filesystem; +import org.sonar.api.scan.filesystem.InputFile; + import org.apache.commons.lang.StringUtils; import org.sonar.api.resources.Resource; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.api.utils.WildcardPattern; abstract class PathPattern { diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapter.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapter.java index c984d231316..39c139315c5 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapter.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapter.java @@ -186,10 +186,10 @@ public class ProjectFileSystemAdapter implements ProjectFileSystem { public List<InputFile> mainFiles(String... langs) { List<InputFile> result = Lists.newArrayList(); - Iterable<org.sonar.api.scan.filesystem.internal.InputFile> files = target.inputFiles(FileQuery.onSource().onLanguage(langs)); - for (org.sonar.api.scan.filesystem.internal.InputFile file : files) { - String sourceDir = file.attribute(org.sonar.api.scan.filesystem.internal.InputFile.ATTRIBUTE_SOURCEDIR_PATH); - String sourceRelativePath = file.attribute(org.sonar.api.scan.filesystem.internal.InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH); + Iterable<org.sonar.api.scan.filesystem.InputFile> files = target.inputFiles(FileQuery.onSource().onLanguage(langs)); + for (org.sonar.api.scan.filesystem.InputFile file : files) { + String sourceDir = file.attribute(org.sonar.api.scan.filesystem.internal.DefaultInputFile.ATTRIBUTE_SOURCEDIR_PATH); + String sourceRelativePath = file.attribute(org.sonar.api.scan.filesystem.internal.DefaultInputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH); if (sourceDir != null && sourceRelativePath != null) { result.add(InputFileUtils.create(new File(sourceDir), sourceRelativePath)); } @@ -199,10 +199,10 @@ public class ProjectFileSystemAdapter implements ProjectFileSystem { public List<InputFile> testFiles(String... langs) { List<InputFile> result = Lists.newArrayList(); - Iterable<org.sonar.api.scan.filesystem.internal.InputFile> files = target.inputFiles(FileQuery.onTest().onLanguage(langs)); - for (org.sonar.api.scan.filesystem.internal.InputFile file : files) { - String sourceDir = file.attribute(org.sonar.api.scan.filesystem.internal.InputFile.ATTRIBUTE_SOURCEDIR_PATH); - String sourceRelativePath = file.attribute(org.sonar.api.scan.filesystem.internal.InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH); + Iterable<org.sonar.api.scan.filesystem.InputFile> files = target.inputFiles(FileQuery.onTest().onLanguage(langs)); + for (org.sonar.api.scan.filesystem.InputFile file : files) { + String sourceDir = file.attribute(org.sonar.api.scan.filesystem.internal.DefaultInputFile.ATTRIBUTE_SOURCEDIR_PATH); + String sourceRelativePath = file.attribute(org.sonar.api.scan.filesystem.internal.DefaultInputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH); if (sourceDir != null && sourceRelativePath != null) { result.add(InputFileUtils.create(new File(sourceDir), sourceRelativePath)); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/report/IncrementalComponentSelector.java b/sonar-batch/src/main/java/org/sonar/batch/scan/report/IncrementalComponentSelector.java index 0317edf8b0b..9c18af551fc 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/report/IncrementalComponentSelector.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/report/IncrementalComponentSelector.java @@ -19,10 +19,11 @@ */ package org.sonar.batch.scan.report; +import org.sonar.api.scan.filesystem.InputFile; + import com.google.common.collect.Sets; import org.sonar.api.issue.Issue; import org.sonar.api.scan.filesystem.internal.DefaultInputFile; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.batch.scan.filesystem.InputFileCache; import java.util.Set; diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/ResourceKeyMigrationTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/ResourceKeyMigrationTest.java index aad9df2dce5..a03d50f5631 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/index/ResourceKeyMigrationTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/index/ResourceKeyMigrationTest.java @@ -19,6 +19,8 @@ */ package org.sonar.batch.index; +import org.sonar.api.scan.filesystem.InputFile; + import com.google.common.base.Charsets; import org.apache.commons.configuration.PropertiesConfiguration; import org.junit.Before; @@ -29,7 +31,6 @@ import org.junit.rules.TemporaryFolder; import org.slf4j.Logger; import org.sonar.api.resources.Project; import org.sonar.api.scan.filesystem.internal.DefaultInputFile; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.api.scan.filesystem.internal.InputFileBuilder; import org.sonar.jpa.test.AbstractDbUnitTestCase; @@ -94,7 +95,7 @@ public class ResourceKeyMigrationTest extends AbstractDbUnitTestCase { return new InputFileBuilder(file, Charsets.UTF_8, path) .attribute(DefaultInputFile.ATTRIBUTE_COMPONENT_KEY, effectiveKey) .attribute(DefaultInputFile.ATTRIBUTE_COMPONENT_DEPRECATED_KEY, deprecatedEffectiveKey) - .attribute(InputFile.ATTRIBUTE_TYPE, isTest ? InputFile.TYPE_TEST : InputFile.TYPE_SOURCE).build(); + .attribute(InputFile.ATTRIBUTE_TYPE, isTest ? InputFile.TYPE_TEST : InputFile.TYPE_MAIN).build(); } @Test diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ComponentIndexerTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ComponentIndexerTest.java index a64b859cc9d..c0945f0f570 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ComponentIndexerTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ComponentIndexerTest.java @@ -19,6 +19,8 @@ */ package org.sonar.batch.scan.filesystem; +import org.sonar.api.scan.filesystem.InputFile; + import com.google.common.base.Charsets; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.CharEncoding; @@ -40,7 +42,6 @@ import org.sonar.api.resources.Qualifiers; import org.sonar.api.resources.Resource; import org.sonar.api.scan.filesystem.FileQuery; import org.sonar.api.scan.filesystem.internal.DefaultInputFile; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.api.scan.filesystem.internal.InputFileBuilder; import org.sonar.batch.index.ResourceKeyMigration; import org.sonar.batch.scan.language.DefaultModuleLanguages; @@ -153,9 +154,9 @@ public class ComponentIndexerTest { File file = new File(baseDir, path); FileUtils.write(file, content); return new InputFileBuilder(file, Charsets.UTF_8, path) - .attribute(InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, sourceRelativePath) + .attribute(DefaultInputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, sourceRelativePath) .attribute(InputFile.ATTRIBUTE_LANGUAGE, languageKey) - .attribute(InputFile.ATTRIBUTE_TYPE, unitTest ? InputFile.TYPE_TEST : InputFile.TYPE_SOURCE) + .attribute(InputFile.ATTRIBUTE_TYPE, unitTest ? InputFile.TYPE_TEST : InputFile.TYPE_MAIN) .build(); } @@ -188,7 +189,7 @@ public class ComponentIndexerTest { FileUtils.write(javaFile1, "\uFEFFpublic class Test", Charsets.UTF_8); when(fs.inputFiles(FileQuery.all())).thenReturn((Iterable) Arrays.asList( new InputFileBuilder(javaFile1, Charset.forName("UTF-8"), "src/main/java/foo/bar/Foo.java") - .attribute(InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "foo/bar/Foo.java") + .attribute(DefaultInputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "foo/bar/Foo.java") .attribute(InputFile.ATTRIBUTE_LANGUAGE, "java") .build())); when(project.getLanguageKey()).thenReturn(Java.KEY); @@ -217,7 +218,7 @@ public class ComponentIndexerTest { .thenReturn( (Iterable) Arrays.asList( new InputFileBuilder(javaFile1, Charset.forName(encoding), "src/main/java/foo/bar/Foo.java") - .attribute(InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "foo/bar/Foo.java") + .attribute(DefaultInputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "foo/bar/Foo.java") .attribute(InputFile.ATTRIBUTE_LANGUAGE, "java") .build())); when(project.getLanguageKey()).thenReturn(Java.KEY); diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystemTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystemTest.java index ef1298b4514..4041895dff4 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystemTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystemTest.java @@ -32,8 +32,8 @@ import org.sonar.api.CoreProperties; import org.sonar.api.config.Settings; import org.sonar.api.resources.Project; import org.sonar.api.scan.filesystem.FileQuery; +import org.sonar.api.scan.filesystem.InputFile; import org.sonar.api.scan.filesystem.internal.DefaultInputFile; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.batch.bootstrap.AnalysisMode; import java.io.File; @@ -162,11 +162,12 @@ public class DefaultModuleFileSystemTest { DefaultModuleFileSystem fs = new DefaultModuleFileSystem(new Project("foo"), settings, fileIndex, initializer, mode, componentIndexer); File mainFile = temp.newFile(); - InputFile mainInput = DefaultInputFile.create(mainFile, Charsets.UTF_8, "Main.java", ImmutableMap.of(InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_SOURCE)); + InputFile mainInput = DefaultInputFile.create(mainFile, Charsets.UTF_8, "Main.java", ImmutableMap.of(InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_MAIN)); InputFile testInput = DefaultInputFile.create(temp.newFile(), Charsets.UTF_8, "Test.java", ImmutableMap.of(InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_TEST)); when(fileIndex.inputFiles("foo")).thenReturn(Lists.newArrayList(mainInput, testInput)); + fs.index(); Iterable<InputFile> inputFiles = fs.inputFiles(FileQuery.onSource()); assertThat(inputFiles).containsOnly(mainInput); diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DeprecatedFileFiltersTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DeprecatedFileFiltersTest.java index 58ba069883d..6fafbb57e20 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DeprecatedFileFiltersTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DeprecatedFileFiltersTest.java @@ -19,6 +19,8 @@ */ package org.sonar.batch.scan.filesystem; +import org.sonar.api.scan.filesystem.InputFile; + import com.google.common.base.Charsets; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; @@ -30,7 +32,6 @@ import org.mockito.ArgumentCaptor; import org.sonar.api.scan.filesystem.FileSystemFilter; import org.sonar.api.scan.filesystem.FileType; import org.sonar.api.scan.filesystem.internal.DefaultInputFile; -import org.sonar.api.scan.filesystem.internal.InputFile; import java.io.File; @@ -63,8 +64,8 @@ public class DeprecatedFileFiltersTest { File basedir = temp.newFolder(); File file = temp.newFile(); InputFile inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java/Foo.java", ImmutableMap.of( - InputFile.ATTRIBUTE_SOURCEDIR_PATH, new File(basedir, "src/main/java").getAbsolutePath(), - InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "Foo.java", + DefaultInputFile.ATTRIBUTE_SOURCEDIR_PATH, new File(basedir, "src/main/java").getAbsolutePath(), + DefaultInputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "Foo.java", InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_TEST )); diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ExclusionFilterTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ExclusionFilterTest.java index 66c2990ec24..1f2551a119c 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ExclusionFilterTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ExclusionFilterTest.java @@ -19,13 +19,14 @@ */ package org.sonar.batch.scan.filesystem; +import org.sonar.api.scan.filesystem.InputFile; + import com.google.common.base.Charsets; import com.google.common.collect.ImmutableMap; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.sonar.api.scan.filesystem.internal.DefaultInputFile; -import org.sonar.api.scan.filesystem.internal.InputFile; import java.io.File; @@ -43,7 +44,7 @@ public class ExclusionFilterTest { File file = new File(temp.newFolder(), "src/main/java/org/MyFoo.java"); InputFile inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java/org/MyFoo.java", ImmutableMap.of( - InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "org/MyFoo.java" + DefaultInputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "org/MyFoo.java" )); assertThat(sourceRelativeFilter.accept(inputFile)).isFalse(); @@ -51,7 +52,7 @@ public class ExclusionFilterTest { file = new File(temp.newFolder(), "src/main/java/org/Other.java"); inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java/org/Other.java", ImmutableMap.of( - InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "org/Other.java" + DefaultInputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "org/Other.java" )); assertThat(sourceRelativeFilter.accept(inputFile)).isTrue(); assertThat(absoluteFilter.accept(inputFile)).isTrue(); diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ExclusionFiltersTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ExclusionFiltersTest.java index 62f844b7aa6..3a8a06a7b6f 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ExclusionFiltersTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ExclusionFiltersTest.java @@ -19,6 +19,8 @@ */ package org.sonar.batch.scan.filesystem; +import org.sonar.api.scan.filesystem.InputFile; + import com.google.common.base.Charsets; import com.google.common.collect.ImmutableMap; import org.junit.Rule; @@ -31,7 +33,6 @@ import org.sonar.api.resources.JavaFile; import org.sonar.api.resources.Project; import org.sonar.api.scan.filesystem.FileExclusions; import org.sonar.api.scan.filesystem.internal.DefaultInputFile; -import org.sonar.api.scan.filesystem.internal.InputFile; import java.io.IOException; @@ -50,22 +51,22 @@ public class ExclusionFiltersTest { java.io.File file = temp.newFile(); InputFile inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java/com/mycompany/Foo.java", ImmutableMap.of( - InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_SOURCE, - InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "com/mycompany/Foo.java" + InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_MAIN, + DefaultInputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "com/mycompany/Foo.java" )); assertThat(filter.accept(inputFile)).isFalse(); inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java/com/mycompany/FooDao.java", ImmutableMap.of( - InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_SOURCE, - InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "com/mycompany/FooDao.java" + InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_MAIN, + DefaultInputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "com/mycompany/FooDao.java" )); assertThat(filter.accept(inputFile)).isTrue(); // source inclusions do not apply to tests inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java/com/mycompany/Foo.java", ImmutableMap.of( InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_TEST, - InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "com/mycompany/Foo.java" + DefaultInputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "com/mycompany/Foo.java" )); assertThat(filter.accept(inputFile)).isTrue(); } @@ -78,15 +79,15 @@ public class ExclusionFiltersTest { java.io.File file = temp.newFile(); InputFile inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java/com/mycompany/Foo.java", ImmutableMap.of( - InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_SOURCE, - InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "com/mycompany/Foo.java" + InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_MAIN, + DefaultInputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "com/mycompany/Foo.java" )); assertThat(filter.accept(inputFile)).isFalse(); inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java/com/mycompany/FooDto.java", ImmutableMap.of( - InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_SOURCE, - InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "com/mycompany/FooDto.java" + InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_MAIN, + DefaultInputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "com/mycompany/FooDto.java" )); assertThat(filter.accept(inputFile)).isTrue(); } @@ -99,21 +100,21 @@ public class ExclusionFiltersTest { java.io.File file = temp.newFile(); InputFile inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java/com/mycompany/FooDao.java", ImmutableMap.of( - InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_SOURCE, - InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "com/mycompany/FooDao.java" + InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_MAIN, + DefaultInputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "com/mycompany/FooDao.java" )); assertThat(filter.accept(inputFile)).isFalse(); inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java/com/mycompany/Foo.java", ImmutableMap.of( - InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_SOURCE, - InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "com/mycompany/Foo.java" + InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_MAIN, + DefaultInputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "com/mycompany/Foo.java" )); assertThat(filter.accept(inputFile)).isTrue(); // source exclusions do not apply to tests inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java/com/mycompany/FooDao.java", ImmutableMap.of( InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_TEST, - InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "com/mycompany/FooDao.java" + DefaultInputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "com/mycompany/FooDao.java" )); assertThat(filter.accept(inputFile)).isTrue(); } @@ -128,12 +129,12 @@ public class ExclusionFiltersTest { ExclusionFilters filter = new ExclusionFilters(new FileExclusions(settings)); InputFile includedInput = DefaultInputFile.create(includedFile, Charsets.UTF_8, "src/main/java/org/bar/Foo.java", ImmutableMap.of( - InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_SOURCE + InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_MAIN )); assertThat(filter.accept(includedInput)).isTrue(); InputFile excludedInput = DefaultInputFile.create(excludedFile, Charsets.UTF_8, "src/main/java/org/bar/Bar.java", ImmutableMap.of( - InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_SOURCE + InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_MAIN )); assertThat(filter.accept(excludedInput)).isFalse(); } diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/FileIndexTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/FileIndexTest.java new file mode 100644 index 00000000000..a72e48f6f7d --- /dev/null +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/FileIndexTest.java @@ -0,0 +1,54 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.batch.scan.filesystem; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.sonar.api.resources.Project; +import org.sonar.api.scan.filesystem.InputDir; +import org.sonar.api.scan.filesystem.PathResolver; +import org.sonar.api.scan.filesystem.internal.DefaultInputDir; + +import java.io.File; + +import static org.fest.assertions.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class FileIndexTest { + + @Rule + public TemporaryFolder temp = new TemporaryFolder(); + + @Test + public void should_return_inputDir() throws Exception { + FileIndex index = new FileIndex(null, null, null, null, new PathResolver(), new Project("myProject")); + File baseDir = temp.newFolder(); + DefaultModuleFileSystem fileSystem = mock(DefaultModuleFileSystem.class); + when(fileSystem.baseDir()).thenReturn(baseDir); + File ioFile = new File(baseDir, "src/main/java/com/foo"); + InputDir inputDir = index.inputDir(fileSystem, ioFile); + + assertThat(inputDir.name()).isEqualTo("src/main/java/com/foo"); + assertThat(inputDir.file()).isEqualTo(ioFile); + assertThat(inputDir.attribute(DefaultInputDir.ATTRIBUTE_COMPONENT_KEY)).isEqualTo("myProject:src/main/java/com/foo"); + } +} diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/FileQueryFilterTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/FileQueryFilterTest.java index b7e24b08af6..791ec2f251b 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/FileQueryFilterTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/FileQueryFilterTest.java @@ -19,13 +19,13 @@ */ package org.sonar.batch.scan.filesystem; +import org.sonar.api.scan.filesystem.InputFile; + import org.junit.Before; import org.junit.Test; import org.sonar.api.scan.filesystem.FileQuery; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.api.scan.filesystem.internal.InputFileFilter; import org.sonar.batch.bootstrap.AnalysisMode; - import static org.fest.assertions.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -48,7 +48,7 @@ public class FileQueryFilterTest { InputFileFilter typeFilter = filter.filters().get(0); assertThat(typeFilter).isInstanceOf(AttributeFilter.class); assertThat(((AttributeFilter) typeFilter).key()).isEqualTo(InputFile.ATTRIBUTE_TYPE); - assertThat(((AttributeFilter) typeFilter).values()).containsOnly(InputFile.TYPE_SOURCE); + assertThat(((AttributeFilter) typeFilter).values()).containsOnly(InputFile.TYPE_MAIN); } @Test diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InclusionFilterTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InclusionFilterTest.java index cd76e714c66..a8ce2a9194d 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InclusionFilterTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InclusionFilterTest.java @@ -19,13 +19,14 @@ */ package org.sonar.batch.scan.filesystem; +import org.sonar.api.scan.filesystem.InputFile; + import com.google.common.base.Charsets; import com.google.common.collect.ImmutableMap; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.sonar.api.scan.filesystem.internal.DefaultInputFile; -import org.sonar.api.scan.filesystem.internal.InputFile; import java.io.File; @@ -42,7 +43,7 @@ public class InclusionFilterTest { File file = new File(temp.newFolder(), "src/main/java/org/MyFoo.java"); InputFile inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java/org/MyFoo.java", ImmutableMap.of( - InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "org/MyFoo.java" + DefaultInputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "org/MyFoo.java" )); assertThat(sourceRelativeFilter.accept(inputFile)).isTrue(); @@ -50,7 +51,7 @@ public class InclusionFilterTest { file = new File(temp.newFolder(), "src/main/java/org/Other.java"); inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java/org/Other.java", ImmutableMap.of( - InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "org/Other.java" + DefaultInputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "org/Other.java" )); assertThat(sourceRelativeFilter.accept(inputFile)).isFalse(); assertThat(absoluteFilter.accept(inputFile)).isFalse(); diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileCacheTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileCacheTest.java index 50635adc091..a829e350f3c 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileCacheTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileCacheTest.java @@ -19,6 +19,8 @@ */ package org.sonar.batch.scan.filesystem; +import org.sonar.api.scan.filesystem.InputFile; + import com.google.common.base.Charsets; import com.google.common.collect.Maps; import org.junit.After; @@ -27,10 +29,8 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.sonar.api.scan.filesystem.internal.DefaultInputFile; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.batch.index.Caches; import org.sonar.batch.index.CachesTest; - import static org.fest.assertions.Assertions.assertThat; public class InputFileCacheTest { diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/LanguageRecognizerTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/LanguageRecognizerTest.java index dad6ae8e240..9d4e8e99689 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/LanguageRecognizerTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/LanguageRecognizerTest.java @@ -19,6 +19,8 @@ */ package org.sonar.batch.scan.filesystem; +import org.sonar.api.scan.filesystem.InputFile; + import com.google.common.base.Charsets; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; @@ -30,7 +32,6 @@ import org.sonar.api.CoreProperties; import org.sonar.api.config.Settings; import org.sonar.api.resources.Language; import org.sonar.api.resources.Languages; -import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.api.scan.filesystem.internal.InputFileBuilder; import org.sonar.api.utils.SonarException; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java index 23a02fd333a..90a2179dca4 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java @@ -19,6 +19,8 @@ */ package org.sonar.api.batch; +import org.sonar.api.scan.filesystem.InputFile; + import org.sonar.api.design.Dependency; import org.sonar.api.measures.Measure; import org.sonar.api.measures.MeasuresFilter; @@ -26,7 +28,6 @@ import org.sonar.api.measures.Metric; import org.sonar.api.resources.ProjectLink; import org.sonar.api.resources.Resource; import org.sonar.api.rules.Violation; -import org.sonar.api.scan.filesystem.internal.InputFile; import java.util.Collection; import java.util.Date; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileQuery.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileQuery.java index 95dbfb0cf12..c29b31683b6 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileQuery.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileQuery.java @@ -25,7 +25,6 @@ import com.google.common.collect.Collections2; import com.google.common.collect.ListMultimap; import com.google.common.collect.Sets; import org.apache.commons.lang.builder.EqualsBuilder; -import org.sonar.api.scan.filesystem.internal.InputFile; import javax.annotation.Nullable; @@ -44,6 +43,10 @@ public class FileQuery { private final Set<String> inclusions = Sets.newHashSet(); private final Set<String> exclusions = Sets.newHashSet(); + /** + * @deprecated since 4.2 use {@link #onMain()} or {@link #onTest()} + */ + @Deprecated public static FileQuery on(FileType... types) { FileQuery query = new FileQuery(); for (FileType type : types) { @@ -59,12 +62,25 @@ public class FileQuery { return on(); } + /** + * @deprecated since 4.2 use {@link #onMain()} + */ + @Deprecated public static FileQuery onSource() { - return on(FileType.SOURCE); + return onMain(); + } + + /** + * @since 4.2 + */ + public static FileQuery onMain() { + FileQuery query = new FileQuery(); + return query.on(InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_MAIN); } public static FileQuery onTest() { - return on(FileType.TEST); + FileQuery query = new FileQuery(); + return query.on(InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_TEST); } private FileQuery() { @@ -81,6 +97,10 @@ public class FileQuery { return attributes.asMap(); } + /** + * @deprecated since 4.2 use {@link #typeAttributes()} + */ + @Deprecated public Collection<FileType> types() { return Collections2.transform(attributes.get(InputFile.ATTRIBUTE_TYPE), new Function<String, FileType>() { @Override @@ -90,6 +110,10 @@ public class FileQuery { }); } + public Collection<String> typeAttributes() { + return attributes.get(InputFile.ATTRIBUTE_TYPE); + } + public Collection<String> languages() { return attributes.get(InputFile.ATTRIBUTE_LANGUAGE); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileType.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileType.java index 6600ae2099a..31e5581db18 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileType.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileType.java @@ -21,7 +21,9 @@ package org.sonar.api.scan.filesystem; /** * @since 3.5 + * @deprecated since 4.2 use {@link InputFile#TYPE_MAIN} or {@link InputFile#TYPE_TEST} */ +@Deprecated public enum FileType { SOURCE, TEST } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/InputDir.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/InputDir.java new file mode 100644 index 00000000000..ae755fc7ab0 --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/InputDir.java @@ -0,0 +1,70 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.api.scan.filesystem; + +import javax.annotation.CheckForNull; + +import java.io.File; +import java.io.Serializable; +import java.util.Map; + +/** + * @since 4.2 + */ +public interface InputDir extends Serializable { + + /** + * Path is relative from module base directory. Path is unique and identifies file + * within given <code>{@link org.sonar.api.scan.filesystem.ModuleFileSystem}</code>. + * File separator is the forward slash ('/'), even on MSWindows. + * <p/> + * Returns <code>src/main/java/com</code> if module base dir is + * <code>/absolute/path/to/module</code> and if directory is + * <code>/absolute/path/to/module/src/main/java/com</code>. + * <p/> + * Returned path is never null. + */ + String path(); + + /** + * Not-null canonical path. File separator is forward slash ('/'), even on MSWindows. + */ + String absolutePath(); + + File file(); + + /** + * Not-null directory name + */ + String name(); + + /** + * Does the given attribute have the given value ? + */ + boolean has(String attribute, String value); + + /** + * See list of attribute keys in constants starting with ATTRIBUTE_. + */ + @CheckForNull + String attribute(String key); + + Map<String, String> attributes(); +} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFile.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/InputFile.java index 0503db1dffd..91ed1c144c1 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFile.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/InputFile.java @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.api.scan.filesystem.internal; +package org.sonar.api.scan.filesystem; import javax.annotation.CheckForNull; @@ -29,31 +29,15 @@ import java.util.Map; public interface InputFile extends Serializable { /** - * Canonical path of source directory. - * Example: <code>/path/to/module/src/main/java</code> or <code>C:\path\to\module\src\main\java</code> - * @deprecated since 4.2 No more sonar.sources - */ - @Deprecated - String ATTRIBUTE_SOURCEDIR_PATH = "SRC_DIR_PATH"; - - /** - * Relative path from source directory. File separator is the forward slash ('/'), - * even on MSWindows. - * @deprecated since 4.2 No more sonar.sources - */ - @Deprecated - String ATTRIBUTE_SOURCE_RELATIVE_PATH = "SRC_REL_PATH"; - - /** * Detected language */ String ATTRIBUTE_LANGUAGE = "LANG"; /** - * + * Type of source file. For now only possible values are {@link #TYPE_MAIN} or {@link #TYPE_TEST} */ String ATTRIBUTE_TYPE = "TYPE"; - String TYPE_SOURCE = "SOURCE"; + String TYPE_MAIN = "MAIN"; String TYPE_TEST = "TEST"; String ATTRIBUTE_STATUS = "STATUS"; @@ -61,8 +45,6 @@ public interface InputFile extends Serializable { String STATUS_CHANGED = "CHANGED"; String STATUS_ADDED = "ADDED"; - String ATTRIBUTE_HASH = "HASH"; - /** * Path is relative from module base directory. Path is unique and identifies file * within given <code>{@link org.sonar.api.scan.filesystem.ModuleFileSystem}</code>. @@ -91,8 +73,8 @@ public interface InputFile extends Serializable { String name(); /** - * Not-null type (is it a source file or a unit test file?). - * See constant values prefixed by <code>TYPE_</code>, for example {@link #TYPE_SOURCE}. + * Not-null type (is it a main file or a unit test file?). + * See constant values prefixed by <code>TYPE_</code>, for example {@link #TYPE_MAIN}. */ String type(); 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 3a055f15112..9ab95321f14 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 @@ -22,6 +22,7 @@ package org.sonar.api.scan.filesystem; import org.sonar.api.BatchComponent; import javax.annotation.CheckForNull; + import java.io.File; import java.nio.charset.Charset; import java.util.List; @@ -46,13 +47,17 @@ public interface ModuleFileSystem extends BatchComponent { /** * Source directories. Non-existing directories are excluded. * Example in Maven : ${project.basedir}/src/main/java + * @deprecated since 4.2 will always return {@link #baseDir()} */ + @Deprecated List<File> sourceDirs(); /** * Test directories. Non-existing directories are excluded. * Example in Maven : ${project.basedir}/src/test/java + * @deprecated since 4.2 will always return {@link #baseDir()} */ + @Deprecated List<File> testDirs(); /** @@ -63,17 +68,42 @@ public interface ModuleFileSystem extends BatchComponent { * <li>Binary directories can be empty</li> * <li>Test binary directories are not supported yet.</li> * </ul> + * @deprecated since 4.2 sonar.binaries should be converted to language specific property */ + @Deprecated List<File> binaryDirs(); /** * Search for files. Never return null. + * @deprecated since 4.2 use {@link #inputFiles(FileQuery)} */ + @Deprecated List<File> files(FileQuery query); /** - * Charset of source and test files. If it's not defined, then - * return the platform default charset. + * Search for input files. Never return null. + * @since 4.2 + */ + Iterable<InputFile> inputFiles(FileQuery query); + + /** + * Search for input file corresponding to the given java.io.File. + * @since 4.2 + */ + @CheckForNull + InputFile inputFile(File ioFile); + + /** + * Search for input directory corresponding to the given java.io.File. + * @since 4.2 + */ + @CheckForNull + InputDir inputDir(File ioFile); + + /** + * Default charset for files of the module. If it's not defined, then + * return the platform default charset. When trying to read an input file it is better to rely on + * {@link InputFile#encoding()} as encoding may be different for each file. */ Charset sourceCharset(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/DefaultInputDir.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/DefaultInputDir.java new file mode 100644 index 00000000000..2e83b122d02 --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/DefaultInputDir.java @@ -0,0 +1,119 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.api.scan.filesystem.internal; + +import org.apache.commons.io.FilenameUtils; +import org.apache.commons.lang.StringUtils; +import org.sonar.api.scan.filesystem.InputDir; +import org.sonar.api.utils.PathUtils; + +import javax.annotation.CheckForNull; + +import java.io.File; +import java.util.Map; + +/** + * PLUGINS MUST NOT USE THIS CLASS, EVEN FOR UNIT TESTING. + * + * @since 4.2 + */ +public class DefaultInputDir implements InputDir { + + /** + * We're not sure that this is the correct way, so not in API yet. + */ + public static final String ATTRIBUTE_COMPONENT_KEY = "CMP_KEY"; + + private final String absolutePath; + private final String path; + private final Map<String, String> attributes; + + private DefaultInputDir(File file, String path, Map<String, String> attributes) { + this.absolutePath = PathUtils.canonicalPath(file); + this.path = FilenameUtils.separatorsToUnix(path); + this.attributes = attributes; + } + + /** + * Plugins must not build their own instances of {@link InputDir}. + * {@link org.sonar.api.scan.filesystem.ModuleFileSystem} must be used to search for inputDir. + */ + public static DefaultInputDir create(File file, String path, Map<String, String> attributes) { + return new DefaultInputDir(file, path, attributes); + } + + @Override + public String path() { + return path; + } + + @Override + public String absolutePath() { + return absolutePath; + } + + @Override + public File file() { + return new File(absolutePath); + } + + @Override + public String name() { + return path(); + } + + @Override + public boolean has(String attribute, String value) { + return StringUtils.equals(attributes.get(attribute), value); + } + + @Override + @CheckForNull + public String attribute(String key) { + return attributes.get(key); + } + + @Override + public Map<String, String> attributes() { + return attributes; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DefaultInputDir other = (DefaultInputDir) o; + return absolutePath.equals(other.absolutePath); + } + + @Override + public int hashCode() { + return absolutePath.hashCode(); + } + + @Override + public String toString() { + return String.format("[%s]", path); + } +} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/DefaultInputFile.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/DefaultInputFile.java index 43024fdf860..e8ea24e1715 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/DefaultInputFile.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/DefaultInputFile.java @@ -22,6 +22,7 @@ package org.sonar.api.scan.filesystem.internal; import org.apache.commons.codec.Charsets; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang.StringUtils; +import org.sonar.api.scan.filesystem.InputFile; import org.sonar.api.utils.PathUtils; import javax.annotation.CheckForNull; @@ -44,6 +45,24 @@ public class DefaultInputFile implements InputFile { public static final String ATTRIBUTE_COMPONENT_DEPRECATED_KEY = "CMP_DEPRECATED_KEY"; + public static final String ATTRIBUTE_HASH = "HASH"; + + /** + * Relative path from source directory. File separator is the forward slash ('/'), + * even on MSWindows. + * @deprecated since 4.2 No more sonar.sources + */ + @Deprecated + public static final String ATTRIBUTE_SOURCE_RELATIVE_PATH = "SRC_REL_PATH"; + + /** + * Canonical path of source directory. + * Example: <code>/path/to/module/src/main/java</code> or <code>C:\path\to\module\src\main\java</code> + * @deprecated since 4.2 No more sonar.sources + */ + @Deprecated + public static final String ATTRIBUTE_SOURCEDIR_PATH = "SRC_DIR_PATH"; + private final String absolutePath; private final String path; private final Map<String, String> attributes; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFileBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFileBuilder.java index 0c57f806285..d7e2d730fbe 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFileBuilder.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFileBuilder.java @@ -19,6 +19,8 @@ */ package org.sonar.api.scan.filesystem.internal; +import org.sonar.api.scan.filesystem.InputFile; + import org.sonar.api.utils.PathUtils; import javax.annotation.Nullable; @@ -66,7 +68,7 @@ public class InputFileBuilder { } public InputFileBuilder hash(@Nullable String hash) { - return attribute(InputFile.ATTRIBUTE_HASH, hash); + return attribute(DefaultInputFile.ATTRIBUTE_HASH, hash); } public InputFileBuilder status(@Nullable String status) { @@ -74,11 +76,11 @@ public class InputFileBuilder { } public InputFileBuilder sourceDir(File dir) { - return attribute(InputFile.ATTRIBUTE_SOURCEDIR_PATH, PathUtils.canonicalPath(dir)); + return attribute(DefaultInputFile.ATTRIBUTE_SOURCEDIR_PATH, PathUtils.canonicalPath(dir)); } public InputFileBuilder sourceDir(@Nullable String path) { - return attribute(InputFile.ATTRIBUTE_SOURCEDIR_PATH, PathUtils.sanitize(path)); + return attribute(DefaultInputFile.ATTRIBUTE_SOURCEDIR_PATH, PathUtils.sanitize(path)); } public DefaultInputFile build() { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFileFilter.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFileFilter.java index e48880d58d5..d9c9adc8374 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFileFilter.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFileFilter.java @@ -19,8 +19,9 @@ */ package org.sonar.api.scan.filesystem.internal; +import org.sonar.api.scan.filesystem.InputFile; + import org.sonar.api.BatchExtension; -import org.sonar.api.scan.filesystem.internal.InputFile; /** * TODO document lifecycle -> executed when initializing project diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFiles.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFiles.java index f6272e24a99..923cd32b133 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFiles.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFiles.java @@ -19,8 +19,9 @@ */ package org.sonar.api.scan.filesystem.internal; +import org.sonar.api.scan.filesystem.InputFile; + import com.google.common.collect.Lists; -import org.sonar.api.scan.filesystem.internal.InputFile; import java.io.File; import java.util.List; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/internal/DefaultInputFileTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/internal/DefaultInputFileTest.java index d62a24aab72..a8346a0ccd3 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/internal/DefaultInputFileTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/internal/DefaultInputFileTest.java @@ -19,6 +19,8 @@ */ package org.sonar.api.scan.filesystem.internal; +import org.sonar.api.scan.filesystem.InputFile; + import com.google.common.base.Charsets; import org.apache.commons.io.FilenameUtils; import org.junit.Rule; @@ -51,7 +53,7 @@ public class DefaultInputFileTest { assertThat(input.attribute("unknown")).isNull(); assertThat(input.attribute("foo")).isEqualTo("bar"); assertThat(input.attribute(InputFile.ATTRIBUTE_TYPE)).isEqualTo(InputFile.TYPE_TEST); - assertThat(input.attribute(InputFile.ATTRIBUTE_HASH)).isEqualTo("ABC"); + assertThat(input.attribute(DefaultInputFile.ATTRIBUTE_HASH)).isEqualTo("ABC"); assertThat(input.attribute(InputFile.ATTRIBUTE_LANGUAGE)).isEqualTo("java"); assertThat(input.attribute(InputFile.ATTRIBUTE_STATUS)).isEqualTo(InputFile.STATUS_ADDED); @@ -70,7 +72,7 @@ public class DefaultInputFileTest { assertThat(input.name()).isEqualTo("Foo.java"); assertThat(input.file()).isEqualTo(file); - assertThat(input.attribute(InputFile.ATTRIBUTE_SOURCEDIR_PATH)).isEqualTo(FilenameUtils.separatorsToUnix(sourceDir.getAbsolutePath())); + assertThat(input.attribute(DefaultInputFile.ATTRIBUTE_SOURCEDIR_PATH)).isEqualTo(FilenameUtils.separatorsToUnix(sourceDir.getAbsolutePath())); assertThat(input.path()).isEqualTo("src/main/java/Foo.java"); assertThat(input.absolutePath()).isEqualTo(PathUtils.canonicalPath(file)); } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/internal/InputFilesTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/internal/InputFilesTest.java index c56dc617721..f0b522be7c5 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/internal/InputFilesTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/internal/InputFilesTest.java @@ -19,6 +19,8 @@ */ package org.sonar.api.scan.filesystem.internal; +import org.sonar.api.scan.filesystem.InputFile; + import com.google.common.base.Charsets; import com.google.common.collect.Lists; import org.junit.Rule; |