aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src/main
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2016-08-29 17:01:13 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2016-08-29 17:02:57 +0200
commit443ad96989ae5f3e5c3388da90a36dcb90d09bf7 (patch)
tree1192a91eeeb4d23f02fe9b82132e7b159594754e /sonar-scanner-engine/src/main
parent0fa7bac665d9c3a29af5db01a445e71d7af23ca5 (diff)
downloadsonarqube-443ad96989ae5f3e5c3388da90a36dcb90d09bf7.tar.gz
sonarqube-443ad96989ae5f3e5c3388da90a36dcb90d09bf7.zip
SONAR-7864 Drop org.sonar.api.scan.filesystem.ModuleFileSystem from API
SONAR-8038 Deprecate ProjectDefinition::getBuildDir
Diffstat (limited to 'sonar-scanner-engine/src/main')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleScanContainer.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/DefaultModuleFileSystem.java132
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/DeprecatedFileFilters.java80
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java33
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ModuleFileSystemInitializer.java14
6 files changed, 25 insertions, 240 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleScanContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleScanContainer.java
index 0a2148c762d..72f95401c53 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleScanContainer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleScanContainer.java
@@ -61,7 +61,6 @@ import org.sonar.scanner.rule.RuleFinderCompatibility;
import org.sonar.scanner.rule.RulesProfileProvider;
import org.sonar.scanner.scan.filesystem.ComponentIndexer;
import org.sonar.scanner.scan.filesystem.DefaultModuleFileSystem;
-import org.sonar.scanner.scan.filesystem.DeprecatedFileFilters;
import org.sonar.scanner.scan.filesystem.ExclusionFilters;
import org.sonar.scanner.scan.filesystem.FileIndexer;
import org.sonar.scanner.scan.filesystem.FileSystemLogger;
@@ -123,7 +122,6 @@ public class ModuleScanContainer extends ComponentContainer {
ModuleInputFileCache.class,
FileExclusions.class,
ExclusionFilters.class,
- DeprecatedFileFilters.class,
InputFileBuilderFactory.class,
FileMetadata.class,
StatusDetectionFactory.class,
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java
index 1f6738d716f..053e735ad01 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java
@@ -70,6 +70,10 @@ public class ProjectReactorBuilder {
private static final String MODULE_KEY_PROPERTY = "sonar.moduleKey";
protected static final String PROPERTY_PROJECT_BASEDIR = "sonar.projectBaseDir";
+ /**
+ * @deprecated since 6.1 notion of buildDir is not well defined
+ */
+ @Deprecated
private static final String PROPERTY_PROJECT_BUILDDIR = "sonar.projectBuildDir";
private static final String PROPERTY_MODULES = "sonar.modules";
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/DefaultModuleFileSystem.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/DefaultModuleFileSystem.java
index cc1fa238669..5b1e1844d0b 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/DefaultModuleFileSystem.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/DefaultModuleFileSystem.java
@@ -20,41 +20,28 @@
package org.sonar.scanner.scan.filesystem;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import java.io.File;
import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
import java.util.List;
-import java.util.Map;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.CoreProperties;
-import org.sonar.api.batch.fs.FilePredicate;
import org.sonar.api.batch.fs.InputFile.Status;
import org.sonar.api.batch.fs.internal.DefaultFileSystem;
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.ModuleFileSystem;
import org.sonar.api.utils.MessageException;
import org.sonar.scanner.analysis.DefaultAnalysisMode;
/**
* @since 3.5
*/
-public class DefaultModuleFileSystem extends DefaultFileSystem implements ModuleFileSystem {
+public class DefaultModuleFileSystem extends DefaultFileSystem {
private String moduleKey;
private FileIndexer indexer;
private Settings settings;
- private File buildDir;
private List<File> sourceDirsOrFiles = Lists.newArrayList();
private List<File> testDirsOrFiles = Lists.newArrayList();
private ComponentIndexer componentIndexer;
@@ -80,7 +67,6 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module
this.settings = settings;
this.indexer = indexer;
setWorkDir(initializer.workingDir());
- this.buildDir = initializer.buildDir();
this.sourceDirsOrFiles = initializer.sources();
this.testDirsOrFiles = initializer.tests();
@@ -98,45 +84,14 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module
return moduleKey;
}
- @Override
- @CheckForNull
- public File buildDir() {
- return buildDir;
- }
-
- @Override
- public List<File> sourceDirs() {
- return keepOnlyDirs(sourceDirsOrFiles);
- }
-
public List<File> sources() {
return sourceDirsOrFiles;
}
- @Override
- public List<File> testDirs() {
- return keepOnlyDirs(testDirsOrFiles);
- }
-
public List<File> tests() {
return testDirsOrFiles;
}
- private static List<File> keepOnlyDirs(List<File> dirsOrFiles) {
- List<File> result = new ArrayList<>();
- for (File f : dirsOrFiles) {
- if (f.isDirectory()) {
- result.add(f);
- }
- }
- return result;
- }
-
- @Override
- public List<File> binaryDirs() {
- return Collections.emptyList();
- }
-
@Override
public Charset encoding() {
final Charset charset;
@@ -154,59 +109,10 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module
return !settings.hasKey(CoreProperties.ENCODING_PROPERTY);
}
- /**
- * Should not be used - only for old plugins
- *
- * @deprecated since 4.0
- */
- @Deprecated
- void addSourceDir(File dir) {
- throw modificationNotPermitted();
- }
-
- /**
- * Should not be used - only for old plugins
- *
- * @deprecated since 4.0
- */
- @Deprecated
- void addTestDir(File dir) {
- throw modificationNotPermitted();
- }
-
private static UnsupportedOperationException modificationNotPermitted() {
return new UnsupportedOperationException("Modifications of the file system are not permitted");
}
- /**
- * @return
- * @deprecated in 4.2. Replaced by {@link #encoding()}
- */
- @Override
- @Deprecated
- public Charset sourceCharset() {
- return encoding();
- }
-
- /**
- * @deprecated in 4.2. Replaced by {@link #workDir()}
- */
- @Deprecated
- @Override
- public File workingDir() {
- return workDir();
- }
-
- @Override
- public List<File> files(FileQuery query) {
- doPreloadFiles();
- Collection<FilePredicate> predicates = Lists.newArrayList();
- for (Map.Entry<String, Collection<String>> entry : query.attributes().entrySet()) {
- predicates.add(fromDeprecatedAttribute(entry.getKey(), entry.getValue()));
- }
- return ImmutableList.copyOf(files(predicates().and(predicates)));
- }
-
@Override
protected void doPreloadFiles() {
if (!initialized) {
@@ -225,42 +131,6 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module
}
}
- private FilePredicate fromDeprecatedAttribute(String key, Collection<String> value) {
- if ("TYPE".equals(key)) {
- return predicates().or(Collections2.transform(value, new Function<String, FilePredicate>() {
- @Override
- public FilePredicate apply(@Nullable String s) {
- return s == null ? predicates().all() : predicates().hasType(org.sonar.api.batch.fs.InputFile.Type.valueOf(s));
- }
- }));
- }
- if ("STATUS".equals(key)) {
- return predicates().or(Collections2.transform(value, new Function<String, FilePredicate>() {
- @Override
- public FilePredicate apply(@Nullable String s) {
- return s == null ? predicates().all() : predicates().hasStatus(org.sonar.api.batch.fs.InputFile.Status.valueOf(s));
- }
- }));
- }
- if ("LANG".equals(key)) {
- return predicates().or(Collections2.transform(value, new Function<String, FilePredicate>() {
- @Override
- public FilePredicate apply(@Nullable String s) {
- return s == null ? predicates().all() : predicates().hasLanguage(s);
- }
- }));
- }
- if ("CMP_KEY".equals(key)) {
- return predicates().or(Collections2.transform(value, new Function<String, FilePredicate>() {
- @Override
- public FilePredicate apply(@Nullable String s) {
- return s == null ? predicates().all() : new AdditionalFilePredicates.KeyPredicate(s);
- }
- }));
- }
- throw new IllegalArgumentException("Unsupported file attribute: " + key);
- }
-
@Override
public boolean equals(Object o) {
if (this == o) {
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/DeprecatedFileFilters.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/DeprecatedFileFilters.java
deleted file mode 100644
index b32ecb5d98a..00000000000
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/DeprecatedFileFilters.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.scanner.scan.filesystem;
-
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.InputFileFilter;
-import org.sonar.api.scan.filesystem.FileSystemFilter;
-import org.sonar.api.scan.filesystem.FileType;
-import org.sonar.api.scan.filesystem.ModuleFileSystem;
-
-public class DeprecatedFileFilters implements InputFileFilter {
- private final FileSystemFilter[] filters;
-
- public DeprecatedFileFilters(FileSystemFilter[] filters) {
- this.filters = filters;
- }
-
- public DeprecatedFileFilters() {
- this(new FileSystemFilter[0]);
- }
-
- @Override
- public boolean accept(InputFile inputFile) {
- if (filters.length > 0) {
- DeprecatedContext context = new DeprecatedContext(inputFile);
- for (FileSystemFilter filter : filters) {
- if (!filter.accept(inputFile.file(), context)) {
- return false;
- }
- }
- }
- return true;
- }
-
- static class DeprecatedContext implements FileSystemFilter.Context {
- private final InputFile inputFile;
-
- DeprecatedContext(InputFile inputFile) {
- this.inputFile = inputFile;
- }
-
- @Override
- public ModuleFileSystem fileSystem() {
- throw new UnsupportedOperationException("Not supported since 4.0");
- }
-
- @Override
- public FileType type() {
- String type = inputFile.type().name();
- return FileType.valueOf(type);
- }
-
- @Override
- public String relativePath() {
- return inputFile.relativePath();
- }
-
- @Override
- public String canonicalPath() {
- return inputFile.absolutePath();
- }
- }
-}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java
index 8b21817ae2d..75c9e927cc0 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java
@@ -20,18 +20,6 @@
package org.sonar.scanner.scan.filesystem;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.sonar.api.batch.ScannerSide;
-import org.sonar.api.batch.bootstrap.ProjectDefinition;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.InputFile.Type;
-import org.sonar.api.batch.fs.InputFileFilter;
-import org.sonar.api.batch.fs.internal.DefaultInputDir;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.scan.filesystem.PathResolver;
-import org.sonar.api.utils.MessageException;
-import org.sonar.scanner.util.ProgressReport;
import java.io.File;
import java.io.IOException;
import java.nio.file.FileSystemLoopException;
@@ -53,6 +41,18 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.sonar.api.batch.ScannerSide;
+import org.sonar.api.batch.bootstrap.ProjectDefinition;
+import org.sonar.api.batch.fs.InputFile;
+import org.sonar.api.batch.fs.InputFile.Type;
+import org.sonar.api.batch.fs.InputFileFilter;
+import org.sonar.api.batch.fs.internal.DefaultInputDir;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
+import org.sonar.api.scan.filesystem.PathResolver;
+import org.sonar.api.utils.MessageException;
+import org.sonar.scanner.util.ProgressReport;
/**
* Index input files into {@link InputPathCache}.
@@ -61,7 +61,7 @@ import java.util.concurrent.TimeUnit;
public class FileIndexer {
private static final Logger LOG = LoggerFactory.getLogger(FileIndexer.class);
- private final List<InputFileFilter> filters;
+ private final InputFileFilter[] filters;
private final boolean isAggregator;
private final ExclusionFilters exclusionFilters;
private final InputFileBuilderFactory inputFileBuilderFactory;
@@ -70,14 +70,17 @@ public class FileIndexer {
private ExecutorService executorService;
private List<Future<Void>> tasks;
- public FileIndexer(List<InputFileFilter> filters, ExclusionFilters exclusionFilters, InputFileBuilderFactory inputFileBuilderFactory,
- ProjectDefinition def) {
+ public FileIndexer(ExclusionFilters exclusionFilters, InputFileBuilderFactory inputFileBuilderFactory, ProjectDefinition def, InputFileFilter[] filters) {
this.filters = filters;
this.exclusionFilters = exclusionFilters;
this.inputFileBuilderFactory = inputFileBuilderFactory;
this.isAggregator = !def.getSubProjects().isEmpty();
}
+ public FileIndexer(ExclusionFilters exclusionFilters, InputFileBuilderFactory inputFileBuilderFactory, ProjectDefinition def) {
+ this(exclusionFilters, inputFileBuilderFactory, def, new InputFileFilter[0]);
+ }
+
void index(DefaultModuleFileSystem fileSystem) {
if (isAggregator) {
// No indexing for an aggregator module
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ModuleFileSystemInitializer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ModuleFileSystemInitializer.java
index c6629174ef3..e0bdd64dc4b 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ModuleFileSystemInitializer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ModuleFileSystemInitializer.java
@@ -20,17 +20,14 @@
package org.sonar.scanner.scan.filesystem;
import com.google.common.collect.Lists;
+import java.io.File;
+import java.util.List;
import org.apache.commons.io.FileUtils;
import org.sonar.api.batch.ScannerSide;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.scan.filesystem.PathResolver;
import org.sonar.api.utils.TempFolder;
-import javax.annotation.CheckForNull;
-
-import java.io.File;
-import java.util.List;
-
/**
* @since 3.5
*/
@@ -39,13 +36,11 @@ public class ModuleFileSystemInitializer {
private File baseDir;
private File workingDir;
- private File buildDir;
private List<File> sourceDirsOrFiles = Lists.newArrayList();
private List<File> testDirsOrFiles = Lists.newArrayList();
public ModuleFileSystemInitializer(ProjectDefinition module, TempFolder tempUtils, PathResolver pathResolver) {
baseDir = module.getBaseDir();
- buildDir = module.getBuildDir();
initWorkingDir(module, tempUtils);
initSources(module, pathResolver);
initTests(module, pathResolver);
@@ -90,11 +85,6 @@ public class ModuleFileSystemInitializer {
return workingDir;
}
- @CheckForNull
- File buildDir() {
- return buildDir;
- }
-
List<File> sources() {
return sourceDirsOrFiles;
}