aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-11-04 21:15:35 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2015-11-05 09:34:47 +0100
commite7885c175b5e078bd93a58650d99a32224b3679b (patch)
treecd238ec9eb4c74bcc915b200815c11fff69f6bf0 /sonar-batch
parente2379a7ffa7e879ededf5f160f55eba26a785a6c (diff)
downloadsonarqube-e7885c175b5e078bd93a58650d99a32224b3679b.tar.gz
sonarqube-e7885c175b5e078bd93a58650d99a32224b3679b.zip
SONAR-6658 Remove ProjectClasspath, ProjectFileSystem, sonar.binaries, sonar.libraries
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java20
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java4
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java74
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapter.java219
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java3
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java70
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapterTest.java72
-rw-r--r--sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-with-explicit-unexisting-binary-dir/module1/src/Fake.java1
-rw-r--r--sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-with-explicit-unexisting-binary-dir/sonar-project.properties9
-rw-r--r--sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-with-explicit-unexisting-lib/module1/src/Fake.java1
-rw-r--r--sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-with-explicit-unexisting-lib/sonar-project.properties9
-rw-r--r--sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-with-unexisting-test-bin-lib-dir/module1/src/Fake.java1
-rw-r--r--sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-with-unexisting-test-bin-lib-dir/sonar-project.properties11
-rw-r--r--sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/shouldFilterFiles/exclude.txt0
-rw-r--r--sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/shouldFilterFiles/include.txt0
15 files changed, 14 insertions, 480 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java
index 92cf55036ed..89d6beb5f48 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java
@@ -60,16 +60,18 @@ public class DefaultIndex extends SonarIndex {
private final BatchComponentCache componentCache;
private final MeasureCache measureCache;
- private DefaultSensorStorage sensorStorage;
+ private final PathResolver pathResolver;
+ private final DefaultProjectTree projectTree;
// caches
+ private DefaultSensorStorage sensorStorage;
private Project currentProject;
private Map<Resource, Bucket> buckets = Maps.newLinkedHashMap();
- private DefaultProjectTree projectTree;
- public DefaultIndex(BatchComponentCache componentCache, DefaultProjectTree projectTree, MeasureCache measureCache) {
+ public DefaultIndex(BatchComponentCache componentCache, DefaultProjectTree projectTree, MeasureCache measureCache, PathResolver pathResolver) {
this.componentCache = componentCache;
this.projectTree = projectTree;
this.measureCache = measureCache;
+ this.pathResolver = pathResolver;
}
public void start() {
@@ -329,14 +331,16 @@ public class DefaultIndex extends SonarIndex {
}
if (relativePathFromSourceDir != null) {
// Resolve using deprecated key
- List<java.io.File> dirs;
+ List<String> dirs;
+ ProjectDefinition projectDef = projectTree.getProjectDefinition(getProject());
if (isTest) {
- dirs = getProject().getFileSystem().getTestDirs();
+ dirs = projectDef.getTestDirs();
} else {
- dirs = getProject().getFileSystem().getSourceDirs();
+ dirs = projectDef.getSourceDirs();
}
- for (java.io.File src : dirs) {
- java.io.File abs = new java.io.File(src, relativePathFromSourceDir);
+ for (String src : dirs) {
+ java.io.File dirOrFile = pathResolver.relativeFile(projectDef.getBaseDir(), src);
+ java.io.File abs = new java.io.File(dirOrFile, relativePathFromSourceDir);
Bucket b = getBucket(isDir ? Directory.fromIOFile(abs, getProject()) : File.fromIOFile(abs, getProject()));
if (b != null) {
return b;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java
index baa19bd268a..eeab1e08c2f 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java
@@ -22,7 +22,6 @@ package org.sonar.batch.scan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.InstantiationStrategy;
-import org.sonar.api.batch.ProjectClasspath;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.fs.internal.FileMetadata;
import org.sonar.api.batch.rule.CheckFactory;
@@ -68,7 +67,6 @@ import org.sonar.batch.scan.filesystem.InputFileBuilderFactory;
import org.sonar.batch.scan.filesystem.LanguageDetectionFactory;
import org.sonar.batch.scan.filesystem.ModuleFileSystemInitializer;
import org.sonar.batch.scan.filesystem.ModuleInputFileCache;
-import org.sonar.batch.scan.filesystem.ProjectFileSystemAdapter;
import org.sonar.batch.scan.filesystem.StatusDetectionFactory;
import org.sonar.batch.scan.report.IssuesReports;
import org.sonar.batch.sensor.DefaultSensorContext;
@@ -131,8 +129,6 @@ public class ModuleScanContainer extends ComponentContainer {
FileSystemLogger.class,
DefaultModuleFileSystem.class,
ModuleFileSystemInitializer.class,
- ProjectFileSystemAdapter.class,
- ProjectClasspath.class,
QProfileVerifier.class,
SensorOptimizer.class,
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java
index 7a2b7dba935..4e24730a816 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java
@@ -23,10 +23,8 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import java.io.File;
-import java.io.FileFilter;
import java.io.IOException;
import java.text.MessageFormat;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
@@ -35,10 +33,6 @@ import java.util.Map;
import java.util.Map.Entry;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
-import org.apache.commons.io.filefilter.AndFileFilter;
-import org.apache.commons.io.filefilter.FileFileFilter;
-import org.apache.commons.io.filefilter.IOFileFilter;
-import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
@@ -85,8 +79,6 @@ public class ProjectReactorBuilder {
*/
private static final String PROPERTY_SOURCES = "sonar.sources";
private static final String PROPERTY_TESTS = "sonar.tests";
- private static final String PROPERTY_BINARIES = "sonar.binaries";
- private static final String PROPERTY_LIBRARIES = "sonar.libraries";
/**
* Array of all mandatory properties required for a project without child.
@@ -336,22 +328,9 @@ public class ProjectReactorBuilder {
if (!props.containsKey(PROPERTY_MODULES)) {
// SONARPLUGINS-2285 Not an aggregator project so we can validate that paths are correct if defined
- // We need to resolve patterns that may have been used in "sonar.libraries"
- for (String pattern : getListFromProperty(props, PROPERTY_LIBRARIES)) {
- File[] files = getLibraries(baseDir, pattern);
- if (files == null || files.length == 0) {
- LOG.error(MessageFormat.format(INVALID_VALUE_OF_X_FOR_Y, PROPERTY_LIBRARIES, projectId));
- throw new IllegalStateException("No files nor directories matching '" + pattern + "' in directory " + baseDir);
- }
- }
-
// Check sonar.tests
String[] testPaths = getListFromProperty(props, PROPERTY_TESTS);
checkExistenceOfPaths(projectId, baseDir, testPaths, PROPERTY_TESTS);
-
- // Check sonar.binaries
- String[] binDirs = getListFromProperty(props, PROPERTY_BINARIES);
- checkExistenceOfDirectories(projectId, baseDir, binDirs, PROPERTY_BINARIES);
}
}
@@ -376,16 +355,6 @@ public class ProjectReactorBuilder {
// We need to check the existence of source directories
String[] sourcePaths = getListFromProperty(properties, PROPERTY_SOURCES);
checkExistenceOfPaths(project.getKey(), project.getBaseDir(), sourcePaths, PROPERTY_SOURCES);
-
- // And we need to resolve patterns that may have been used in "sonar.libraries"
- List<String> libPaths = Lists.newArrayList();
- for (String pattern : getListFromProperty(properties, PROPERTY_LIBRARIES)) {
- for (File file : getLibraries(project.getBaseDir(), pattern)) {
- libPaths.add(file.getAbsolutePath());
- }
- }
- properties.remove(PROPERTY_LIBRARIES);
- properties.put(PROPERTY_LIBRARIES, StringUtils.join(libPaths, ","));
}
@VisibleForTesting
@@ -406,8 +375,6 @@ public class ProjectReactorBuilder {
// "aggregator" project must not have the following properties:
properties.remove(PROPERTY_SOURCES);
properties.remove(PROPERTY_TESTS);
- properties.remove(PROPERTY_BINARIES);
- properties.remove(PROPERTY_LIBRARIES);
}
@VisibleForTesting
@@ -422,19 +389,6 @@ public class ProjectReactorBuilder {
}
@VisibleForTesting
- protected static void checkExistenceOfDirectories(String moduleRef, File baseDir, String[] dirPaths, String propName) {
- for (String path : dirPaths) {
- File sourceFolder = resolvePath(baseDir, path);
- if (!sourceFolder.isDirectory()) {
- LOG.error(MessageFormat.format(INVALID_VALUE_OF_X_FOR_Y, propName, moduleRef));
- throw new IllegalStateException("The folder '" + path + "' does not exist for '" + moduleRef +
- "' (base directory = " + baseDir.getAbsolutePath() + ")");
- }
- }
-
- }
-
- @VisibleForTesting
protected static void checkExistenceOfPaths(String moduleRef, File baseDir, String[] paths, String propName) {
for (String path : paths) {
File sourceFolder = resolvePath(baseDir, path);
@@ -447,34 +401,6 @@ public class ProjectReactorBuilder {
}
- /**
- * Returns files matching specified pattern.
- */
- @VisibleForTesting
- protected static File[] getLibraries(File baseDir, String pattern) {
- final int i = Math.max(pattern.lastIndexOf('/'), pattern.lastIndexOf('\\'));
- final String dirPath;
- final String filePattern;
- if (i == -1) {
- dirPath = ".";
- filePattern = pattern;
- } else {
- dirPath = pattern.substring(0, i);
- filePattern = pattern.substring(i + 1);
- }
- List<IOFileFilter> filters = new ArrayList<>();
- if (pattern.indexOf('*') >= 0) {
- filters.add(FileFileFilter.FILE);
- }
- filters.add(new WildcardFileFilter(filePattern));
- File dir = resolvePath(baseDir, dirPath);
- File[] files = dir.listFiles((FileFilter) new AndFileFilter(filters));
- if (files == null) {
- files = new File[0];
- }
- return files;
- }
-
protected static File resolvePath(File baseDir, String path) {
File file = new File(path);
if (!file.isAbsolute()) {
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
deleted file mode 100644
index 20390af7c84..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapter.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 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 com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.util.Arrays;
-import java.util.List;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.CharEncoding;
-import org.sonar.api.batch.fs.FilePredicate;
-import org.sonar.api.resources.InputFile;
-import org.sonar.api.resources.Java;
-import org.sonar.api.resources.Language;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.ProjectFileSystem;
-import org.sonar.api.resources.Resource;
-import org.sonar.api.scan.filesystem.PathResolver;
-import org.sonar.api.utils.SonarException;
-
-/**
- * Adapter for keeping the backward-compatibility of the deprecated component {@link org.sonar.api.resources.ProjectFileSystem}
- *
- * @since 3.5
- */
-public class ProjectFileSystemAdapter implements ProjectFileSystem {
-
- private final DefaultModuleFileSystem target;
- private final PathResolver pathResolver = new PathResolver();
-
- public ProjectFileSystemAdapter(DefaultModuleFileSystem target, Project project) {
- this.target = target;
-
- // previously MavenProjectBuilder was responsible for creation of ProjectFileSystem
- project.setFileSystem(this);
- }
-
- public void start() {
- // used to avoid NPE in Project#getFileSystem()
- }
-
- @Override
- public Charset getSourceCharset() {
- return target.sourceCharset();
- }
-
- @Override
- public File getBasedir() {
- return target.baseDir();
- }
-
- @Override
- public File getBuildDir() {
- File dir = target.buildDir();
- if (dir == null) {
- // emulate build dir to keep backward-compatibility
- dir = new File(getSonarWorkingDirectory(), "build");
- }
- return dir;
- }
-
- @Override
- public File getBuildOutputDir() {
- File dir = Iterables.getFirst(target.binaryDirs(), null);
- if (dir == null) {
- // emulate binary dir
- dir = new File(getBuildDir(), "classes");
- }
-
- return dir;
- }
-
- @Override
- public List<File> getSourceDirs() {
- return target.sourceDirs();
- }
-
- @Override
- public ProjectFileSystem addSourceDir(File dir) {
- target.addSourceDir(dir);
- return this;
- }
-
- @Override
- public List<File> getTestDirs() {
- return target.testDirs();
- }
-
- @Override
- public ProjectFileSystem addTestDir(File dir) {
- target.addTestDir(dir);
- return this;
- }
-
- @Override
- public File getReportOutputDir() {
- // emulate Maven report output dir
- return new File(getBuildDir(), "site");
- }
-
- @Override
- public File getSonarWorkingDirectory() {
- return target.workDir();
- }
-
- @Override
- public File resolvePath(String path) {
- File file = new File(path);
- if (!file.isAbsolute()) {
- try {
- file = new File(getBasedir(), path).getCanonicalFile();
- } catch (IOException e) {
- throw new SonarException("Unable to resolve path '" + path + "'", e);
- }
- }
- return file;
- }
-
- @Override
- public List<File> getSourceFiles(Language... langs) {
- return Lists.newArrayList(target.files(target.predicates().and(
- target.predicates().hasType(org.sonar.api.batch.fs.InputFile.Type.MAIN),
- newHasLanguagesPredicate(langs))));
- }
-
- @Override
- public List<File> getJavaSourceFiles() {
- return getSourceFiles(Java.INSTANCE);
- }
-
- @Override
- public boolean hasJavaSourceFiles() {
- return !getJavaSourceFiles().isEmpty();
- }
-
- @Override
- public List<File> getTestFiles(Language... langs) {
- return Lists.newArrayList(target.files(target.predicates().and(
- target.predicates().hasType(org.sonar.api.batch.fs.InputFile.Type.TEST),
- newHasLanguagesPredicate(langs))));
- }
-
- @Override
- public boolean hasTestFiles(Language lang) {
- return target.hasFiles(target.predicates().and(
- target.predicates().hasType(org.sonar.api.batch.fs.InputFile.Type.TEST),
- target.predicates().hasLanguage(lang.getKey())));
- }
-
- @Override
- public File writeToWorkingDirectory(String content, String fileName) throws IOException {
- File file = new File(target.workDir(), fileName);
- FileUtils.writeStringToFile(file, content, CharEncoding.UTF_8);
- return file;
- }
-
- @Override
- public File getFileFromBuildDirectory(String filename) {
- File file = new File(getBuildDir(), filename);
- return file.exists() ? file : null;
- }
-
- @Override
- public Resource toResource(File file) {
- if (file == null || !file.exists()) {
- return null;
- }
- String relativePath = pathResolver.relativePath(getBasedir(), file);
- if (relativePath == null) {
- return null;
- }
- return file.isFile() ? org.sonar.api.resources.File.create(relativePath) : org.sonar.api.resources.Directory.create(relativePath);
- }
-
- @Override
- public List<InputFile> mainFiles(String... langs) {
- return Lists.newArrayList((Iterable) target.inputFiles(target.predicates().and(
- target.predicates().hasType(org.sonar.api.batch.fs.InputFile.Type.MAIN),
- target.predicates().hasLanguages(Arrays.asList(langs))
- )));
-
- }
-
- @Override
- public List<InputFile> testFiles(String... langs) {
- return Lists.newArrayList((Iterable) target.inputFiles(target.predicates().and(
- target.predicates().hasType(org.sonar.api.batch.fs.InputFile.Type.TEST),
- target.predicates().hasLanguages(Arrays.asList(langs))
- )));
- }
-
- private FilePredicate newHasLanguagesPredicate(Language... languages) {
- List<FilePredicate> list = Lists.newArrayList();
- for (Language language : languages) {
- list.add(target.predicates().hasLanguage(language.getKey()));
- }
- return target.predicates().or(list);
- }
-}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java
index c18ce10a540..eccd889ff7e 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java
@@ -35,6 +35,7 @@ import org.sonar.api.resources.Project;
import org.sonar.api.resources.Resource;
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.RuleFinder;
+import org.sonar.api.scan.filesystem.PathResolver;
import org.sonar.batch.DefaultProjectTree;
import org.sonar.batch.scan.measure.MeasureCache;
import org.sonar.batch.sensor.DefaultSensorStorage;
@@ -64,7 +65,7 @@ public class DefaultIndexTest {
DefaultProjectTree projectTree = mock(DefaultProjectTree.class);
BatchComponentCache resourceCache = new BatchComponentCache();
- index = new DefaultIndex(resourceCache, projectTree, mock(MeasureCache.class));
+ index = new DefaultIndex(resourceCache, projectTree, mock(MeasureCache.class), new PathResolver());
baseDir = temp.newFolder();
project = new Project("project");
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java
index d199bce50c9..0aea951a706 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java
@@ -68,8 +68,6 @@ public class ProjectReactorBuilderTest {
assertThat(projectDefinition.getVersion()).isEqualTo("1.0-SNAPSHOT");
assertThat(projectDefinition.getDescription()).isEqualTo("Description of Foo Project");
assertThat(projectDefinition.getSourceDirs()).contains("sources");
- assertThat(projectDefinition.getLibraries()).contains(TestUtils.getResource(this.getClass(), "simple-project/libs/lib2.txt").getAbsolutePath(),
- TestUtils.getResource(this.getClass(), "simple-project/libs/lib2.txt").getAbsolutePath());
}
@Test
@@ -130,7 +128,6 @@ public class ProjectReactorBuilderTest {
// root project must not contain some properties - even if they are defined in the root properties file
assertThat(rootProject.getSourceDirs().contains("sources")).isFalse();
assertThat(rootProject.getTestDirs().contains("tests")).isFalse();
- assertThat(rootProject.getBinaries().contains("target/classes")).isFalse();
// and module properties must have been cleaned
assertThat(rootProject.properties().get("module1.sonar.projectKey")).isNull();
assertThat(rootProject.properties().get("module2.sonar.projectKey")).isNull();
@@ -261,11 +258,6 @@ public class ProjectReactorBuilderTest {
}
@Test
- public void shouldNotFailIfUnexistingTestBinLibFolderInheritedInMultimodule() {
- loadProjectDefinition("multi-module-with-unexisting-test-bin-lib-dir");
- }
-
- @Test
public void shouldFailIfExplicitUnexistingTestFolder() {
thrown.expect(IllegalStateException.class);
thrown.expectMessage("The folder 'tests' does not exist for 'com.foo.project' (base directory = "
@@ -275,33 +267,6 @@ public class ProjectReactorBuilderTest {
}
@Test
- public void shouldFailIfExplicitUnexistingBinaryFolder() {
- thrown.expect(IllegalStateException.class);
- thrown.expectMessage("The folder 'bin' does not exist for 'com.foo.project' (base directory = "
- + TestUtils.getResource(this.getClass(), "simple-project-with-unexisting-binary").getAbsolutePath());
-
- loadProjectDefinition("simple-project-with-unexisting-binary");
- }
-
- @Test
- public void shouldFailIfExplicitUnmatchingLibFolder() {
- thrown.expect(IllegalStateException.class);
- thrown.expectMessage("No files nor directories matching 'libs/*.txt' in directory "
- + TestUtils.getResource(this.getClass(), "simple-project-with-unexisting-lib").getAbsolutePath());
-
- loadProjectDefinition("simple-project-with-unexisting-lib");
- }
-
- @Test
- public void shouldGetLibDirectory() {
- ProjectDefinition def = loadProjectDefinition("simple-project-with-lib-dir");
- assertThat(def.getLibraries()).hasSize(1);
- File libDir = new File(def.getLibraries().get(0));
- assertThat(libDir).isDirectory().exists();
- assertThat(libDir.getName()).isEqualTo("lib");
- }
-
- @Test
public void shouldFailIfExplicitUnexistingTestFolderOnModule() {
thrown.expect(IllegalStateException.class);
thrown.expectMessage("The folder 'tests' does not exist for 'module1' (base directory = "
@@ -311,24 +276,6 @@ public class ProjectReactorBuilderTest {
}
@Test
- public void shouldFailIfExplicitUnexistingBinaryFolderOnModule() {
- thrown.expect(IllegalStateException.class);
- thrown.expectMessage("The folder 'bin' does not exist for 'module1' (base directory = "
- + TestUtils.getResource(this.getClass(), "multi-module-with-explicit-unexisting-binary-dir").getAbsolutePath() + File.separator + "module1)");
-
- loadProjectDefinition("multi-module-with-explicit-unexisting-binary-dir");
- }
-
- @Test
- public void shouldFailIfExplicitUnmatchingLibFolderOnModule() {
- thrown.expect(IllegalStateException.class);
- thrown.expectMessage("No files nor directories matching 'lib/*.jar' in directory "
- + TestUtils.getResource(this.getClass(), "multi-module-with-explicit-unexisting-lib").getAbsolutePath() + File.separator + "module1");
-
- loadProjectDefinition("multi-module-with-explicit-unexisting-lib");
- }
-
- @Test
public void multiModuleProperties() {
ProjectDefinition projectDefinition = loadProjectDefinition("big-multi-module-definitions-all-in-root");
@@ -416,22 +363,6 @@ public class ProjectReactorBuilderTest {
}
@Test
- public void shouldFilterFiles() {
- File baseDir = TestUtils.getResource(this.getClass(), "shouldFilterFiles");
- assertThat(ProjectReactorBuilder.getLibraries(baseDir, "in*.txt")).hasSize(1);
- assertThat(ProjectReactorBuilder.getLibraries(baseDir, "*.txt")).hasSize(2);
- assertThat(ProjectReactorBuilder.getLibraries(baseDir.getParentFile(), "shouldFilterFiles/in*.txt")).hasSize(1);
- assertThat(ProjectReactorBuilder.getLibraries(baseDir.getParentFile(), "shouldFilterFiles/*.txt")).hasSize(2);
- }
-
- @Test
- public void shouldWorkWithAbsolutePath() {
- File baseDir = new File("not-exists");
- String absolutePattern = TestUtils.getResource(this.getClass(), "shouldFilterFiles").getAbsolutePath() + "/in*.txt";
- assertThat(ProjectReactorBuilder.getLibraries(baseDir.getParentFile(), absolutePattern)).hasSize(1);
- }
-
- @Test
public void shouldGetRelativeFile() {
assertThat(ProjectReactorBuilder.resolvePath(TestUtils.getResource(this.getClass(), "/"), "shouldGetFile/foo.properties"))
.isEqualTo(TestUtils.getResource(this.getClass(), "shouldGetFile/foo.properties"));
@@ -639,7 +570,6 @@ public class ProjectReactorBuilderTest {
// root project must not contain some properties - even if they are defined in the root properties file
assertThat(rootProject.getSourceDirs().contains("sources")).isFalse();
assertThat(rootProject.getTestDirs().contains("tests")).isFalse();
- assertThat(rootProject.getBinaries().contains("target/classes")).isFalse();
// and module properties must have been cleaned
assertThat(rootProject.properties().get("module1.sonar.projectKey")).isNull();
assertThat(rootProject.properties().get("module2.sonar.projectKey")).isNull();
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapterTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapterTest.java
deleted file mode 100644
index c75ad09cc0b..00000000000
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapterTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 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.mockito.Mockito;
-import org.sonar.api.resources.Project;
-
-import java.io.File;
-import java.io.IOException;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class ProjectFileSystemAdapterTest {
-
- @Rule
- public TemporaryFolder temp = new TemporaryFolder();
-
- @Test
- public void should_wrap_module_file_system() {
- DefaultModuleFileSystem target = mock(DefaultModuleFileSystem.class, Mockito.RETURNS_SMART_NULLS);
- ProjectFileSystemAdapter adapter = new ProjectFileSystemAdapter(target, new Project("my-project"));
-
- assertThat(adapter.getBasedir()).isNotNull();
- verify(target).baseDir();
-
- assertThat(adapter.getSourceDirs()).isNotNull();
- verify(target).sourceDirs();
-
- assertThat(adapter.getTestDirs()).isNotNull();
- verify(target).testDirs();
-
- assertThat(adapter.getSourceCharset()).isNotNull();
- verify(target).sourceCharset();
-
- assertThat(adapter.getBuildDir()).isNotNull();
- verify(target).buildDir();
- }
-
- @Test
- public void should_create_default_build_dir() throws IOException {
- File workingDir = temp.newFile("work");
- DefaultModuleFileSystem target = mock(DefaultModuleFileSystem.class);
- when(target.workDir()).thenReturn(workingDir);
- ProjectFileSystemAdapter adapter = new ProjectFileSystemAdapter(target, new Project("my-project"));
-
- File buildDir = adapter.getBuildDir();
- assertThat(buildDir.getParentFile().getCanonicalPath()).isEqualTo(workingDir.getCanonicalPath());
- }
-}
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-with-explicit-unexisting-binary-dir/module1/src/Fake.java b/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-with-explicit-unexisting-binary-dir/module1/src/Fake.java
deleted file mode 100644
index 8b137891791..00000000000
--- a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-with-explicit-unexisting-binary-dir/module1/src/Fake.java
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-with-explicit-unexisting-binary-dir/sonar-project.properties b/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-with-explicit-unexisting-binary-dir/sonar-project.properties
deleted file mode 100644
index 8007363a9c4..00000000000
--- a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-with-explicit-unexisting-binary-dir/sonar-project.properties
+++ /dev/null
@@ -1,9 +0,0 @@
-sonar.projectKey=com.foo.project
-sonar.projectName=Foo Project
-sonar.projectVersion=1.0-SNAPSHOT
-sonar.projectDescription=Description of Foo Project
-
-sonar.sources=src
-
-sonar.modules=module1
-module1.sonar.binaries=bin
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-with-explicit-unexisting-lib/module1/src/Fake.java b/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-with-explicit-unexisting-lib/module1/src/Fake.java
deleted file mode 100644
index 8b137891791..00000000000
--- a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-with-explicit-unexisting-lib/module1/src/Fake.java
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-with-explicit-unexisting-lib/sonar-project.properties b/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-with-explicit-unexisting-lib/sonar-project.properties
deleted file mode 100644
index d97a18bb16d..00000000000
--- a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-with-explicit-unexisting-lib/sonar-project.properties
+++ /dev/null
@@ -1,9 +0,0 @@
-sonar.projectKey=com.foo.project
-sonar.projectName=Foo Project
-sonar.projectVersion=1.0-SNAPSHOT
-sonar.projectDescription=Description of Foo Project
-
-sonar.sources=src
-
-sonar.modules=module1
-module1.sonar.libraries=lib/*.jar
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-with-unexisting-test-bin-lib-dir/module1/src/Fake.java b/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-with-unexisting-test-bin-lib-dir/module1/src/Fake.java
deleted file mode 100644
index 8b137891791..00000000000
--- a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-with-unexisting-test-bin-lib-dir/module1/src/Fake.java
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-with-unexisting-test-bin-lib-dir/sonar-project.properties b/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-with-unexisting-test-bin-lib-dir/sonar-project.properties
deleted file mode 100644
index 59b68b39663..00000000000
--- a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-with-unexisting-test-bin-lib-dir/sonar-project.properties
+++ /dev/null
@@ -1,11 +0,0 @@
-sonar.projectKey=com.foo.project
-sonar.projectName=Foo Project
-sonar.projectVersion=1.0-SNAPSHOT
-sonar.projectDescription=Description of Foo Project
-
-sonar.sources=src
-sonar.tests=tests
-sonar.binaries=bin
-sonar.libraries=lib/*.jar
-
-sonar.modules=module1
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/shouldFilterFiles/exclude.txt b/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/shouldFilterFiles/exclude.txt
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/shouldFilterFiles/exclude.txt
+++ /dev/null
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/shouldFilterFiles/include.txt b/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/shouldFilterFiles/include.txt
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/shouldFilterFiles/include.txt
+++ /dev/null