maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r747168 - in /maven/plugins/trunk/maven-invoker-plugin/src: it/staging-dependencies/ it/staging-dependencies/repo/org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/ it/staging-dependencies/repo/org/apache/maven/its/parent-a/ it/staging-dependen...
Date Mon, 23 Feb 2009 22:29:14 GMT
Author: bentmann
Date: Mon Feb 23 22:29:07 2009
New Revision: 747168

URL: http://svn.apache.org/viewvc?rev=747168&view=rev
Log:
[MINVOKER-84] Staging of snapshot dependencies is incomplete

Added:
    maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-a/
    maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-a/0.1-SNAPSHOT/
    maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-a/0.1-SNAPSHOT/maven-metadata.xml
  (with props)
    maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-a/0.1-SNAPSHOT/parent-a-0.1-20081020.164906-1.pom
    maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-b/
    maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-b/0.1-SNAPSHOT/
    maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-b/0.1-SNAPSHOT/maven-metadata.xml
  (with props)
    maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-b/0.1-SNAPSHOT/parent-b-0.1-20081020.164906-1.pom
    maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/pom/
    maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/pom/0.3-SNAPSHOT/
    maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/pom/0.3-SNAPSHOT/maven-metadata.xml
  (with props)
    maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/pom/0.3-SNAPSHOT/pom-0.3-20081020.164906-1.pom
    maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/PomUtils.java
  (with props)
Modified:
    maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/pom.xml
    maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/minvoker-70-1.0-20081020.164906-1.pom
    maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/verify.bsh
    maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InstallMojo.java
    maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java

Modified: maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/pom.xml?rev=747168&r1=747167&r2=747168&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/pom.xml (original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/pom.xml Mon Feb 23
22:29:07 2009
@@ -43,6 +43,13 @@
       <artifactId>minvoker-70</artifactId>
       <version>1.0-SNAPSHOT</version>
     </dependency>
+    <!-- a dependency that does not contribute to the class path but must be staged, too
-->
+    <dependency>
+      <groupId>org.apache.maven.its</groupId>
+      <artifactId>pom</artifactId>
+      <version>0.3-SNAPSHOT</version>
+      <type>pom</type>
+    </dependency>
   </dependencies>
 
   <repositories>

Modified: maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/minvoker-70-1.0-20081020.164906-1.pom
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/minvoker-70-1.0-20081020.164906-1.pom?rev=747168&r1=747167&r2=747168&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/minvoker-70-1.0-20081020.164906-1.pom
(original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/minvoker-70-1.0-20081020.164906-1.pom
Mon Feb 23 22:29:07 2009
@@ -1,6 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.maven.its</groupId>
+    <artifactId>parent-b</artifactId>
+    <version>0.1-SNAPSHOT</version>
+  </parent>
   <groupId>org.apache.maven.its</groupId>
   <artifactId>minvoker-70</artifactId>
   <packaging>jar</packaging>

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-a/0.1-SNAPSHOT/maven-metadata.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-a/0.1-SNAPSHOT/maven-metadata.xml?rev=747168&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-a/0.1-SNAPSHOT/maven-metadata.xml
(added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-a/0.1-SNAPSHOT/maven-metadata.xml
Mon Feb 23 22:29:07 2009
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata>
+  <groupId>org.apache.maven.its</groupId>
+  <artifactId>parent-a</artifactId>
+  <version>0.1-SNAPSHOT</version>
+  <versioning>
+    <snapshot>
+      <timestamp>20081020.164906</timestamp>
+      <buildNumber>1</buildNumber>
+    </snapshot>
+    <lastUpdated>20081020164906</lastUpdated>
+  </versioning>
+</metadata>

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-a/0.1-SNAPSHOT/maven-metadata.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-a/0.1-SNAPSHOT/maven-metadata.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-a/0.1-SNAPSHOT/parent-a-0.1-20081020.164906-1.pom
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-a/0.1-SNAPSHOT/parent-a-0.1-20081020.164906-1.pom?rev=747168&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-a/0.1-SNAPSHOT/parent-a-0.1-20081020.164906-1.pom
(added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-a/0.1-SNAPSHOT/parent-a-0.1-20081020.164906-1.pom
Mon Feb 23 22:29:07 2009
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.its</groupId>
+  <artifactId>parent-a</artifactId>
+  <packaging>pom</packaging>
+  <version>0.1-SNAPSHOT</version>
+</project>

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-b/0.1-SNAPSHOT/maven-metadata.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-b/0.1-SNAPSHOT/maven-metadata.xml?rev=747168&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-b/0.1-SNAPSHOT/maven-metadata.xml
(added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-b/0.1-SNAPSHOT/maven-metadata.xml
Mon Feb 23 22:29:07 2009
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata>
+  <groupId>org.apache.maven.its</groupId>
+  <artifactId>parent-b</artifactId>
+  <version>0.1-SNAPSHOT</version>
+  <versioning>
+    <snapshot>
+      <timestamp>20081020.164906</timestamp>
+      <buildNumber>1</buildNumber>
+    </snapshot>
+    <lastUpdated>20081020164906</lastUpdated>
+  </versioning>
+</metadata>

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-b/0.1-SNAPSHOT/maven-metadata.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-b/0.1-SNAPSHOT/maven-metadata.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-b/0.1-SNAPSHOT/parent-b-0.1-20081020.164906-1.pom
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-b/0.1-SNAPSHOT/parent-b-0.1-20081020.164906-1.pom?rev=747168&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-b/0.1-SNAPSHOT/parent-b-0.1-20081020.164906-1.pom
(added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/parent-b/0.1-SNAPSHOT/parent-b-0.1-20081020.164906-1.pom
Mon Feb 23 22:29:07 2009
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.maven.its</groupId>
+    <artifactId>parent-a</artifactId>
+    <version>0.1-SNAPSHOT</version>
+  </parent>
+  <groupId>org.apache.maven.its</groupId>
+  <artifactId>parent-b</artifactId>
+  <packaging>pom</packaging>
+  <version>0.1-SNAPSHOT</version>
+</project>

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/pom/0.3-SNAPSHOT/maven-metadata.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/pom/0.3-SNAPSHOT/maven-metadata.xml?rev=747168&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/pom/0.3-SNAPSHOT/maven-metadata.xml
(added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/pom/0.3-SNAPSHOT/maven-metadata.xml
Mon Feb 23 22:29:07 2009
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata>
+  <groupId>org.apache.maven.its</groupId>
+  <artifactId>pom</artifactId>
+  <version>0.3-SNAPSHOT</version>
+  <versioning>
+    <snapshot>
+      <timestamp>20081020.164906</timestamp>
+      <buildNumber>1</buildNumber>
+    </snapshot>
+    <lastUpdated>20081020164906</lastUpdated>
+  </versioning>
+</metadata>

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/pom/0.3-SNAPSHOT/maven-metadata.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/pom/0.3-SNAPSHOT/maven-metadata.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/pom/0.3-SNAPSHOT/pom-0.3-20081020.164906-1.pom
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/pom/0.3-SNAPSHOT/pom-0.3-20081020.164906-1.pom?rev=747168&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/pom/0.3-SNAPSHOT/pom-0.3-20081020.164906-1.pom
(added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/repo/org/apache/maven/its/pom/0.3-SNAPSHOT/pom-0.3-20081020.164906-1.pom
Mon Feb 23 22:29:07 2009
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.its</groupId>
+  <artifactId>pom</artifactId>
+  <packaging>pom</packaging>
+  <version>0.3-SNAPSHOT</version>
+</project>

Modified: maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/verify.bsh?rev=747168&r1=747167&r2=747168&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/verify.bsh (original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/staging-dependencies/verify.bsh Mon Feb
23 22:29:07 2009
@@ -17,6 +17,9 @@
             "junit/junit/3.8.2/junit-3.8.2.jar",
             "org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/minvoker-70-1.0-SNAPSHOT.pom",
             "org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/minvoker-70-1.0-SNAPSHOT.jar",
+            "org/apache/maven/its/parent-b/0.1-SNAPSHOT/parent-b-0.1-SNAPSHOT.pom",
+            "org/apache/maven/its/parent-a/0.1-SNAPSHOT/parent-a-0.1-SNAPSHOT.pom",
+            "org/apache/maven/its/pom/0.3-SNAPSHOT/pom-0.3-SNAPSHOT.pom",
       };
     for ( String file : files )
     {
@@ -24,8 +27,7 @@
         System.out.println( "Checking for existence of: " + stagedFile );
         if ( !stagedFile.isFile() )
         {
-            System.out.println( "FAILED!" );
-            return false;
+            throw new IllegalStateException( "Missing: " + stagedFile );
         }
     }
 }

Modified: maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InstallMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InstallMojo.java?rev=747168&r1=747167&r2=747168&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InstallMojo.java
(original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InstallMojo.java
Mon Feb 23 22:29:07 2009
@@ -33,6 +33,8 @@
 import org.apache.maven.artifact.installer.ArtifactInstaller;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Parent;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
@@ -135,9 +137,9 @@
 
         ArtifactRepository testRepository = createTestRepository();
 
-        installProjectArtifacts( project, testRepository );
-        installProjectParents( project, testRepository );
         installProjectDependencies( project, reactorProjects, testRepository );
+        installProjectParents( project, testRepository );
+        installProjectArtifacts( project, testRepository );
     }
 
     /**
@@ -263,6 +265,8 @@
             {
                 if ( parent.getFile() == null )
                 {
+                    installParentPoms( parent.getGroupId(), parent.getArtifactId(), parent.getVersion(),

+                                       testRepository );
                     break;
                 }
                 installProjectPom( parent, testRepository );
@@ -329,7 +333,7 @@
 
         // collect transitive dependencies
         Collection dependencies = new HashSet();
-        for ( Iterator it = mvnProject.getRuntimeArtifacts().iterator(); it.hasNext(); )
+        for ( Iterator it = mvnProject.getArtifacts().iterator(); it.hasNext(); )
         {
             Artifact artifact = (Artifact) it.next();
             String id = ArtifactUtils.versionlessKey( artifact );
@@ -353,7 +357,7 @@
             }
 
             // install remaining dependencies from local repository
-            for ( Iterator it = mvnProject.getRuntimeArtifacts().iterator(); it.hasNext();
)
+            for ( Iterator it = mvnProject.getArtifacts().iterator(); it.hasNext(); )
             {
                 Artifact artifact = (Artifact) it.next();
                 String id = ArtifactUtils.versionlessKey( artifact );
@@ -373,9 +377,13 @@
                                                         artifact.getBaseVersion(), null,
"pom" );
 
                     File pomFile = new File( localRepository.getBasedir(), localRepository.pathOf(
pomArtifact ) );
-                    if ( pomFile.exists() )
+                    if ( pomFile.isFile() )
                     {
-                        depArtifact.addMetadata( new ProjectArtifactMetadata( depArtifact,
pomFile ) );
+                        if ( !pomFile.equals( artifactFile ) )
+                        {
+                            depArtifact.addMetadata( new ProjectArtifactMetadata( depArtifact,
pomFile ) );
+                        }
+                        installParentPoms( pomFile, testRepository );
                     }
 
                     installArtifact( artifactFile, depArtifact, testRepository );
@@ -388,4 +396,45 @@
         }
     }
 
+    /**
+     * Installs all parent POMs of the specified POM file that are available in the local
repository.
+     * 
+     * @param pomFile The path to the POM file whose parents should be installed, must not
be <code>null</code>.
+     * @param testRepository The local repository to install the POMs to, must not be <code>null</code>.
+     * @throws MojoExecutionException If any (existing) parent POM could not be installed.
+     */
+    private void installParentPoms( File pomFile, ArtifactRepository testRepository )
+        throws MojoExecutionException
+    {
+        Model model = PomUtils.loadPom( pomFile );
+        Parent parent = model.getParent();
+        if ( parent != null )
+        {
+            installParentPoms( parent.getGroupId(), parent.getArtifactId(), parent.getVersion(),
testRepository );
+        }
+    }
+
+    /**
+     * Installs the specified POM and all its parent POMs to the local repository.
+     * 
+     * @param groupId The group id of the POM which should be installed, must not be <code>null</code>.
+     * @param artifactId The artifact id of the POM which should be installed, must not be
<code>null</code>.
+     * @param version The version of the POM which should be installed, must not be <code>null</code>.
+     * @param testRepository The local repository to install the POMs to, must not be <code>null</code>.
+     * @throws MojoExecutionException If any (existing) parent POM could not be installed.
+     */
+    private void installParentPoms( String groupId, String artifactId, String version, ArtifactRepository
testRepository )
+        throws MojoExecutionException
+    {
+        Artifact pomArtifact = artifactFactory.createProjectArtifact( groupId, artifactId,
version );
+
+        File pomFile = new File( localRepository.getBasedir(), localRepository.pathOf( pomArtifact
) );
+        if ( pomFile.isFile() )
+        {
+            // TODO: track which parents were already installed to prevent needless re-installation
+            installArtifact( pomFile, pomArtifact, testRepository );
+            installParentPoms( pomFile, testRepository );
+        }
+    }
+
 }

Modified: maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java?rev=747168&r1=747167&r2=747168&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java
(original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java
Mon Feb 23 22:29:07 2009
@@ -46,7 +46,6 @@
 import java.util.TreeSet;
 
 import org.apache.maven.model.Model;
-import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
@@ -718,22 +717,7 @@
         }
         getLog().debug( "Collecting parent/child projects of " + projectPath );
 
-        Model model;
-
-        Reader reader = null;
-        try
-        {
-            reader = ReaderFactory.newXmlReader( pomFile );
-            model = new MavenXpp3Reader().read( reader );
-        }
-        catch ( Exception e )
-        {
-            throw new MojoExecutionException( "Failed to parse POM: " + pomFile, e );
-        }
-        finally
-        {
-            IOUtil.close( reader );
-        }
+        Model model = PomUtils.loadPom( pomFile );
 
         try
         {

Added: maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/PomUtils.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/PomUtils.java?rev=747168&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/PomUtils.java
(added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/PomUtils.java
Mon Feb 23 22:29:07 2009
@@ -0,0 +1,71 @@
+package org.apache.maven.plugin.invoker;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Reader;
+
+import org.apache.maven.model.Model;
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.ReaderFactory;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+/**
+ * Provides utility methods for POM processing.
+ * 
+ * @author Benjamin Bentmann
+ */
+class PomUtils
+{
+
+    /**
+     * Loads the (raw) model from the specified POM file.
+     * 
+     * @param pomFile The path to the POM file to load, must not be <code>null</code>.
+     * @return The raw model, never <code>null</code>.
+     * @throws MojoExecutionException If the POM file could not be loaded.
+     */
+    public static Model loadPom( File pomFile )
+        throws MojoExecutionException
+    {
+        Reader reader = null;
+        try
+        {
+            reader = ReaderFactory.newXmlReader( pomFile );
+            return new MavenXpp3Reader().read( reader, false );
+        }
+        catch ( XmlPullParserException e )
+        {
+            throw new MojoExecutionException( "Failed to parse POM: " + pomFile, e );
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Failed to read POM: " + pomFile, e );
+        }
+        finally
+        {
+            IOUtil.close( reader );
+        }
+    }
+
+}

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/PomUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/PomUtils.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



Mime
View raw message