diff options
author | Julien HENRY <henryju@yahoo.fr> | 2016-06-14 13:19:08 +0200 |
---|---|---|
committer | Julien HENRY <henryju@yahoo.fr> | 2016-07-05 14:00:16 +0200 |
commit | 0ba54087a18539d0fbe4d8e985e18b01bfe67757 (patch) | |
tree | e76db84602f4c1a98748f933062ddefcca6936fe /sonar-scanner-engine | |
parent | 1dba982961537fd82e35e016402d962afde7d76b (diff) | |
download | sonarqube-0ba54087a18539d0fbe4d8e985e18b01bfe67757.tar.gz sonarqube-0ba54087a18539d0fbe4d8e985e18b01bfe67757.zip |
SONAR-7727 Remove deprecated stuff on ProjectDefinition
Diffstat (limited to 'sonar-scanner-engine')
7 files changed, 30 insertions, 63 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/index/DefaultIndex.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/index/DefaultIndex.java index d5f1a561729..2c8f1de8ffb 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/batch/index/DefaultIndex.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/index/DefaultIndex.java @@ -333,9 +333,9 @@ public class DefaultIndex extends SonarIndex { List<String> dirs; ProjectDefinition projectDef = projectTree.getProjectDefinition(getProject()); if (isTest) { - dirs = projectDef.getTestDirs(); + dirs = projectDef.tests(); } else { - dirs = projectDef.getSourceDirs(); + dirs = projectDef.sources(); } for (String src : dirs) { java.io.File dirOrFile = pathResolver.relativeFile(projectDef.getBaseDir(), src); diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java index 125a73d0078..bf1eedc2206 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java @@ -19,34 +19,31 @@ */ package org.sonar.batch.scan.filesystem; -import org.sonar.api.batch.fs.InputFile.Status; - -import org.sonar.batch.analysis.DefaultAnalysisMode; 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.batch.analysis.DefaultAnalysisMode; /** * @since 3.5 @@ -60,7 +57,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; @@ -87,7 +83,6 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module this.buildDir = initializer.buildDir(); this.sourceDirsOrFiles = initializer.sources(); this.testDirsOrFiles = initializer.tests(); - this.binaryDirs = initializer.binaryDirs(); // filter the files sensors have access to if (!mode.scanAllFiles()) { @@ -139,7 +134,7 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module @Override public List<File> binaryDirs() { - return binaryDirs; + return Collections.emptyList(); } @Override diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/filesystem/FileSystemLogger.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/filesystem/FileSystemLogger.java index 44a2600773e..765465971f6 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/filesystem/FileSystemLogger.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/filesystem/FileSystemLogger.java @@ -50,7 +50,6 @@ public class FileSystemLogger { logDir(logger, "Working dir: ", fs.workDir()); logPaths(logger, "Source paths: ", fs.baseDir(), fs.sources()); logPaths(logger, "Test paths: ", fs.baseDir(), fs.tests()); - logPaths(logger, "Binary dirs: ", fs.baseDir(), fs.binaryDirs()); logEncoding(logger, fs.encoding()); } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializer.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializer.java index 86d3b08cbbc..0e34f8f93df 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializer.java +++ b/sonar-scanner-engine/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; } @@ -112,11 +103,4 @@ public class ModuleFileSystemInitializer { return testDirsOrFiles; } - /** - * @deprecated since 4.5.1 use SonarQube Java specific API - */ - @Deprecated - List<File> binaryDirs() { - return binaryDirs; - } } diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java index c10bb04dd8b..f796cd246a8 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java @@ -58,7 +58,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.sources()).contains("sources"); } @Test @@ -125,8 +125,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.sources().contains("sources")).isFalse(); + assertThat(rootProject.tests().contains("tests")).isFalse(); // and module properties must have been cleaned assertThat(rootProject.properties().get("module1.sonar.projectKey")).isNull(); assertThat(rootProject.properties().get("module2.sonar.projectKey")).isNull(); @@ -148,9 +148,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.properties().get("module1.sonar.projectKey")).isNull(); assertThat(module1.properties().get("module2.sonar.projectKey")).isNull(); @@ -167,9 +166,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.properties().get("module1.sonar.projectKey")).isNull(); assertThat(module2.properties().get("module2.sonar.projectKey")).isNull(); @@ -216,7 +214,7 @@ public class ProjectReactorBuilderTest { // Module 1 ProjectDefinition module1 = modules.get(0); assertThat(module1.getBaseDir().getCanonicalFile()).isEqualTo(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(getResource(this.getClass(), "multi-language-definitions-all-in-root"), ".sonar/example_java-module")); @@ -224,7 +222,7 @@ public class ProjectReactorBuilderTest { // Module 2 ProjectDefinition module2 = modules.get(1); assertThat(module2.getBaseDir().getCanonicalFile()).isEqualTo(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(getResource(this.getClass(), "multi-language-definitions-all-in-root"), ".sonar/example_groovy-module")); @@ -559,8 +557,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.sources().contains("sources")).isFalse(); + assertThat(rootProject.tests().contains("tests")).isFalse(); // and module properties must have been cleaned assertThat(rootProject.properties().get("module1.sonar.projectKey")).isNull(); assertThat(rootProject.properties().get("module2.sonar.projectKey")).isNull(); @@ -582,9 +580,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.properties().get("module1.sonar.projectKey")).isNull(); assertThat(module1.properties().get("module2.sonar.projectKey")).isNull(); @@ -601,9 +598,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.properties().get("module1.sonar.projectKey")).isNull(); assertThat(module1Feature.properties().get("module2.sonar.projectKey")).isNull(); diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystemTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystemTest.java index 46b70a17522..b6e50899d57 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystemTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystemTest.java @@ -19,11 +19,12 @@ */ package org.sonar.batch.scan.filesystem; -import org.sonar.api.batch.fs.InputFile.Status; - -import org.junit.Before; -import org.sonar.batch.analysis.DefaultAnalysisMode; import com.google.common.collect.Lists; +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.util.Arrays; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -31,14 +32,11 @@ import org.junit.rules.TemporaryFolder; import org.mockito.Mockito; import org.sonar.api.CoreProperties; import org.sonar.api.batch.fs.InputFile; +import org.sonar.api.batch.fs.InputFile.Status; import org.sonar.api.batch.fs.internal.DefaultInputFile; import org.sonar.api.config.Settings; import org.sonar.api.resources.Project; - -import java.io.File; -import java.io.IOException; -import java.nio.charset.Charset; -import java.util.Arrays; +import org.sonar.batch.analysis.DefaultAnalysisMode; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; @@ -146,7 +144,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"); @@ -164,7 +161,6 @@ 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); } @Test diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializerTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializerTest.java index 08dcf9197e5..e7418c6a2d1 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializerTest.java +++ b/sonar-scanner-engine/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 { |