aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-07-03 17:31:17 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2014-07-03 17:31:56 +0200
commitf280711447aef1c46827208bb999e480f68a340c (patch)
treea8ff2475f412b73f9b94b1a6340756ede1fa0243 /sonar-plugin-api
parentf8136fcae2693df33c4c9cd8edefe5a381f165b3 (diff)
downloadsonarqube-f280711447aef1c46827208bb999e480f68a340c.tar.gz
sonarqube-f280711447aef1c46827208bb999e480f68a340c.zip
SONAR-5419 sonar.sources and sonar.tests should support a mixed list of files and folders
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java228
1 files changed, 173 insertions, 55 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java
index 62c4da3d653..b228e383421 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java
@@ -39,9 +39,28 @@ import java.util.Properties;
*/
public class ProjectDefinition {
- public static final String SOURCE_DIRS_PROPERTY = "sonar.sources";
+ public static final String SOURCES_PROPERTY = "sonar.sources";
+ /**
+ * @deprecated since 4.5 use {@link #SOURCES_PROPERTY}
+ */
+ @Deprecated
+ public static final String SOURCE_DIRS_PROPERTY = SOURCES_PROPERTY;
+ /**
+ * @deprecated since 4.5 use {@link #SOURCES_PROPERTY}
+ */
+ @Deprecated
public static final String SOURCE_FILES_PROPERTY = "sonar.sourceFiles";
- public static final String TEST_DIRS_PROPERTY = "sonar.tests";
+
+ public static final String TESTS_PROPERTY = "sonar.tests";
+ /**
+ * @deprecated since 4.5 use {@link #TESTS_PROPERTY}
+ */
+ @Deprecated
+ public static final String TEST_DIRS_PROPERTY = TESTS_PROPERTY;
+ /**
+ * @deprecated since 4.5 use {@link #TESTS_PROPERTY}
+ */
+ @Deprecated
public static final String TEST_FILES_PROPERTY = "sonar.testFiles";
public static final String BINARIES_PROPERTY = "sonar.binaries";
public static final String LIBRARIES_PROPERTY = "sonar.libraries";
@@ -167,39 +186,94 @@ public class ProjectDefinition {
properties.put(key, newValue);
}
- public List<String> getSourceDirs() {
- String sources = properties.getProperty(SOURCE_DIRS_PROPERTY, "");
+ /**
+ * @return Source files and folders.
+ */
+ public List<String> sources() {
+ String sources = properties.getProperty(SOURCES_PROPERTY, "");
return trim(StringUtils.split(sources, SEPARATOR));
}
/**
- * @param paths paths to directory with main sources.
+ * @deprecated since 4.5 use {@link #sources()}
+ */
+ @Deprecated
+ public List<String> getSourceDirs() {
+ return sources();
+ }
+
+ /**
+ * @param paths paths to file or directory with main sources.
* They can be absolute or relative to project base directory.
*/
- public ProjectDefinition addSourceDirs(String... paths) {
+ public ProjectDefinition addSources(String... paths) {
for (String path : paths) {
- appendProperty(SOURCE_DIRS_PROPERTY, path);
+ appendProperty(SOURCES_PROPERTY, path);
}
return this;
}
- public ProjectDefinition addSourceDirs(File... dirs) {
- for (File dir : dirs) {
- addSourceDirs(dir.getAbsolutePath());
+ /**
+ * @deprecated since 4.5 use {@link #addSources(String...)}
+ */
+ @Deprecated
+ public ProjectDefinition addSourceDirs(String... paths) {
+ return addSources(paths);
+ }
+
+ public ProjectDefinition addSources(File... fileOrDirs) {
+ for (File fileOrDir : fileOrDirs) {
+ addSources(fileOrDir.getAbsolutePath());
}
return this;
}
- public ProjectDefinition resetSourceDirs() {
- properties.remove(SOURCE_DIRS_PROPERTY);
+ /**
+ * @deprecated since 4.5 use {@link #addSources(File...)}
+ */
+ @Deprecated
+ public ProjectDefinition addSourceDirs(File... dirs) {
+ return addSources(dirs);
+ }
+
+ public ProjectDefinition resetSources() {
+ properties.remove(SOURCES_PROPERTY);
return this;
}
+ /**
+ * @deprecated since 4.5 use {@link #resetSources()}
+ */
+ @Deprecated
+ public ProjectDefinition resetSourceDirs() {
+ return resetSources();
+ }
+
+ public ProjectDefinition setSources(String... paths) {
+ resetSources();
+ return addSources(paths);
+ }
+
+ /**
+ * @deprecated since 4.5 use {@link #setSources(String...)}
+ */
+ @Deprecated
public ProjectDefinition setSourceDirs(String... paths) {
- resetSourceDirs();
- return addSourceDirs(paths);
+ return setSources(paths);
}
+ public ProjectDefinition setSources(File... filesOrDirs) {
+ resetSources();
+ for (File fileOrDir : filesOrDirs) {
+ addSources(fileOrDir.getAbsolutePath());
+ }
+ return this;
+ }
+
+ /**
+ * @deprecated since 4.5 use {@link #setSources(File...)}
+ */
+ @Deprecated
public ProjectDefinition setSourceDirs(File... dirs) {
resetSourceDirs();
for (File dir : dirs) {
@@ -209,96 +283,140 @@ public class ProjectDefinition {
}
/**
- * Adding source files is possible only if no source directories have been set.
- * Absolute path or relative path from project base dir.
+ * @deprecated since 4.5 use {@link #addSources(File...)}
*/
+ @Deprecated
public ProjectDefinition addSourceFiles(String... paths) {
- for (String path : paths) {
- appendProperty(SOURCE_FILES_PROPERTY, path);
- }
- return this;
+ return addSources(paths);
}
/**
- * Adding source files is possible only if no source directories have been set.
+ * @deprecated since 4.5 use {@link #addSources(File...)}
*/
+ @Deprecated
public ProjectDefinition addSourceFiles(File... files) {
- for (File file : files) {
- addSourceFiles(file.getAbsolutePath());
- }
- return this;
+ return addSources(files);
}
+ /**
+ * @deprecated since 4.5 use {@link #sources()}
+ */
+ @Deprecated
public List<String> getSourceFiles() {
- String sources = properties.getProperty(SOURCE_FILES_PROPERTY, "");
+ return sources();
+ }
+
+ public List<String> tests() {
+ String sources = properties.getProperty(TESTS_PROPERTY, "");
return trim(StringUtils.split(sources, SEPARATOR));
}
+ /**
+ * @deprecated since 4.5 use {@link #tests()}
+ */
+ @Deprecated
public List<String> getTestDirs() {
- String sources = properties.getProperty(TEST_DIRS_PROPERTY, "");
- return trim(StringUtils.split(sources, SEPARATOR));
+ return tests();
}
/**
- * @param paths path to directory with test sources.
+ * @param paths path to files or directories with test sources.
* It can be absolute or relative to project directory.
*/
- public ProjectDefinition addTestDirs(String... paths) {
+ public ProjectDefinition addTests(String... paths) {
for (String path : paths) {
- appendProperty(TEST_DIRS_PROPERTY, path);
+ appendProperty(TESTS_PROPERTY, path);
}
return this;
}
- public ProjectDefinition addTestDirs(File... dirs) {
- for (File dir : dirs) {
- addTestDirs(dir.getAbsolutePath());
+ /**
+ * @deprecated since 4.5 use {@link #addTests(String...)}
+ */
+ @Deprecated
+ public ProjectDefinition addTestDirs(String... paths) {
+ return addTests(paths);
+ }
+
+ public ProjectDefinition addTests(File... fileOrDirs) {
+ for (File fileOrDir : fileOrDirs) {
+ addTests(fileOrDir.getAbsolutePath());
}
return this;
}
+ /**
+ * @deprecated since 4.5 use {@link #addTests(File...)}
+ */
+ @Deprecated
+ public ProjectDefinition addTestDirs(File... dirs) {
+ return addTests(dirs);
+ }
+
+ public ProjectDefinition setTests(String... paths) {
+ resetTests();
+ return addTests(paths);
+ }
+
+ /**
+ * @deprecated since 4.5 use {@link #setTests(String...)}
+ */
+ @Deprecated
public ProjectDefinition setTestDirs(String... paths) {
- resetTestDirs();
- return addTestDirs(paths);
+ return setTests(paths);
}
- public ProjectDefinition setTestDirs(File... dirs) {
- resetTestDirs();
- for (File dir : dirs) {
- addTestDirs(dir.getAbsolutePath());
+ public ProjectDefinition setTests(File... fileOrDirs) {
+ resetTests();
+ for (File dir : fileOrDirs) {
+ addTests(dir.getAbsolutePath());
}
return this;
}
- public ProjectDefinition resetTestDirs() {
- properties.remove(TEST_DIRS_PROPERTY);
+ /**
+ * @deprecated since 4.5 use {@link #setTests(File...)}
+ */
+ @Deprecated
+ public ProjectDefinition setTestDirs(File... dirs) {
+ return setTests(dirs);
+ }
+
+ public ProjectDefinition resetTests() {
+ properties.remove(TESTS_PROPERTY);
return this;
}
/**
- * Adding source files is possible only if no source directories have been set.
- * Absolute path or relative path from project base dir.
+ * @deprecated since 4.5 use {@link #resetTests()}
+ */
+ @Deprecated
+ public ProjectDefinition resetTestDirs() {
+ return resetTests();
+ }
+
+ /**
+ * @deprecated since 4.5 use {@link #addTests(String...)}
*/
+ @Deprecated
public ProjectDefinition addTestFiles(String... paths) {
- for (String path : paths) {
- appendProperty(TEST_FILES_PROPERTY, path);
- }
- return this;
+ return addTests(paths);
}
/**
- * Adding source files is possible only if no source directories have been set.
+ * @deprecated since 4.5 use {@link #addTests(File...)}
*/
+ @Deprecated
public ProjectDefinition addTestFiles(File... files) {
- for (File file : files) {
- addTestFiles(file.getAbsolutePath());
- }
- return this;
+ return addTests(files);
}
+ /**
+ * @deprecated since 4.5 use {@link #tests()}
+ */
+ @Deprecated
public List<String> getTestFiles() {
- String sources = properties.getProperty(TEST_FILES_PROPERTY, "");
- return trim(StringUtils.split(sources, SEPARATOR));
+ return tests();
}
public List<String> getBinaries() {