diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-02-02 01:58:56 +0300 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-02-02 01:58:56 +0300 |
commit | c449685c7fc56d15daab8eec3df557ed6a8ec938 (patch) | |
tree | ba15df225aa56706ce72e8a7e92f5bd9c008a7f6 /sonar-batch/src/main/java/org/sonar/batch | |
parent | 356f32fa759fdf4b9801194b26fc8dcc877dc3fc (diff) | |
download | sonarqube-c449685c7fc56d15daab8eec3df557ed6a8ec938.tar.gz sonarqube-c449685c7fc56d15daab8eec3df557ed6a8ec938.zip |
Improve ProjectDefinition
* Replace properties "sonar.projectBinaries" and "sonar.projectLibraries"
by explicit fields in ProjectDefinition
Diffstat (limited to 'sonar-batch/src/main/java/org/sonar/batch')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/InMemoryPomCreator.java | 17 | ||||
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/bootstrapper/ProjectDefinition.java | 27 |
2 files changed, 38 insertions, 6 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/InMemoryPomCreator.java b/sonar-batch/src/main/java/org/sonar/batch/InMemoryPomCreator.java index 04c6e32aa74..1f1f1a3be9d 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/InMemoryPomCreator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/InMemoryPomCreator.java @@ -28,7 +28,10 @@ import org.sonar.api.utils.SonarException; import org.sonar.batch.bootstrapper.ProjectDefinition; import java.io.File; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Properties; /** * This is a dirty hack for for non-Maven environments, @@ -46,8 +49,10 @@ public class InMemoryPomCreator { File workDir = project.getWorkDir(); String buildDirectory = workDir.getAbsolutePath() + "/target"; Properties properties = project.getProperties(); - final String binaries = properties.getProperty("sonar.projectBinaries", buildDirectory + "/classes"); - final String[] libraries = StringUtils.split(properties.getProperty("sonar.projectLibraries", ""), ','); + + if (project.getBinaries().size() == 0) { + project.addBinaryDir(buildDirectory + "/classes"); + } final MavenProject pom = new MavenProject() { /** @@ -64,8 +69,8 @@ public class InMemoryPomCreator { @Override public List<String> getCompileClasspathElements() throws DependencyResolutionRequiredException { List<String> cp = new ArrayList<String>(); - cp.add(binaries); - cp.addAll(Arrays.asList(libraries)); + cp.addAll(project.getBinaries()); + cp.addAll(project.getLibraries()); return cp; } }; @@ -85,7 +90,7 @@ public class InMemoryPomCreator { // Configure fake directories pom.getBuild().setDirectory(buildDirectory); - pom.getBuild().setOutputDirectory(binaries); + pom.getBuild().setOutputDirectory(project.getBinaries().get(0)); Reporting reporting = new Reporting(); String reportingOutputDirectory = buildDirectory + "/site"; reporting.setOutputDirectory(reportingOutputDirectory); 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 10ede5a1100..54ea3b5f5e3 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 @@ -39,6 +39,8 @@ public class ProjectDefinition { 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(); /** * @param baseDir project base directory @@ -85,4 +87,29 @@ public class ProjectDefinition { public void addTestDir(String path) { testDirs.add(path); } + + public List<String> getBinaries() { + return binaries; + } + + /** + * @param path path to directory with compiled source. In case of Java this is directory with class files. + * It can be absolute or relative to project directory. + * @TODO currently Sonar supports only one such directory due to dependency on MavenProject + */ + public void addBinaryDir(String path) { + binaries.add(path); + } + + public List<String> getLibraries() { + return libraries; + } + + /** + * @param path path to file with third-party library. In case of Java this is path to jar file. + * It can be absolute or relative to project directory. + */ + public void addLibrary(String path) { + libraries.add(path); + } } |