maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r754735 - in /maven/plugins/trunk/maven-deploy-plugin/src: main/java/org/apache/maven/plugin/deploy/ test/java/org/apache/maven/plugin/deploy/ test/java/org/apache/maven/plugin/deploy/stubs/
Date Sun, 15 Mar 2009 19:59:59 GMT
Author: bentmann
Date: Sun Mar 15 19:59:58 2009
New Revision: 754735

URL: http://svn.apache.org/viewvc?rev=754735&view=rev
Log:
o Polished code

Modified:
    maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java
    maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java
    maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/DeployMojoTest.java
    maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactDeployerStub.java

Modified: maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java?rev=754735&r1=754734&r2=754735&view=diff
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java
(original)
+++ maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java
Sun Mar 15 19:59:58 2009
@@ -248,7 +248,7 @@
     /**
      * Process the supplied pomFile to get groupId, artifactId, version, and packaging
      *
-     * @throws NullPointerException if model is <code>null</code>
+     * @param model The POM to extract missing artifact coordinates from, must not be <code>null</code>.
      */
     private void processModel( Model model )
     {
@@ -256,16 +256,13 @@
 
         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();
         }
@@ -277,46 +274,39 @@
                 this.version = parent.getVersion();
             }
         }
-        if ( this.packaging == null && model.getPackaging() != null )
+        if ( this.packaging == null )
         {
             this.packaging = model.getPackaging();
         }
     }
 
     /**
-     * Extract the Model from the specified file.
-     *
-     * @param pomFile
-     * @return
-     * @throws MojoExecutionException if the file doesn't exist of cannot be read.
+     * Extract the model from the specified POM file.
+     * 
+     * @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 file doesn't exist of cannot be read.
      */
     protected Model readModel( File pomFile )
         throws MojoExecutionException
     {
-
-        if ( !pomFile.exists() )
-        {
-            throw new MojoExecutionException( "Specified pomFile does not exist" );
-        }
-
         Reader reader = null;
         try
         {
             reader = ReaderFactory.newXmlReader( pomFile );
-            MavenXpp3Reader modelReader = new MavenXpp3Reader();
-            return modelReader.read( reader );
+            return new MavenXpp3Reader().read( reader );
         }
         catch ( FileNotFoundException e )
         {
-            throw new MojoExecutionException( "Error reading specified POM file: " + e.getMessage(),
e );
+            throw new MojoExecutionException( "POM not found " + pomFile, e );
         }
         catch ( IOException e )
         {
-            throw new MojoExecutionException( "Error reading specified POM file: " + e.getMessage(),
e );
+            throw new MojoExecutionException( "Error reading POM " + pomFile, e );
         }
         catch ( XmlPullParserException e )
         {
-            throw new MojoExecutionException( "Error reading specified POM file: " + e.getMessage(),
e );
+            throw new MojoExecutionException( "Error parsing POM " + pomFile, e );
         }
         finally
         {

Modified: maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java?rev=754735&r1=754734&r2=754735&view=diff
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java
(original)
+++ maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java
Sun Mar 15 19:59:58 2009
@@ -25,9 +25,7 @@
 import java.util.Iterator;
 
 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.Model;
-import org.codehaus.plexus.util.FileUtils;
 
 /**
  * @author <a href="mailto:aramirez@apache.org">Allan Ramirez</a>
@@ -39,8 +37,6 @@
 
     private List fileList;
 
-    private File localRepo;
-
     private File remoteRepo;
 
     public void setUp()

Modified: maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/DeployMojoTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/DeployMojoTest.java?rev=754735&r1=754734&r2=754735&view=diff
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/DeployMojoTest.java
(original)
+++ maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/DeployMojoTest.java
Sun Mar 15 19:59:58 2009
@@ -33,7 +33,6 @@
 import org.apache.maven.plugin.deploy.stubs.ArtifactDeployerStub;
 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
-import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.codehaus.plexus.util.FileUtils;
 
 /**
@@ -103,8 +102,6 @@
 
         assertTrue( file.exists() );
 
-        ArtifactRepository loc = ( ArtifactRepository ) getVariableValueFromObject( mojo,
"localRepository" );
-
         artifact = ( DeployArtifactStub ) getVariableValueFromObject( mojo, "artifact" );
 
         String packaging = ( String ) getVariableValueFromObject( mojo, "packaging" );
@@ -207,8 +204,6 @@
 
         assertTrue( file.exists() );
 
-        ArtifactRepository loc = (ArtifactRepository) getVariableValueFromObject( mojo, "localRepository"
);
-
         artifact = (DeployArtifactStub) getVariableValueFromObject( mojo, "artifact" );
 
         String packaging = (String) getVariableValueFromObject( mojo, "packaging" );

Modified: maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactDeployerStub.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactDeployerStub.java?rev=754735&r1=754734&r2=754735&view=diff
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactDeployerStub.java
(original)
+++ maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactDeployerStub.java
Sun Mar 15 19:59:58 2009
@@ -20,25 +20,15 @@
  */
 
 import java.io.File;
-import java.io.IOException;
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.deployer.ArtifactDeployer;
 import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
-import org.apache.maven.artifact.manager.WagonManager;
 import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
-import org.apache.maven.artifact.transform.ArtifactTransformationManager;
-import org.codehaus.plexus.util.FileUtils;
 
 public class ArtifactDeployerStub
     implements ArtifactDeployer
 {
-    private WagonManager wagonManager;
-
-    private ArtifactTransformationManager transformationManager;
-
-    private RepositoryMetadataManager repositoryMetadataManager;
 
     public void deploy( String basedir, String finalName, Artifact artifact, ArtifactRepository
deploymentRepository,
                         ArtifactRepository localRepository )
@@ -53,6 +43,6 @@
                         ArtifactRepository localRepository )
         throws ArtifactDeploymentException
     {
-
+        // does nothing
     }
 }



Mime
View raw message