aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2015-08-21 17:26:04 +0200
committerDuarte Meneses <duarte.meneses@sonarsource.com>2015-08-24 09:54:39 +0200
commit1dd1cd5c6517ffe91ae9b0b003d65c126d54b4b4 (patch)
treec6dee9cbf1f0599c5e7c19747dc7d762b5859c14 /sonar-batch
parenta805e4796f8826acc73f2078e7374f1956402dfd (diff)
downloadsonarqube-1dd1cd5c6517ffe91ae9b0b003d65c126d54b4b4.tar.gz
sonarqube-1dd1cd5c6517ffe91ae9b0b003d65c126d54b4b4.zip
SONAR-6658 Drop validation on sonar.libraries and sonar.binaries
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java27
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java14
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializer.java17
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/DeprecatedProjectReactorBuilderTest.java54
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java83
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystemTest.java7
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializerTest.java7
-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/simple-project-with-lib-dir/lib/Fake.class3
-rw-r--r--sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/simple-project-with-lib-dir/sonar-project.properties7
-rw-r--r--sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/simple-project-with-lib-dir/sources/Fake.java3
-rw-r--r--sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/simple-project-with-unexisting-binary/sonar-project.properties7
-rw-r--r--sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/simple-project-with-unexisting-binary/sources/Fake.java1
-rw-r--r--sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/simple-project-with-unexisting-lib/sonar-project.properties7
-rw-r--r--sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/simple-project-with-unexisting-lib/sources/Fake.java1
19 files changed, 54 insertions, 206 deletions
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 1363134d449..beeec9e389f 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;
@@ -134,7 +133,6 @@ public class ModuleScanContainer extends ComponentContainer {
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 670bf714eef..ad67711a857 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
@@ -81,8 +81,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.
@@ -344,22 +342,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);
}
}
@@ -384,16 +369,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
@@ -414,8 +389,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
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 24e26f5eb94..cb67cf534eb 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
@@ -19,19 +19,26 @@
*/
package org.sonar.batch.scan.filesystem;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
+
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.LinkedList;
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;
@@ -46,6 +53,7 @@ import org.sonar.api.utils.MessageException;
* @since 3.5
*/
public class DefaultModuleFileSystem extends DefaultFileSystem implements ModuleFileSystem {
+ private static final Logger LOG = Loggers.get(DefaultModuleFileSystem.class);
private final String moduleKey;
private final FileIndexer indexer;
@@ -54,7 +62,6 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module
private File buildDir;
private List<File> sourceDirsOrFiles = Lists.newArrayList();
private List<File> testDirsOrFiles = Lists.newArrayList();
- private List<File> binaryDirs = Lists.newArrayList();
private ComponentIndexer componentIndexer;
private boolean initialized;
@@ -69,7 +76,6 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module
this.buildDir = initializer.buildDir();
this.sourceDirsOrFiles = initializer.sources();
this.testDirsOrFiles = initializer.tests();
- this.binaryDirs = initializer.binaryDirs();
}
@VisibleForTesting
@@ -84,7 +90,6 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module
this.buildDir = initializer.buildDir();
this.sourceDirsOrFiles = initializer.sources();
this.testDirsOrFiles = initializer.tests();
- this.binaryDirs = initializer.binaryDirs();
}
public boolean isInitialized() {
@@ -131,7 +136,8 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module
@Override
public List<File> binaryDirs() {
- return binaryDirs;
+ LOG.warn("ModuleFileSystem#binaryDirs() is deprecated and will always return an empty list");
+ return new LinkedList<>();
}
@Override
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializer.java
index fd2e8a9226a..aa8e20813e1 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializer.java
@@ -42,13 +42,11 @@ public class ModuleFileSystemInitializer {
private File buildDir;
private List<File> sourceDirsOrFiles = Lists.newArrayList();
private List<File> testDirsOrFiles = Lists.newArrayList();
- private List<File> binaryDirs = Lists.newArrayList();
public ModuleFileSystemInitializer(ProjectDefinition module, TempFolder tempUtils, PathResolver pathResolver) {
baseDir = module.getBaseDir();
buildDir = module.getBuildDir();
initWorkingDir(module, tempUtils);
- initBinaryDirs(module, pathResolver);
initSources(module, pathResolver);
initTests(module, pathResolver);
}
@@ -84,13 +82,6 @@ public class ModuleFileSystemInitializer {
}
}
- private void initBinaryDirs(ProjectDefinition module, PathResolver pathResolver) {
- for (String path : module.getBinaries()) {
- File dir = pathResolver.relativeFile(module.getBaseDir(), path);
- binaryDirs.add(dir);
- }
- }
-
File baseDir() {
return baseDir;
}
@@ -111,12 +102,4 @@ public class ModuleFileSystemInitializer {
List<File> tests() {
return testDirsOrFiles;
}
-
- /**
- * @deprecated since 4.5.1 use SonarQube Java specific API
- */
- @Deprecated
- List<File> binaryDirs() {
- return binaryDirs;
- }
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/DeprecatedProjectReactorBuilderTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/DeprecatedProjectReactorBuilderTest.java
index 0aaf6e2dfd2..f42cdc208d5 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/DeprecatedProjectReactorBuilderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/DeprecatedProjectReactorBuilderTest.java
@@ -52,12 +52,11 @@ public class DeprecatedProjectReactorBuilderTest {
assertThat(rootProject.getVersion()).isEqualTo("1.0-SNAPSHOT");
assertThat(rootProject.getDescription()).isEqualTo("Description of Foo Project");
// 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();
+ assertThat(rootProject.sources().contains("sources")).isFalse();
+ assertThat(rootProject.tests().contains("tests")).isFalse();
// and module properties must have been cleaned
- assertThat(rootProject.getProperties().getProperty("module1.sonar.projectKey")).isNull();
- assertThat(rootProject.getProperties().getProperty("module2.sonar.projectKey")).isNull();
+ assertThat(rootProject.properties().get("module1.sonar.projectKey")).isNull();
+ assertThat(rootProject.properties().get("module2.sonar.projectKey")).isNull();
// CHECK MODULES
List<ProjectDefinition> modules = rootProject.getSubProjects();
@@ -71,12 +70,11 @@ public class DeprecatedProjectReactorBuilderTest {
assertThat(module1.getVersion()).isEqualTo("1.0-SNAPSHOT");
// Description should not be inherited from parent if not set
assertThat(module1.getDescription()).isEqualTo("Description of Module 1");
- assertThat(module1.getSourceDirs()).contains("sources");
- assertThat(module1.getTestDirs()).contains("tests");
- assertThat(module1.getBinaries()).contains("target/classes");
+ assertThat(module1.sources()).contains("sources");
+ assertThat(module1.tests()).contains("tests");
// and module properties must have been cleaned
- assertThat(module1.getProperties().getProperty("module1.sonar.projectKey")).isNull();
- assertThat(module1.getProperties().getProperty("module2.sonar.projectKey")).isNull();
+ assertThat(module1.properties().get("module1.sonar.projectKey")).isNull();
+ assertThat(module1.properties().get("module2.sonar.projectKey")).isNull();
// Module 2
ProjectDefinition module2 = modules.get(1);
@@ -85,12 +83,11 @@ public class DeprecatedProjectReactorBuilderTest {
assertThat(module2.getName()).isEqualTo("Foo Module 2");
assertThat(module2.getVersion()).isEqualTo("1.0-SNAPSHOT");
assertThat(module2.getDescription()).isEqualTo("Description of Module 2");
- assertThat(module2.getSourceDirs()).contains("src");
- assertThat(module2.getTestDirs()).contains("tests");
- assertThat(module2.getBinaries()).contains("target/classes");
+ assertThat(module2.sources()).contains("src");
+ assertThat(module2.tests()).contains("tests");
// and module properties must have been cleaned
- assertThat(module2.getProperties().getProperty("module1.sonar.projectKey")).isNull();
- assertThat(module2.getProperties().getProperty("module2.sonar.projectKey")).isNull();
+ assertThat(module2.properties().get("module1.sonar.projectKey")).isNull();
+ assertThat(module2.properties().get("module2.sonar.projectKey")).isNull();
}
@Test
@@ -103,12 +100,11 @@ public class DeprecatedProjectReactorBuilderTest {
assertThat(rootProject.getVersion()).isEqualTo("1.0-SNAPSHOT");
assertThat(rootProject.getDescription()).isEqualTo("Description of Foo Project");
// 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();
+ assertThat(rootProject.sources().contains("sources")).isFalse();
+ assertThat(rootProject.tests().contains("tests")).isFalse();
// and module properties must have been cleaned
- assertThat(rootProject.getProperties().getProperty("module1.sonar.projectKey")).isNull();
- assertThat(rootProject.getProperties().getProperty("module2.sonar.projectKey")).isNull();
+ assertThat(rootProject.properties().get("module1.sonar.projectKey")).isNull();
+ assertThat(rootProject.properties().get("module2.sonar.projectKey")).isNull();
// CHECK MODULES
List<ProjectDefinition> modules = rootProject.getSubProjects();
@@ -122,12 +118,11 @@ public class DeprecatedProjectReactorBuilderTest {
assertThat(module1.getVersion()).isEqualTo("1.0-SNAPSHOT");
// Description should not be inherited from parent if not set
assertThat(module1.getDescription()).isNull();
- assertThat(module1.getSourceDirs()).contains("sources");
- assertThat(module1.getTestDirs()).contains("tests");
- assertThat(module1.getBinaries()).contains("target/classes");
+ assertThat(module1.sources()).contains("sources");
+ assertThat(module1.tests()).contains("tests");
// and module properties must have been cleaned
- assertThat(module1.getProperties().getProperty("module1.sonar.projectKey")).isNull();
- assertThat(module1.getProperties().getProperty("module2.sonar.projectKey")).isNull();
+ assertThat(module1.properties().get("module1.sonar.projectKey")).isNull();
+ assertThat(module1.properties().get("module2.sonar.projectKey")).isNull();
// Module 2
ProjectDefinition module2 = modules.get(1);
@@ -136,12 +131,11 @@ public class DeprecatedProjectReactorBuilderTest {
assertThat(module2.getName()).isEqualTo("Foo Module 2");
assertThat(module2.getVersion()).isEqualTo("1.0-SNAPSHOT");
assertThat(module2.getDescription()).isEqualTo("Description of Module 2");
- assertThat(module2.getSourceDirs()).contains("src");
- assertThat(module2.getTestDirs()).contains("tests");
- assertThat(module2.getBinaries()).contains("target/classes");
+ assertThat(module2.sources()).contains("src");
+ assertThat(module2.tests()).contains("tests");
// and module properties must have been cleaned
- assertThat(module2.getProperties().getProperty("module1.sonar.projectKey")).isNull();
- assertThat(module2.getProperties().getProperty("module2.sonar.projectKey")).isNull();
+ assertThat(module2.properties().get("module1.sonar.projectKey")).isNull();
+ assertThat(module2.properties().get("module2.sonar.projectKey")).isNull();
}
@Test
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 b4bdeb07877..8db640586d8 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
@@ -52,9 +52,7 @@ public class ProjectReactorBuilderTest {
assertThat(projectDefinition.getName()).isEqualTo("Foo Project");
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());
+ assertThat(projectDefinition.sources()).contains("sources");
}
@Test
@@ -96,9 +94,8 @@ public class ProjectReactorBuilderTest {
assertThat(rootProject.getVersion()).isEqualTo("1.0-SNAPSHOT");
assertThat(rootProject.getDescription()).isEqualTo("Description of Foo Project");
// 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();
+ assertThat(rootProject.sources().contains("sources")).isFalse();
+ assertThat(rootProject.tests().contains("tests")).isFalse();
// and module properties must have been cleaned
assertThat(rootProject.getProperties().getProperty("module1.sonar.projectKey")).isNull();
assertThat(rootProject.getProperties().getProperty("module2.sonar.projectKey")).isNull();
@@ -120,9 +117,8 @@ public class ProjectReactorBuilderTest {
assertThat(module1.getVersion()).isEqualTo("1.0-SNAPSHOT");
// Description should not be inherited from parent if not set
assertThat(module1.getDescription()).isNull();
- assertThat(module1.getSourceDirs()).contains("sources");
- assertThat(module1.getTestDirs()).contains("tests");
- assertThat(module1.getBinaries()).contains("target/classes");
+ assertThat(module1.sources()).contains("sources");
+ assertThat(module1.tests()).contains("tests");
// and module properties must have been cleaned
assertThat(module1.getProperties().getProperty("module1.sonar.projectKey")).isNull();
assertThat(module1.getProperties().getProperty("module2.sonar.projectKey")).isNull();
@@ -139,9 +135,8 @@ public class ProjectReactorBuilderTest {
assertThat(module2.getName()).isEqualTo("Foo Module 2");
assertThat(module2.getVersion()).isEqualTo("1.0-SNAPSHOT");
assertThat(module2.getDescription()).isEqualTo("Description of Module 2");
- assertThat(module2.getSourceDirs()).contains("src");
- assertThat(module2.getTestDirs()).contains("tests");
- assertThat(module2.getBinaries()).contains("target/classes");
+ assertThat(module2.sources()).contains("src");
+ assertThat(module2.tests()).contains("tests");
// and module properties must have been cleaned
assertThat(module2.getProperties().getProperty("module1.sonar.projectKey")).isNull();
assertThat(module2.getProperties().getProperty("module2.sonar.projectKey")).isNull();
@@ -188,7 +183,7 @@ public class ProjectReactorBuilderTest {
// Module 1
ProjectDefinition module1 = modules.get(0);
assertThat(module1.getBaseDir().getCanonicalFile()).isEqualTo(TestUtils.getResource(this.getClass(), "multi-language-definitions-all-in-root"));
- assertThat(module1.getSourceDirs()).contains("src/main/java");
+ assertThat(module1.sources()).contains("src/main/java");
// and module properties must have been cleaned
assertThat(module1.getWorkDir().getCanonicalFile())
.isEqualTo(new File(TestUtils.getResource(this.getClass(), "multi-language-definitions-all-in-root"), ".sonar/example_java-module"));
@@ -196,7 +191,7 @@ public class ProjectReactorBuilderTest {
// Module 2
ProjectDefinition module2 = modules.get(1);
assertThat(module2.getBaseDir().getCanonicalFile()).isEqualTo(TestUtils.getResource(this.getClass(), "multi-language-definitions-all-in-root"));
- assertThat(module2.getSourceDirs()).contains("src/main/groovy");
+ assertThat(module2.sources()).contains("src/main/groovy");
// and module properties must have been cleaned
assertThat(module2.getWorkDir().getCanonicalFile())
.isEqualTo(new File(TestUtils.getResource(this.getClass(), "multi-language-definitions-all-in-root"), ".sonar/example_groovy-module"));
@@ -243,33 +238,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 = "
@@ -279,24 +247,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");
@@ -583,9 +533,8 @@ public class ProjectReactorBuilderTest {
assertThat(rootProject.getVersion()).isEqualTo("1.0-SNAPSHOT");
assertThat(rootProject.getDescription()).isEqualTo("Description of Foo Project");
// 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();
+ assertThat(rootProject.sources().contains("sources")).isFalse();
+ assertThat(rootProject.tests().contains("tests")).isFalse();
// and module properties must have been cleaned
assertThat(rootProject.getProperties().getProperty("module1.sonar.projectKey")).isNull();
assertThat(rootProject.getProperties().getProperty("module2.sonar.projectKey")).isNull();
@@ -607,9 +556,8 @@ public class ProjectReactorBuilderTest {
assertThat(module1.getVersion()).isEqualTo("1.0-SNAPSHOT");
// Description should not be inherited from parent if not set
assertThat(module1.getDescription()).isNull();
- assertThat(module1.getSourceDirs()).contains("sources");
- assertThat(module1.getTestDirs()).contains("tests");
- assertThat(module1.getBinaries()).contains("target/classes");
+ assertThat(module1.sources()).contains("sources");
+ assertThat(module1.tests()).contains("tests");
// and module properties must have been cleaned
assertThat(module1.getProperties().getProperty("module1.sonar.projectKey")).isNull();
assertThat(module1.getProperties().getProperty("module2.sonar.projectKey")).isNull();
@@ -626,9 +574,8 @@ public class ProjectReactorBuilderTest {
assertThat(module1Feature.getName()).isEqualTo("Foo Module 1 Feature");
assertThat(module1Feature.getVersion()).isEqualTo("1.0-SNAPSHOT");
assertThat(module1Feature.getDescription()).isEqualTo("Description of Module 1 Feature");
- assertThat(module1Feature.getSourceDirs()).contains("src");
- assertThat(module1Feature.getTestDirs()).contains("tests");
- assertThat(module1Feature.getBinaries()).contains("target/classes");
+ assertThat(module1Feature.sources()).contains("src");
+ assertThat(module1Feature.tests()).contains("tests");
// and module properties must have been cleaned
assertThat(module1Feature.getProperties().getProperty("module1.sonar.projectKey")).isNull();
assertThat(module1Feature.getProperties().getProperty("module2.sonar.projectKey")).isNull();
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 4a5e04b4a8e..1486b1b5482 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
@@ -82,7 +82,7 @@ public class DefaultModuleFileSystemTest {
DefaultModuleFileSystem fs = new DefaultModuleFileSystem(moduleInputFileCache,
new Project("foo"), settings, fileIndexer, initializer, componentIndexer);
- assertThat(fs.sourceCharset()).isEqualTo(Charset.defaultCharset());
+ assertThat(fs.encoding()).isEqualTo(Charset.defaultCharset());
assertThat(fs.isDefaultJvmEncoding()).isTrue();
}
@@ -93,7 +93,7 @@ public class DefaultModuleFileSystemTest {
new Project("foo"), settings, fileIndexer, initializer, componentIndexer);
assertThat(fs.encoding()).isEqualTo(Charset.forName("Cp1124"));
- assertThat(fs.sourceCharset()).isEqualTo(Charset.forName("Cp1124"));
+ assertThat(fs.encoding()).isEqualTo(Charset.forName("Cp1124"));
// This test fails when default Java encoding is "IBM AIX Ukraine". Sorry for that.
assertThat(fs.isDefaultJvmEncoding()).isFalse();
@@ -109,7 +109,6 @@ public class DefaultModuleFileSystemTest {
when(initializer.baseDir()).thenReturn(basedir);
when(initializer.buildDir()).thenReturn(buildDir);
when(initializer.workingDir()).thenReturn(workingDir);
- when(initializer.binaryDirs()).thenReturn(Arrays.asList(new File(basedir, "target/classes")));
File javaSrc = new File(basedir, "src/main/java");
javaSrc.mkdirs();
File groovySrc = new File(basedir, "src/main/groovy");
@@ -127,7 +126,7 @@ public class DefaultModuleFileSystemTest {
assertThat(fs.buildDir().getCanonicalPath()).isEqualTo(buildDir.getCanonicalPath());
assertThat(fs.sourceDirs()).hasSize(2);
assertThat(fs.testDirs()).hasSize(1);
- assertThat(fs.binaryDirs()).hasSize(1);
+ assertThat(fs.binaryDirs()).hasSize(0);
}
@Test
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializerTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializerTest.java
index 53ee455adfb..815ead7e5bd 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializerTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializerTest.java
@@ -69,9 +69,8 @@ public class ModuleFileSystemInitializerTest {
ProjectDefinition project = ProjectDefinition.create()
.setBaseDir(baseDir)
.setBuildDir(buildDir)
- .addSourceDirs("src/main/java", "src/main/unknown")
- .addTestDirs("src/test/java", "src/test/unknown")
- .addBinaryDir("target/classes");
+ .addSources("src/main/java", "src/main/unknown")
+ .addTests("src/test/java", "src/test/unknown");
ModuleFileSystemInitializer initializer = new ModuleFileSystemInitializer(project, mock(TempFolder.class), pathResolver);
@@ -81,8 +80,6 @@ public class ModuleFileSystemInitializerTest {
assertThat(path(initializer.sources().get(0))).endsWith("src/main/java");
assertThat(initializer.tests()).hasSize(1);
assertThat(path(initializer.tests().get(0))).endsWith("src/test/java");
- assertThat(initializer.binaryDirs()).hasSize(1);
- assertThat(path(initializer.binaryDirs().get(0))).endsWith("target/classes");
}
private String path(File f) throws IOException {
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/simple-project-with-lib-dir/lib/Fake.class b/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/simple-project-with-lib-dir/lib/Fake.class
deleted file mode 100644
index bf2c3a09e07..00000000000
--- a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/simple-project-with-lib-dir/lib/Fake.class
+++ /dev/null
@@ -1,3 +0,0 @@
-package org.sonar.runner.batch.ProjectReactorBuilderTest.simple
-
-Fake \ No newline at end of file
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/simple-project-with-lib-dir/sonar-project.properties b/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/simple-project-with-lib-dir/sonar-project.properties
deleted file mode 100644
index 0cada50b51f..00000000000
--- a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/simple-project-with-lib-dir/sonar-project.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-sonar.projectKey=com.foo.project
-sonar.projectName=Foo Project
-sonar.projectVersion=1.0-SNAPSHOT
-sonar.projectDescription=Description of Foo Project
-
-sonar.sources=sources
-sonar.libraries=lib
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/simple-project-with-lib-dir/sources/Fake.java b/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/simple-project-with-lib-dir/sources/Fake.java
deleted file mode 100644
index aee03e60b4a..00000000000
--- a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/simple-project-with-lib-dir/sources/Fake.java
+++ /dev/null
@@ -1,3 +0,0 @@
-package org.sonar.runner.batch.ProjectReactorBuilderTest.simple;
-
-class Fake {}
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/simple-project-with-unexisting-binary/sonar-project.properties b/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/simple-project-with-unexisting-binary/sonar-project.properties
deleted file mode 100644
index 55d1ddf0242..00000000000
--- a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/simple-project-with-unexisting-binary/sonar-project.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-sonar.projectKey=com.foo.project
-sonar.projectName=Foo Project
-sonar.projectVersion=1.0-SNAPSHOT
-sonar.projectDescription=Description of Foo Project
-
-sonar.sources=sources
-sonar.binaries=bin
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/simple-project-with-unexisting-binary/sources/Fake.java b/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/simple-project-with-unexisting-binary/sources/Fake.java
deleted file mode 100644
index e67004defc5..00000000000
--- a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/simple-project-with-unexisting-binary/sources/Fake.java
+++ /dev/null
@@ -1 +0,0 @@
-class Fake {}
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/simple-project-with-unexisting-lib/sonar-project.properties b/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/simple-project-with-unexisting-lib/sonar-project.properties
deleted file mode 100644
index 69ccd8d1411..00000000000
--- a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/simple-project-with-unexisting-lib/sonar-project.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-sonar.projectKey=com.foo.project
-sonar.projectName=Foo Project
-sonar.projectVersion=1.0-SNAPSHOT
-sonar.projectDescription=Description of Foo Project
-
-sonar.sources=sources
-sonar.libraries=libs/*.txt
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/simple-project-with-unexisting-lib/sources/Fake.java b/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/simple-project-with-unexisting-lib/sources/Fake.java
deleted file mode 100644
index e67004defc5..00000000000
--- a/sonar-batch/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/simple-project-with-unexisting-lib/sources/Fake.java
+++ /dev/null
@@ -1 +0,0 @@
-class Fake {}