maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject svn commit: r491524 - in /maven/components/trunk: maven-core/src/main/java/org/apache/maven/ maven-core/src/main/java/org/apache/maven/execution/ maven-embedder/ maven-embedder/src/main/java/org/apache/maven/embedder/execution/ maven-embedder/src/test/...
Date Mon, 01 Jan 2007 02:52:57 GMT
Author: jvanzyl
Date: Sun Dec 31 18:52:56 2006
New Revision: 491524

URL: http://svn.apache.org/viewvc?view=rev&rev=491524
Log:
MNG-2733 When request.setPomFile( file ) is used, takes its basedir for the execution request
so that request.getBasedir() doesn't NPE

Modified:
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
    maven/components/trunk/maven-embedder/pom.xml
    maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestDefaultsPopulator.java
    maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java?view=diff&rev=491524&r1=491523&r2=491524
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java Sun
Dec 31 18:52:56 2006
@@ -311,7 +311,7 @@
             lifecycleExecutor.execute( session, rm, dispatcher );
         }
         catch ( Exception e )
-        {
+        {                        
             executionExceptions.add( new BuildFailureException( e.getMessage(), e ) );
         }
 

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java?view=diff&rev=491524&r1=491523&r2=491524
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
(original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
Sun Dec 31 18:52:56 2006
@@ -125,6 +125,11 @@
 
     public String getBaseDirectory()
     {
+        if ( basedir == null )
+        {
+            return null;
+        }
+
         return basedir.getAbsolutePath();
     }
 

Modified: maven/components/trunk/maven-embedder/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/pom.xml?view=diff&rev=491524&r1=491523&r2=491524
==============================================================================
--- maven/components/trunk/maven-embedder/pom.xml (original)
+++ maven/components/trunk/maven-embedder/pom.xml Sun Dec 31 18:52:56 2006
@@ -27,7 +27,7 @@
   <artifactId>maven-embedder</artifactId>
   <name>Maven Embedder</name>
   <properties>
-    <bundleVersion>2.1.0.v20061231-1908</bundleVersion>
+    <bundleVersion>2.1.0.v20061231-1929</bundleVersion>
   </properties>
   <build>
     <resources>

Modified: maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestDefaultsPopulator.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestDefaultsPopulator.java?view=diff&rev=491524&r1=491523&r2=491524
==============================================================================
--- maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestDefaultsPopulator.java
(original)
+++ maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestDefaultsPopulator.java
Sun Dec 31 18:52:56 2006
@@ -144,6 +144,13 @@
             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;
     }
 

Modified: maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java?view=diff&rev=491524&r1=491523&r2=491524
==============================================================================
--- maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java
(original)
+++ maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java
Sun Dec 31 18:52:56 2006
@@ -54,12 +54,12 @@
     // 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 );
 
@@ -68,6 +68,34 @@
             .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() );
+    }
+
+    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"
);
 



Mime
View raw message