diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
index cc542769f2..c45b077e31 100644
--- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
+++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
@@ -311,7 +311,7 @@ public class DefaultMaven
lifecycleExecutor.execute( session, rm, dispatcher );
}
catch ( Exception e )
- {
+ {
executionExceptions.add( new BuildFailureException( e.getMessage(), e ) );
}
diff --git a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
index f87f0a4a6b..85b70290c5 100644
--- a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
+++ b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
@@ -125,6 +125,11 @@ public class DefaultMavenExecutionRequest
public String getBaseDirectory()
{
+ if ( basedir == null )
+ {
+ return null;
+ }
+
return basedir.getAbsolutePath();
}
diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml
index 17273ae6fd..ac3b13fb74 100644
--- a/maven-embedder/pom.xml
+++ b/maven-embedder/pom.xml
@@ -27,7 +27,7 @@
maven-embedder
Maven Embedder
- 2.1.0.v20061231-1908
+ 2.1.0.v20061231-1929
diff --git a/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestDefaultsPopulator.java b/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestDefaultsPopulator.java
index 16a0baa7e7..f69592528e 100644
--- a/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestDefaultsPopulator.java
+++ b/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestDefaultsPopulator.java
@@ -144,6 +144,13 @@ public class DefaultMavenExecutionRequestDefaultsPopulator
throw new MavenEmbedderException( "Unable to configure Maven for execution", e );
}
+ // BaseDirectory in MavenExecutionRequest
+
+ if ( request.getPomFile() != null && request.getBaseDirectory() == null )
+ {
+ request.setBasedir( new File( request.getPomFile() ) );
+ }
+
return request;
}
diff --git a/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java b/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java
index 7f8727d186..5b697a9ce2 100644
--- a/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java
+++ b/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java
@@ -54,12 +54,12 @@ public class MavenEmbedderTest
// Goal/Phase execution tests
// ----------------------------------------------------------------------
- public void testPhaseExecution()
+ public void testSimplePhaseExecutionUsingABaseDirectory()
throws Exception
{
File testDirectory = new File( basedir, "src/test/embedder-test-project" );
- File targetDirectory = new File( basedir, "target/embedder-test-project" );
+ File targetDirectory = new File( basedir, "target/embedder-test-project0" );
FileUtils.copyDirectoryStructure( testDirectory, targetDirectory );
@@ -69,6 +69,34 @@ public class MavenEmbedderTest
MavenExecutionResult result = maven.execute( request );
+ MavenProject project = result.getMavenProject();
+
+ assertEquals( "embedder-test-project", project.getArtifactId() );
+
+ File jar = new File( targetDirectory, "target/embedder-test-project-1.0-SNAPSHOT.jar" );
+
+ assertTrue( jar.exists() );
+ }
+
+ public void testSimplePhaseExecutionUsingAPomFile()
+ throws Exception
+ {
+ File testDirectory = new File( basedir, "src/test/embedder-test-project" );
+
+ File targetDirectory = new File( basedir, "target/embedder-test-project1" );
+
+ FileUtils.copyDirectoryStructure( testDirectory, targetDirectory );
+
+ MavenExecutionRequest request = new DefaultMavenExecutionRequest()
+ .setPomFile( new File( targetDirectory, "pom.xml" ).getAbsolutePath() )
+ .setGoals( Arrays.asList( new String[]{ "package" } ) );
+
+ MavenExecutionResult result = maven.execute( request );
+
+ MavenProject project = result.getMavenProject();
+
+ assertEquals( "embedder-test-project", project.getArtifactId() );
+
File jar = new File( targetDirectory, "target/embedder-test-project-1.0-SNAPSHOT.jar" );
assertTrue( jar.exists() );