diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-04-09 02:19:28 +0400 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-04-26 13:00:11 +0400 |
commit | e174628696636f74808f61c76a44da994edcadc7 (patch) | |
tree | 06af7a9e94d17294cce72ddded48a84c8b2b3f1f /sonar-batch/src/main/java/org/sonar/batch/bootstrapper | |
parent | 4eb630d0ff939898efdd9ef29330736ca4e50ebc (diff) | |
download | sonarqube-e174628696636f74808f61c76a44da994edcadc7.tar.gz sonarqube-e174628696636f74808f61c76a44da994edcadc7.zip |
SONAR-2298 Add support for multi-modules for non-Maven projects
* Use ProjectDefinition in ProjectTree instead of MavenProject
* Allow to specify extensions for project's container via
ProjectDefinition, so MavenProject not passed directly to batch in mojos
* ProjectDefinition should store all information in properties
* Replace DefaultProjectFileSystem by DefaultProjectFileSystem2, which
works not only for Maven projects
* Add DefaultProjectClasspath, which works not only for Maven projects
* Enable ProjectLinksSensor only for Maven
Diffstat (limited to 'sonar-batch/src/main/java/org/sonar/batch/bootstrapper')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/bootstrapper/ProjectDefinition.java | 75 |
1 files changed, 61 insertions, 14 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/ProjectDefinition.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/ProjectDefinition.java index b632feb60ac..907f30940ac 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/ProjectDefinition.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/ProjectDefinition.java @@ -19,12 +19,14 @@ */ package org.sonar.batch.bootstrapper; +import com.google.common.collect.Lists; +import org.apache.commons.lang.StringUtils; + import java.io.File; +import java.util.Arrays; import java.util.List; import java.util.Properties; -import com.google.common.collect.Lists; - /** * Describes project in a form suitable to bootstrap Sonar batch. * We assume that project is just a set of configuration properties and directories. @@ -33,13 +35,19 @@ import com.google.common.collect.Lists; */ public class ProjectDefinition { + private static final String PROJECT_SOURCES_PROPERTY = "sonar.sources"; + private static final String PROJECT_TESTS_PROPERTY = "sonar.tests"; + private static final String PROJECT_BINARIES_PROPERTY = "sonar.binaries"; + private static final String PROJECT_LIBRARIES_PROPERTY = "sonar.libraries"; + + private static final char SEPARATOR = ','; + private File baseDir; private File workDir; private Properties properties; - private List<String> sourceDirs = Lists.newArrayList(); - private List<String> testDirs = Lists.newArrayList(); - private List<String> binaries = Lists.newArrayList(); - private List<String> libraries = Lists.newArrayList(); + private List<ProjectDefinition> modules = Lists.newArrayList(); + + private List<Object> containerExtensions = Lists.newArrayList(); /** * @param baseDir project base directory @@ -63,8 +71,14 @@ public class ProjectDefinition { return properties; } + private void appendProperty(String key, String value) { + String newValue = properties.getProperty(key, "") + SEPARATOR + value; + properties.put(key, newValue); + } + public List<String> getSourceDirs() { - return sourceDirs; + String sources = properties.getProperty(PROJECT_SOURCES_PROPERTY, ""); + return Arrays.asList(StringUtils.split(sources, SEPARATOR)); } /** @@ -72,11 +86,12 @@ public class ProjectDefinition { * It can be absolute or relative to project directory. */ public void addSourceDir(String path) { - sourceDirs.add(path); + appendProperty(PROJECT_SOURCES_PROPERTY, path); } public List<String> getTestDirs() { - return testDirs; + String sources = properties.getProperty(PROJECT_TESTS_PROPERTY, ""); + return Arrays.asList(StringUtils.split(sources, SEPARATOR)); } /** @@ -84,11 +99,12 @@ public class ProjectDefinition { * It can be absolute or relative to project directory. */ public void addTestDir(String path) { - testDirs.add(path); + appendProperty(PROJECT_TESTS_PROPERTY, path); } public List<String> getBinaries() { - return binaries; + String sources = properties.getProperty(PROJECT_BINARIES_PROPERTY, ""); + return Arrays.asList(StringUtils.split(sources, SEPARATOR)); } /** @@ -97,11 +113,12 @@ public class ProjectDefinition { * @TODO currently Sonar supports only one such directory due to dependency on MavenProject */ public void addBinaryDir(String path) { - binaries.add(path); + appendProperty(PROJECT_BINARIES_PROPERTY, path); } public List<String> getLibraries() { - return libraries; + String sources = properties.getProperty(PROJECT_LIBRARIES_PROPERTY, ""); + return Arrays.asList(StringUtils.split(sources, SEPARATOR)); } /** @@ -109,6 +126,36 @@ public class ProjectDefinition { * It can be absolute or relative to project directory. */ public void addLibrary(String path) { - libraries.add(path); + appendProperty(PROJECT_LIBRARIES_PROPERTY, path); + } + + /** + * Adds an extension, which would be available in PicoContainer during analysis of this project. + * + * @since 2.8 + */ + public void addContainerExtension(Object extension) { + containerExtensions.add(extension); + } + + /** + * @since 2.8 + */ + public List<Object> getContainerExtensions() { + return containerExtensions; + } + + /** + * @since 2.8 + */ + public void addModule(ProjectDefinition projectDefinition) { + modules.add(projectDefinition); + } + + /** + * @since 2.8 + */ + public List<ProjectDefinition> getModules() { + return modules; } } |