You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2009/01/05 21:58:05 UTC

svn commit: r731716 - in /maven/plugins/trunk/maven-install-plugin/src: it/generate-pom-auto-1/ it/generate-pom-auto-2/ main/java/org/apache/maven/plugin/install/

Author: bentmann
Date: Mon Jan  5 12:58:05 2009
New Revision: 731716

URL: http://svn.apache.org/viewvc?rev=731716&view=rev
Log:
[MINSTALL-57] Default generatePom to true

Added:
    maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/
    maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/invoker.properties   (with props)
    maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/pom.xml   (with props)
    maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/setup.bsh   (with props)
    maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/test.jar   (with props)
    maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/test.properties   (with props)
    maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/verify.bsh   (with props)
    maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/
    maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/invoker.properties   (with props)
    maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/pom.xml   (with props)
    maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/setup.bsh   (with props)
    maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/test.jar   (with props)
    maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/test.properties   (with props)
    maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/verify.bsh   (with props)
Modified:
    maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallFileMojo.java

Added: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/invoker.properties?rev=731716&view=auto
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/invoker.properties (added)
+++ maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/invoker.properties Mon Jan  5 12:58:05 2009
@@ -0,0 +1 @@
+invoker.goals = install:install-file

Propchange: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/invoker.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/invoker.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/pom.xml?rev=731716&view=auto
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/pom.xml (added)
+++ maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/pom.xml Mon Jan  5 12:58:05 2009
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.install.gpa1</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0</version>
+  <packaging>jar</packaging>
+
+  <description>
+    Tests that by default a POM is generated for the installed file if no POM exists already in the local repo.
+  </description>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-install-plugin</artifactId>
+        <version>@project.version@</version>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Propchange: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/setup.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/setup.bsh?rev=731716&view=auto
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/setup.bsh (added)
+++ maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/setup.bsh Mon Jan  5 12:58:05 2009
@@ -0,0 +1,10 @@
+import java.io.*;
+import java.util.*;
+
+import org.codehaus.plexus.util.*;
+
+File file = new File( localRepositoryPath, "org/apache/maven/its/install/gpa1" );
+System.out.println( "Deleting " + file );
+FileUtils.deleteDirectory( file );
+
+return true;

Propchange: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/setup.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/setup.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/test.jar
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/test.jar?rev=731716&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/test.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/test.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/test.properties?rev=731716&view=auto
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/test.properties (added)
+++ maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/test.properties Mon Jan  5 12:58:05 2009
@@ -0,0 +1,6 @@
+file = test.jar
+groupId = org.apache.maven.its.install.gpa1
+artifactId = test
+version = 0.1
+packaging = jar
+createChecksum = true

Propchange: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/test.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/test.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/verify.bsh?rev=731716&view=auto
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/verify.bsh (added)
+++ maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/verify.bsh Mon Jan  5 12:58:05 2009
@@ -0,0 +1,34 @@
+import java.io.*;
+import java.util.*;
+
+import org.apache.maven.plugin.install.*;
+
+String[] paths =
+{
+    "org/apache/maven/its/install/gpa1/test/maven-metadata-local.xml",
+    "org/apache/maven/its/install/gpa1/test/maven-metadata-local.xml.md5",
+    "org/apache/maven/its/install/gpa1/test/maven-metadata-local.xml.sha1",
+    "org/apache/maven/its/install/gpa1/test/0.1/test-0.1.jar",
+    "org/apache/maven/its/install/gpa1/test/0.1/test-0.1.jar.md5",
+    "org/apache/maven/its/install/gpa1/test/0.1/test-0.1.jar.sha1",
+    "org/apache/maven/its/install/gpa1/test/0.1/test-0.1.pom",
+    "org/apache/maven/its/install/gpa1/test/0.1/test-0.1.pom.md5",
+    "org/apache/maven/its/install/gpa1/test/0.1/test-0.1.pom.sha1",
+};
+
+for ( String path : paths )
+{
+    File file = new File( localRepositoryPath, path );
+    System.out.println( "Checking for existence of " + file );
+    if ( !file.isFile() )
+    {
+        throw new FileNotFoundException( "Missing: " + file.getAbsolutePath() );
+    }
+    if ( file.getName().endsWith( ".md5" ) || file.getName().endsWith( ".sha1" ) )
+    {
+        System.out.println( "Verifying " + file );
+        Utils.verifyChecksum( file );
+    }
+}
+
+return true;

Propchange: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/verify.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-1/verify.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/invoker.properties?rev=731716&view=auto
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/invoker.properties (added)
+++ maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/invoker.properties Mon Jan  5 12:58:05 2009
@@ -0,0 +1 @@
+invoker.goals = install:install-file

Propchange: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/invoker.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/invoker.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/pom.xml?rev=731716&view=auto
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/pom.xml (added)
+++ maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/pom.xml Mon Jan  5 12:58:05 2009
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.install.gpa2</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0</version>
+  <packaging>jar</packaging>
+
+  <description>
+    Tests that by default no POM is generated for the installed file if already a POM exists in the local repo.
+  </description>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-install-plugin</artifactId>
+        <version>@project.version@</version>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Propchange: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/setup.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/setup.bsh?rev=731716&view=auto
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/setup.bsh (added)
+++ maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/setup.bsh Mon Jan  5 12:58:05 2009
@@ -0,0 +1,15 @@
+import java.io.*;
+import java.util.*;
+
+import org.codehaus.plexus.util.*;
+
+File groupDir = new File( localRepositoryPath, "org/apache/maven/its/install/gpa2" );
+System.out.println( "Deleting " + groupDir );
+FileUtils.deleteDirectory( groupDir );
+
+File pomFile = new File( localRepositoryPath, "org/apache/maven/its/install/gpa2/test/0.1/test-0.1.pom" );
+System.out.println( "Writing " + pomFile );
+pomFile.getParentFile().mkdirs();
+FileUtils.fileWrite( pomFile.getPath(), "UTF-8", "test" );
+
+return true;

Propchange: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/setup.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/setup.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/test.jar
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/test.jar?rev=731716&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/test.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/test.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/test.properties?rev=731716&view=auto
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/test.properties (added)
+++ maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/test.properties Mon Jan  5 12:58:05 2009
@@ -0,0 +1,5 @@
+file = test.jar
+groupId = org.apache.maven.its.install.gpa2
+artifactId = test
+version = 0.1
+packaging = jar

Propchange: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/test.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/test.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/verify.bsh?rev=731716&view=auto
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/verify.bsh (added)
+++ maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/verify.bsh Mon Jan  5 12:58:05 2009
@@ -0,0 +1,29 @@
+import java.io.*;
+import java.util.*;
+
+String[] paths =
+{
+    "org/apache/maven/its/install/gpa2/test/maven-metadata-local.xml",
+    "org/apache/maven/its/install/gpa2/test/0.1/test-0.1.jar",
+    "org/apache/maven/its/install/gpa2/test/0.1/test-0.1.pom",
+};
+
+for ( String path : paths )
+{
+    File file = new File( localRepositoryPath, path );
+    System.out.println( "Checking for existence of " + file );
+    if ( !file.isFile() )
+    {
+        throw new FileNotFoundException( "Missing: " + file.getAbsolutePath() );
+    }
+    if ( path.endsWith( ".pom" ) )
+    {
+        System.out.println( "Checking for original state of " + file );
+        if ( file.length() != "test".length() )
+        {
+            throw new Exception( "Overwritten: " + file.getAbsolutePath() );
+        }
+    }
+}
+
+return true;

Propchange: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/verify.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-install-plugin/src/it/generate-pom-auto-2/verify.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallFileMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallFileMojo.java?rev=731716&r1=731715&r2=731716&view=diff
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallFileMojo.java (original)
+++ maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallFileMojo.java Mon Jan  5 12:58:05 2009
@@ -57,69 +57,69 @@
 public class InstallFileMojo
     extends AbstractInstallMojo
 {
+
     /**
      * GroupId of the artifact to be installed. Retrieved from POM file if specified.
-     *
+     * 
      * @parameter expression="${groupId}"
      */
     protected String groupId;
 
     /**
      * ArtifactId of the artifact to be installed. Retrieved from POM file if specified.
-     *
+     * 
      * @parameter expression="${artifactId}"
      */
     protected String artifactId;
 
     /**
      * Version of the artifact to be installed. Retrieved from POM file if specified
-     *
+     * 
      * @parameter expression="${version}"
      */
     protected String version;
 
     /**
      * Packaging type of the artifact to be installed. Retrieved from POM file if specified
-     *
+     * 
      * @parameter expression="${packaging}"
      */
     protected String packaging;
 
     /**
-     * Classifier type of the artifact to be installed.  For example, "sources" or "javadoc".
-     * Defaults to none which means this is the project's main jar.
-     *
+     * Classifier type of the artifact to be installed. For example, "sources" or "javadoc". Defaults to none which
+     * means this is the project's main JAR.
+     * 
      * @parameter expression="${classifier}"
      */
     protected String classifier;
 
     /**
-     * The file to be deployed
-     *
+     * The file to be installed to the local repository.
+     * 
      * @parameter expression="${file}"
      * @required
      */
     private File file;
 
     /**
-     * Location of an existing POM file to be deployed alongside the main
-     * artifact, given by the ${file} parameter.
-     *
+     * Location of an existing POM file to be installed alongside the main artifact, given by the {@link #file}
+     * parameter.
+     * 
      * @parameter expression="${pomFile}"
      */
     private File pomFile;
 
     /**
-     * Install a POM for this artifact.  Will generate a default POM if none is
-     * supplied with the pomFile argument.
-     *
-     * @parameter expression="${generatePom}" default-value="false"
+     * Generate a minimal POM for the artifact if none is supplied via the parameter {@link #pomFile}. Defaults to
+     * <code>true</code> if there is no existing POM in the local repository yet.
+     * 
+     * @parameter expression="${generatePom}"
      */
-    private boolean generatePom;
+    private Boolean generatePom;
 
     /**
-     * The type of remote repository layout to deploy to. Try <i>legacy</i> for 
-     * a Maven 1.x-style repository layout.
+     * The type of remote repository layout to install to. Try <i>legacy</i> for a Maven 1.x-style repository layout.
      * 
      * @parameter expression="${repositoryLayout}" default-value="default"
      * @required
@@ -127,23 +127,23 @@
     private String repositoryLayout;
 
     /**
-     * Map that contains the layouts
-     *
+     * Map that contains the layouts.
+     * 
      * @component role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
      */
     private Map repositoryLayouts;
 
     /**
-     * The path for a specific local repository directory. It will wrap into an <code>ArtifactRepository</code>
-     * with <code>localRepoId</code> as <code>id</code> and with default <code>repositoryLayout</code>
-     *
+     * The path for a specific local repository directory. It will wrap into an <code>ArtifactRepository</code> with
+     * <code>localRepoId</code> as <code>id</code> and with default <code>repositoryLayout</code>.
+     * 
      * @parameter expression="${localRepositoryPath}"
      */
     private File localRepositoryPath;
 
     /**
-     * The <code>id</code> for the <code>localRepo</code>
-     *
+     * The <code>id</code> for the <code>localRepo</code>.
+     * 
      * @parameter expression="${localRepositoryId}"
      */
     private String localRepositoryId;
@@ -161,13 +161,11 @@
         {
             try
             {
-                ArtifactRepositoryLayout layout;
-
-                layout = ( ArtifactRepositoryLayout ) repositoryLayouts.get( repositoryLayout );
+                ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) repositoryLayouts.get( repositoryLayout );
+                getLog().debug( "Layout: " + layout.getClass() );
 
-                getLog().info("Layout: " + layout.getClass());
-                localRepository = new DefaultArtifactRepository( localRepositoryId, localRepositoryPath.toURL()
-                    .toString(), layout );
+                localRepository =
+                    new DefaultArtifactRepository( localRepositoryId, localRepositoryPath.toURL().toString(), layout );
             }
             catch ( MalformedURLException e )
             {
@@ -175,22 +173,9 @@
             }
         }
 
-        ArtifactMetadata metadata = null;
-
-        Artifact pomArtifact = null;
-
         if ( pomFile != null )
         {
-            if ( pomFile.isFile() )
-            {
-                processModel( readPom( pomFile ) );
-
-                pomArtifact = artifactFactory.createArtifact( groupId, artifactId, version, null, "pom" );
-            }
-            else
-            {
-                getLog().warn( "Ignored non-existent POM file " + pomFile );
-            }
+            processModel( readModel( pomFile ) );
         }
 
         if ( StringUtils.isEmpty( groupId ) )
@@ -213,102 +198,81 @@
         Artifact artifact =
             artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, packaging, classifier );
 
+        if ( file.equals( getLocalRepoFile( artifact ) ) )
+        {
+            throw new MojoFailureException( "Cannot install artifact. "
+                + "Artifact is already in the local repository.\n\nFile in question is: " + file + "\n" );
+        }
+
         File generatedPomFile = null;
 
-        // TODO: check if it exists first, and default to true if not
-        if ( generatePom )
+        if ( !"pom".equals( packaging ) )
         {
-            Writer fw = null;
-            try
+            if ( pomFile != null )
             {
-                generatedPomFile = File.createTempFile( "mvninstall", ".pom" );
-                generatedPomFile.deleteOnExit();
-
-                Model model = new Model();
-                model.setModelVersion( "4.0.0" );
-                model.setGroupId( groupId );
-                model.setArtifactId( artifactId );
-                model.setVersion( version );
-                model.setPackaging( packaging );
-                model.setDescription( "POM was created from install:install-file" );
-
-                fw = WriterFactory.newXmlWriter( generatedPomFile );
-                new MavenXpp3Writer().write( fw, model );
-                metadata = new ProjectArtifactMetadata( artifact, generatedPomFile );
-                artifact.addMetadata( metadata );
+                ArtifactMetadata pomMetadata = new ProjectArtifactMetadata( artifact, pomFile );
+                artifact.addMetadata( pomMetadata );
             }
-            catch ( IOException e )
-            {
-                throw new MojoExecutionException( "Error writing temporary pom file: " + e.getMessage(), e );
-            }
-            finally
+            else
             {
-                IOUtil.close( fw );
+                generatedPomFile = generatePomFile();
+                ArtifactMetadata pomMetadata = new ProjectArtifactMetadata( artifact, generatedPomFile );
+                if ( Boolean.TRUE.equals( generatePom )
+                    || ( generatePom == null && !getLocalRepoFile( pomMetadata ).exists() ) )
+                {
+                    artifact.addMetadata( pomMetadata );
+                }
             }
         }
 
-        // TODO: validate
         // TODO: maybe not strictly correct, while we should enforce that packaging has a type handler of the same id,
         // we don't
         try
         {
-            String localPath = localRepository.pathOf( artifact );
-
-            File destination = new File( localRepository.getBasedir(), localPath );
-
-            if ( !file.equals( destination ) )
-            {
-                installer.install( file, artifact, localRepository );
-                installChecksums( artifact );
-
-                if ( pomFile != null && pomFile.isFile() )
-                {
-                    installer.install( pomFile, pomArtifact, localRepository );
-                    installChecksums( pomArtifact );
-                }
-            }
-            else
-            {
-                throw new MojoFailureException(
-                    "Cannot install artifact. Artifact is already in the local repository.\n\nFile in question is: " +
-                        file + "\n" );
-            }
+            installer.install( file, artifact, localRepository );
+            installChecksums( artifact );
         }
         catch ( ArtifactInstallationException e )
         {
-            throw new MojoExecutionException(
-                "Error installing artifact '" + artifact.getDependencyConflictId() + "': " + e.getMessage(), e );
+            throw new MojoExecutionException( "Error installing artifact '" + artifact.getDependencyConflictId()
+                + "': " + e.getMessage(), e );
+        }
+        finally
+        {
+            if ( generatedPomFile != null )
+            {
+                generatedPomFile.delete();
+            }
         }
     }
 
     /**
-     * @param aFile
-     * @return the model from a file
-     * @throws MojoExecutionException if any
+     * Parses a POM.
+     * 
+     * @param pomFile The path of the POM file to parse, must not be <code>null</code>.
+     * @return The model from the POM file, never <code>null</code>.
+     * @throws MojoExecutionException If the POM could not be parsed.
      */
-    private Model readPom( File aFile )
+    private Model readModel( File pomFile )
         throws MojoExecutionException
     {
         Reader reader = null;
         try
         {
-            reader = ReaderFactory.newXmlReader( aFile );
-
-            MavenXpp3Reader mavenReader = new MavenXpp3Reader();
-
-            return mavenReader.read( reader );
+            reader = ReaderFactory.newXmlReader( pomFile );
+            return new MavenXpp3Reader().read( reader );
         }
         catch ( FileNotFoundException e )
         {
-            throw new MojoExecutionException( "File not found " + aFile, e );
+            throw new MojoExecutionException( "File not found " + pomFile, e );
         }
         catch ( IOException e )
         {
-            throw new MojoExecutionException( "Error reading pom", e );
+            throw new MojoExecutionException( "Error reading POM " + pomFile, e );
         }
         catch ( XmlPullParserException e )
         {
-            throw new MojoExecutionException( "Error reading pom", e );
+            throw new MojoExecutionException( "Error parsing POM " + pomFile, e );
         }
         finally
         {
@@ -316,43 +280,80 @@
         }
     }
 
+    /**
+     * Populates missing mojo parameters from the specified POM.
+     * 
+     * @param model The POM to extract missing artifact coordinates from, must not be <code>null</code>.
+     */
     private void processModel( Model model )
     {
         Parent parent = model.getParent();
 
         if ( this.groupId == null )
         {
-            if ( parent != null && parent.getGroupId() != null )
+            this.groupId = model.getGroupId();
+            if ( this.groupId == null && parent != null )
             {
                 this.groupId = parent.getGroupId();
             }
-            if ( model.getGroupId() != null )
-            {
-                this.groupId = model.getGroupId();
-            }
         }
-        if ( this.artifactId == null && model.getArtifactId() != null )
+        if ( this.artifactId == null )
         {
             this.artifactId = model.getArtifactId();
         }
         if ( this.version == null )
         {
-            if ( parent != null && parent.getVersion() != null )
+            this.version = model.getVersion();
+            if ( this.version == null && parent != null )
             {
                 this.version = parent.getVersion();
             }
-            if ( model.getVersion() != null )
-            {
-                this.version = model.getVersion();
-            }
         }
-        if ( this.packaging == null && model.getPackaging() != null )
+        if ( this.packaging == null )
         {
             this.packaging = model.getPackaging();
         }
     }
 
     /**
+     * Generates a (temporary) POM file from the plugin configuration. It's the responsibility of the caller to delete
+     * the generated file when no longer needed.
+     * 
+     * @return The path to the generated POM file, never <code>null</code>.
+     * @throws MojoExecutionException If the POM file could not be generated.
+     */
+    private File generatePomFile()
+        throws MojoExecutionException
+    {
+        Model model = new Model();
+        model.setModelVersion( "4.0.0" );
+        model.setGroupId( groupId );
+        model.setArtifactId( artifactId );
+        model.setVersion( version );
+        model.setPackaging( packaging );
+        model.setDescription( "POM was created from install:install-file" );
+
+        Writer writer = null;
+        try
+        {
+            File pomFile = File.createTempFile( "mvninstall", ".pom" );
+
+            writer = WriterFactory.newXmlWriter( pomFile );
+            new MavenXpp3Writer().write( writer, model );
+
+            return pomFile;
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Error writing temporary POM file: " + e.getMessage(), e );
+        }
+        finally
+        {
+            IOUtil.close( writer );
+        }
+    }
+
+    /**
      * @return the localRepositoryId
      */
     public String getLocalRepositoryId()
@@ -383,4 +384,5 @@
     {
         this.localRepositoryPath = theLocalRepositoryPath;
     }
+
 }