]> source.dussan.org Git - sonarqube.git/commitdiff
Add workDir to ProjectDefinition
authorEvgeny Mandrikov <mandrikov@gmail.com>
Fri, 28 Jan 2011 16:35:57 +0000 (19:35 +0300)
committerEvgeny Mandrikov <mandrikov@gmail.com>
Fri, 28 Jan 2011 16:36:53 +0000 (19:36 +0300)
sonar-batch/src/main/java/org/sonar/batch/InMemoryPomCreator.java
sonar-batch/src/main/java/org/sonar/batch/bootstrapper/ProjectDefinition.java
sonar-batch/src/test/java/org/sonar/batch/InMemoryPomCreatorTest.java

index f1b05d90df29a71e1972f9caa1eba692b4b564a8..68eb57b18f87f49051e74cac405c902c6e461b0c 100644 (file)
@@ -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);
 
index b2f7b5f8ca5e6e7fed44490b5a067191d4b3f31f..10ede5a11005e56174a7f771b5805b443512eca9 100644 (file)
@@ -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;
   }
index c3bec7ff3f20cc62b0ec5192a9d5eb246bbe6637..83550c40c0d824bf3486b0dd0786d14f135f0152 100644 (file)
@@ -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
@@ -83,33 +89,6 @@ public class InMemoryPomCreatorTest {
     assertThat((String) pom.getCompileClasspathElements().get(0), is("junit.jar"));
   }
 
-  @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();