aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Mandrikov <mandrikov@gmail.com>2011-02-01 15:54:00 +0300
committerEvgeny Mandrikov <mandrikov@gmail.com>2011-02-01 15:54:00 +0300
commit608e72b03e61aadfe1b58817b3be6ad337617e3c (patch)
tree6839c5c8e965544a77fa9cc959607d9c06b1f085
parent56e588b0e5be949fbd7c64b7e170d5947d7727af (diff)
downloadsonarqube-608e72b03e61aadfe1b58817b3be6ad337617e3c.tar.gz
sonarqube-608e72b03e61aadfe1b58817b3be6ad337617e3c.zip
Add property "sonar.projectLibraries"
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/InMemoryPomCreator.java22
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/InMemoryPomCreatorTest.java12
2 files changed, 19 insertions, 15 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 8e0ada5e60d..04c6e32aa74 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/InMemoryPomCreator.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/InMemoryPomCreator.java
@@ -28,10 +28,7 @@ import org.sonar.api.utils.SonarException;
import org.sonar.batch.bootstrapper.ProjectDefinition;
import java.io.File;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Properties;
+import java.util.*;
/**
* This is a dirty hack for for non-Maven environments,
@@ -46,8 +43,11 @@ public class InMemoryPomCreator {
}
public MavenProject create() {
+ File workDir = project.getWorkDir();
+ String buildDirectory = workDir.getAbsolutePath() + "/target";
Properties properties = project.getProperties();
- final String[] binaries = StringUtils.split(properties.getProperty("sonar.projectBinaries", ""), ',');
+ final String binaries = properties.getProperty("sonar.projectBinaries", buildDirectory + "/classes");
+ final String[] libraries = StringUtils.split(properties.getProperty("sonar.projectLibraries", ""), ',');
final MavenProject pom = new MavenProject() {
/**
@@ -59,11 +59,14 @@ public class InMemoryPomCreator {
};
/**
- * This allows to specify project binaries.
+ * This allows to specify project classpath (binaries + libraries).
*/
@Override
public List<String> getCompileClasspathElements() throws DependencyResolutionRequiredException {
- return Arrays.asList(binaries);
+ List<String> cp = new ArrayList<String>();
+ cp.add(binaries);
+ cp.addAll(Arrays.asList(libraries));
+ return cp;
}
};
@@ -81,11 +84,8 @@ public class InMemoryPomCreator {
pom.setArtifacts(Collections.EMPTY_SET);
// Configure fake directories
- File workDir = project.getWorkDir();
- String buildDirectory = workDir.getAbsolutePath() + "/target";
pom.getBuild().setDirectory(buildDirectory);
- String buildOutputDirectory = buildDirectory + "/classes";
- pom.getBuild().setOutputDirectory(buildOutputDirectory);
+ pom.getBuild().setOutputDirectory(binaries);
Reporting reporting = new Reporting();
String reportingOutputDirectory = buildDirectory + "/site";
reporting.setOutputDirectory(reportingOutputDirectory);
diff --git a/sonar-batch/src/test/java/org/sonar/batch/InMemoryPomCreatorTest.java b/sonar-batch/src/test/java/org/sonar/batch/InMemoryPomCreatorTest.java
index 260e6846d69..9893598add2 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/InMemoryPomCreatorTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/InMemoryPomCreatorTest.java
@@ -27,6 +27,7 @@ import org.sonar.api.utils.SonarException;
import org.sonar.batch.bootstrapper.ProjectDefinition;
import java.io.File;
+import java.util.List;
import java.util.Properties;
import static org.hamcrest.Matchers.is;
@@ -96,12 +97,15 @@ public class InMemoryPomCreatorTest {
@Test
public void classpath() throws Exception {
createRequiredProperties();
- properties.setProperty("sonar.projectBinaries", "junit.jar");
+ properties.setProperty("sonar.projectBinaries", "/classes");
+ properties.setProperty("sonar.projectLibraries", "junit.jar");
MavenProject pom = create();
- assertThat(pom.getCompileClasspathElements().size(), is(1));
- assertThat((String) pom.getCompileClasspathElements().get(0), is("junit.jar"));
+ List<String> cp = pom.getCompileClasspathElements();
+ assertThat(cp.size(), is(2));
+ assertThat(cp.get(0), is("/classes"));
+ assertThat(cp.get(1), is("junit.jar"));
}
@Test
@@ -109,7 +113,7 @@ public class InMemoryPomCreatorTest {
createRequiredProperties();
MavenProject pom = create();
- assertThat(pom.getCompileClasspathElements().size(), is(0));
+ assertThat(pom.getCompileClasspathElements().size(), is(1));
}
private void createRequiredProperties() {