diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-01-28 19:35:57 +0300 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-01-28 19:36:53 +0300 |
commit | 73e6ee80edae3e5f2a543df88776e1039b425462 (patch) | |
tree | 9b5f7a81cbf0fc0bf3f7a8ef3983879f0866e66a /sonar-batch | |
parent | b69ae6b7c4981e63ba099a96d0c7d8ae9b9e65f0 (diff) | |
download | sonarqube-73e6ee80edae3e5f2a543df88776e1039b425462.tar.gz sonarqube-73e6ee80edae3e5f2a543df88776e1039b425462.zip |
Add workDir to ProjectDefinition
Diffstat (limited to 'sonar-batch')
3 files changed, 18 insertions, 32 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 f1b05d90df2..68eb57b18f8 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/InMemoryPomCreator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/InMemoryPomCreator.java @@ -78,12 +78,13 @@ public class InMemoryPomCreator { pom.setArtifacts(Collections.EMPTY_SET); // Configure fake directories - String buildDirectory = properties.getProperty("project.build.directory", project.getBaseDir().getAbsolutePath() + "/target"); + File workDir = project.getWorkDir(); + String buildDirectory = workDir.getAbsolutePath() + "/target"; pom.getBuild().setDirectory(buildDirectory); - String buildOutputDirectory = properties.getProperty("project.build.outputDirectory", buildDirectory + "/classes"); + String buildOutputDirectory = buildDirectory + "/classes"; pom.getBuild().setOutputDirectory(buildOutputDirectory); Reporting reporting = new Reporting(); - String reportingOutputDirectory = properties.getProperty("project.reporting.outputDirectory", buildDirectory + "/site"); + String reportingOutputDirectory = buildDirectory + "/site"; reporting.setOutputDirectory(reportingOutputDirectory); pom.setReporting(reporting); 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 b2f7b5f8ca5..10ede5a1100 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 @@ -35,6 +35,7 @@ import java.util.Properties; public class ProjectDefinition { private File baseDir; + private File workDir; private Properties properties; private List<String> sourceDirs = Lists.newArrayList(); private List<String> testDirs = Lists.newArrayList(); @@ -43,8 +44,9 @@ public class ProjectDefinition { * @param baseDir project base directory * @param properties project properties */ - public ProjectDefinition(File baseDir, Properties properties) { + public ProjectDefinition(File baseDir, File workDir, Properties properties) { this.baseDir = baseDir; + this.workDir = workDir; this.properties = properties; } @@ -52,6 +54,10 @@ public class ProjectDefinition { return baseDir; } + public File getWorkDir() { + return workDir; + } + public Properties getProperties() { return properties; } 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 c3bec7ff3f2..83550c40c0d 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/InMemoryPomCreatorTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/InMemoryPomCreatorTest.java @@ -41,7 +41,8 @@ public class InMemoryPomCreatorTest { public void setUp() { properties = new Properties(); File baseDir = new File("."); - project = new ProjectDefinition(baseDir, properties); + File workDir = new File(baseDir, "sonar"); + project = new ProjectDefinition(baseDir, workDir, properties); } @Test @@ -54,6 +55,11 @@ public class InMemoryPomCreatorTest { assertThat(pom.getGroupId(), is("org.example")); assertThat(pom.getArtifactId(), is("example")); assertThat(pom.getProperties(), is(project.getProperties())); + assertThat(pom.getBasedir(), is(project.getBaseDir())); + String buildDirectory = project.getWorkDir().getAbsolutePath() + "/target"; + assertThat(pom.getBuild().getDirectory(), is(buildDirectory)); + assertThat(pom.getBuild().getOutputDirectory(), is(buildDirectory + "/classes")); + assertThat(pom.getReporting().getOutputDirectory(), is(buildDirectory + "/site")); } @Test @@ -84,33 +90,6 @@ public class InMemoryPomCreatorTest { } @Test - public void standardDirectoriesLayout() { - createRequiredProperties(); - - MavenProject pom = create(); - - assertThat(pom.getBasedir(), is(project.getBaseDir())); - String buildDirectory = project.getBaseDir().getAbsolutePath() + "/target"; - assertThat(pom.getBuild().getDirectory(), is(buildDirectory)); - assertThat(pom.getBuild().getOutputDirectory(), is(buildDirectory + "/classes")); - assertThat(pom.getReporting().getOutputDirectory(), is(buildDirectory + "/site")); - } - - @Test - public void nonStandardDirectoriesLayout() { - createRequiredProperties(); - properties.setProperty("project.build.directory", "build"); - properties.setProperty("project.build.outputDirectory", "classes"); - properties.setProperty("project.reporting.outputDirectory", "reports"); - - MavenProject pom = create(); - - assertThat(pom.getBuild().getDirectory(), is("build")); - assertThat(pom.getBuild().getOutputDirectory(), is("classes")); - assertThat(pom.getReporting().getOutputDirectory(), is("reports")); - } - - @Test public void shouldNotFailIfNoBinaries() throws Exception { createRequiredProperties(); |