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);
public class ProjectDefinition {
private File baseDir;
+ private File workDir;
private Properties properties;
private List<String> sourceDirs = Lists.newArrayList();
private List<String> testDirs = Lists.newArrayList();
* @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;
}
return baseDir;
}
+ public File getWorkDir() {
+ return workDir;
+ }
+
public Properties getProperties() {
return properties;
}
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
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
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();