o DeployMojo
  Using ProjectDeployer instead of ArtifactDeployer
  which makes code much more simpler and using 
  ProjectDeployerRequest instead of DeployRequest.
o DeployFileMojo
  using ArtifactDeployer.
o Added slf4j-api and slf4j-noop in test scope
  to get running the tests.


git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1761345 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/pom.xml b/pom.xml
index 7effe70..31a8e93 100644
--- a/pom.xml
+++ b/pom.xml
@@ -136,6 +136,19 @@
       <version>1.7</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+      <version>1.7.5</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-nop</artifactId>
+      <version>1.7.5</version>
+      <scope>test</scope>
+    </dependency>
+    
   </dependencies>
 
   <contributors>
diff --git a/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java b/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java
index e54c778..7a78e8b 100644
--- a/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java
+++ b/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java
@@ -19,10 +19,8 @@
  * under the License.
  */
 
-import java.util.Collection;
 import java.util.Map;
 
-import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
@@ -34,8 +32,6 @@
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.shared.artifact.deploy.ArtifactDeployer;
-import org.apache.maven.shared.artifact.deploy.ArtifactDeployerException;
 
 /**
  * @version $Id$
@@ -44,11 +40,6 @@
     extends AbstractMojo
 {
     /**
-     */
-    @Component
-    private ArtifactDeployer deployer;
-
-    /**
      * Component used to create an artifact.
      */
     @Component
@@ -86,16 +77,6 @@
     
     /* Setters and Getters */
 
-    public ArtifactDeployer getDeployer()
-    {
-        return deployer;
-    }
-
-    public void setDeployer( ArtifactDeployer deployer )
-    {
-        this.deployer = deployer;
-    }
-
     void failIfOffline()
         throws MojoFailureException
     {
@@ -128,56 +109,6 @@
         return retryFailedDeploymentCount;
     }
 
-    /**
-     * Deploy an artifact from a particular file.
-     * @param artifacts the artifact definitions
-     * @param deploymentRepository the repository to deploy to
-     * @param localRepository the local repository to install into
-     * @param retryFailedDeploymentCount TODO
-     * 
-     * @throws ArtifactDeployerException if an error occurred deploying the artifact
-     */
-    protected void deploy( Collection<Artifact> artifacts, ArtifactRepository deploymentRepository,
-                           int retryFailedDeploymentCount )
-        throws ArtifactDeployerException
-    {
-
-        // for now retry means redeploy the complete artifacts collection
-        int retryFailedDeploymentCounter = Math.max( 1, Math.min( 10, retryFailedDeploymentCount ) );
-        ArtifactDeployerException exception = null;
-        for ( int count = 0; count < retryFailedDeploymentCounter; count++ )
-        {
-            try
-            {
-                if ( count > 0 )
-                {
-                    getLog().info( "Retrying deployment attempt " + ( count + 1 ) + " of "
-                                       + retryFailedDeploymentCounter );
-                }
-                
-                getDeployer().deploy( session.getProjectBuildingRequest(), deploymentRepository, artifacts );
-                exception = null;
-                break;
-            }
-            catch ( ArtifactDeployerException e )
-            {
-                if ( count + 1 < retryFailedDeploymentCounter )
-                {
-                    getLog().warn( "Encountered issue during deployment: " + e.getLocalizedMessage() );
-                    getLog().debug( e );
-                }
-                if ( exception == null )
-                {
-                    exception = e;
-                }
-            }
-        }
-        if ( exception != null )
-        {
-            throw exception;
-        }
-    }
-
     protected ArtifactRepository createDeploymentArtifactRepository( String id, String url,
                                                                      ArtifactRepositoryLayout layout,
                                                                      boolean uniqueVersion2 )
diff --git a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java
index 5334c11..9afe7ea 100644
--- a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java
+++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java
@@ -61,6 +61,7 @@
 import org.apache.maven.project.ProjectBuildingException;
 import org.apache.maven.project.artifact.ProjectArtifactMetadata;
 import org.apache.maven.shared.artifact.DefaultArtifactCoordinate;
+import org.apache.maven.shared.artifact.deploy.ArtifactDeployer;
 import org.apache.maven.shared.artifact.deploy.ArtifactDeployerException;
 import org.apache.maven.shared.repository.RepositoryManager;
 import org.codehaus.plexus.util.FileUtils;
@@ -79,13 +80,15 @@
 public class DeployFileMojo
     extends AbstractDeployMojo
 {
+    @Component
+    private ArtifactDeployer artifactDeployer;
 
     /**
      * Used for attaching the artifacts to deploy to the project.
      */
     @Component
     private MavenProjectHelper projectHelper;
-    
+
     /**
      * Used for creating the project to which the artifacts to deploy will be attached.
      */
@@ -218,10 +221,10 @@
      */
     @Parameter( property = "files" )
     private String files;
-    
+
     @Component
     private RepositoryManager repoManager;
-    
+
     void initProperties()
         throws MojoExecutionException
     {
@@ -258,16 +261,16 @@
                         try
                         {
                             pomInputStream = jarFile.getInputStream( entry );
-                            
+
                             String base = file.getName();
                             if ( base.indexOf( '.' ) > 0 )
                             {
                                 base = base.substring( 0, base.lastIndexOf( '.' ) );
                             }
                             pomFile = new File( file.getParentFile(), base + ".pom" );
-                            
+
                             pomOutputStream = new FileOutputStream( pomFile );
-                            
+
                             IOUtil.copy( pomInputStream, pomOutputStream );
 
                             pomOutputStream.close();
@@ -494,18 +497,19 @@
 
         try
         {
-            deploy( deployableArtifacts, deploymentRepository, getRetryFailedDeploymentCount() );
+            artifactDeployer.deploy( getSession().getProjectBuildingRequest(), deploymentRepository,
+                                     deployableArtifacts );
         }
         catch ( ArtifactDeployerException e )
         {
             throw new MojoExecutionException( e.getMessage(), e );
         }
     }
-    
+
     /**
-     * Creates a Maven project in-memory from the user-supplied groupId, artifactId and version.
-     * When a classifier is supplied, the packaging must be POM because the project with only have attachments.
-     * This project serves as basis to attach the artifacts to deploy to.
+     * Creates a Maven project in-memory from the user-supplied groupId, artifactId and version. When a classifier is
+     * supplied, the packaging must be POM because the project with only have attachments. This project serves as basis
+     * to attach the artifacts to deploy to.
      * 
      * @return The created Maven project, never <code>null</code>.
      * @throws MojoFailureException When building the project failed.
@@ -513,14 +517,10 @@
     private MavenProject createMavenProject()
         throws MojoFailureException
     {
-        ModelSource modelSource = new StringModelSource( 
-                "<project>"
-              +   "<modelVersion>4.0.0</modelVersion>"
-              +   "<groupId>" + groupId + "</groupId>"
-              +   "<artifactId>" + artifactId + "</artifactId>"
-              +   "<version>" + version + "</version>"
-              +   "<packaging>" + ( classifier == null ? packaging : "pom" ) + "</packaging>"
-              + "</project>" );
+        ModelSource modelSource =
+            new StringModelSource( "<project>" + "<modelVersion>4.0.0</modelVersion>" + "<groupId>" + groupId
+                + "</groupId>" + "<artifactId>" + artifactId + "</artifactId>" + "<version>" + version + "</version>"
+                + "<packaging>" + ( classifier == null ? packaging : "pom" ) + "</packaging>" + "</project>" );
         DefaultProjectBuildingRequest buildingRequest =
             new DefaultProjectBuildingRequest( getSession().getProjectBuildingRequest() );
         buildingRequest.setProcessPlugins( false );
@@ -533,10 +533,10 @@
             throw new MojoFailureException( e.getMessage(), e );
         }
     }
-    
+
     /**
-     * Gets the path of the artifact constructed from the supplied groupId, artifactId, version, classifier
-     * and packaging within the local repository. Note that the returned path need not exist (yet).
+     * Gets the path of the artifact constructed from the supplied groupId, artifactId, version, classifier and
+     * packaging within the local repository. Note that the returned path need not exist (yet).
      * 
      * @return The absolute path to the artifact when installed, never <code>null</code>.
      */
@@ -673,7 +673,7 @@
         ModelBuildingRequest buildingRequest = new DefaultModelBuildingRequest();
 
         DeployModelProblemCollector problemCollector = new DeployModelProblemCollector();
-        
+
         modelValidator.validateEffectiveModel( model, buildingRequest, problemCollector );
 
         if ( problemCollector.getMessageCount() > 0 )
@@ -763,15 +763,16 @@
     {
         this.classifier = classifier;
     }
-    
-    private static class DeployModelProblemCollector implements ModelProblemCollector
+
+    private static class DeployModelProblemCollector
+        implements ModelProblemCollector
     {
         /** */
         private static final String NEWLINE = System.getProperty( "line.separator" );
 
         /** */
         private List<String> messages = new ArrayList<String>();
-        
+
         @Override
         public void add( Severity severity, String message, InputLocation location, Exception cause )
         {
diff --git a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java
index 3c8ee44..e1e6138 100644
--- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java
+++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java
@@ -19,7 +19,27 @@
  * under the License.
  */
 
-import java.io.File;
+import java.io.IOException;
+
+/*
+ * 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.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -27,18 +47,20 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.ArtifactUtils;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.LifecyclePhase;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.artifact.ProjectArtifactMetadata;
-import org.apache.maven.shared.artifact.deploy.ArtifactDeployerException;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.shared.project.NoFileAssignedException;
+import org.apache.maven.shared.project.deploy.ProjectDeployer;
+import org.apache.maven.shared.project.deploy.ProjectDeployerRequest;
 
 /**
  * Deploys an artifact to remote repository.
@@ -60,8 +82,8 @@
      */
     private static final AtomicInteger READYPROJECTSCOUNTER = new AtomicInteger();
 
-    private static final List<DeployRequest> DEPLOYREQUESTS =
-        Collections.synchronizedList( new ArrayList<DeployRequest>() );
+    private static final List<ProjectDeployerRequest> DEPLOYREQUESTS =
+        Collections.synchronizedList( new ArrayList<ProjectDeployerRequest>() );
 
     /**
      */
@@ -124,6 +146,12 @@
     @Parameter( property = "maven.deploy.skip", defaultValue = "false" )
     private boolean skip;
 
+    /**
+     * Component used to deploy project.
+     */
+    @Component
+    private ProjectDeployer projectDeployer;
+
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
@@ -137,17 +165,26 @@
             failIfOffline();
 
             // CHECKSTYLE_OFF: LineLength
-            DeployRequest currentExecutionDeployRequest =
-                new DeployRequest().setProject( project ).setUpdateReleaseInfo( isUpdateReleaseInfo() ).setRetryFailedDeploymentCount( getRetryFailedDeploymentCount() ).setAltReleaseDeploymentRepository( altReleaseDeploymentRepository ).setAltSnapshotDeploymentRepository( altSnapshotDeploymentRepository ).setAltDeploymentRepository( altDeploymentRepository );
+            // @formatter:off
+            ProjectDeployerRequest pdr = new ProjectDeployerRequest()
+                .setProject( project )
+                .setUpdateReleaseInfo( isUpdateReleaseInfo() )
+                .setRetryFailedDeploymentCount( getRetryFailedDeploymentCount() )
+                .setAltReleaseDeploymentRepository( altReleaseDeploymentRepository )
+                .setAltSnapshotDeploymentRepository( altSnapshotDeploymentRepository )
+                .setAltDeploymentRepository( altDeploymentRepository );
+            // @formatter:on
             // CHECKSTYLE_ON: LineLength
 
+            ArtifactRepository repo = getDeploymentRepository( pdr );
+
             if ( !deployAtEnd )
             {
-                deployProject( currentExecutionDeployRequest );
+                deployProject( getSession().getProjectBuildingRequest(), pdr, repo );
             }
             else
             {
-                DEPLOYREQUESTS.add( currentExecutionDeployRequest );
+                DEPLOYREQUESTS.add( pdr );
                 addedDeployRequest = true;
             }
         }
@@ -159,121 +196,46 @@
             {
                 while ( !DEPLOYREQUESTS.isEmpty() )
                 {
-                    deployProject( DEPLOYREQUESTS.remove( 0 ) );
+                    ArtifactRepository repo = getDeploymentRepository( DEPLOYREQUESTS.get( 0 ) );
+
+                    deployProject( getSession().getProjectBuildingRequest(), DEPLOYREQUESTS.remove( 0 ), repo );
                 }
             }
         }
         else if ( addedDeployRequest )
         {
             getLog().info( "Deploying " + project.getGroupId() + ":" + project.getArtifactId() + ":"
-                               + project.getVersion() + " at end" );
+                + project.getVersion() + " at end" );
         }
     }
 
-    private void deployProject( DeployRequest request )
-        throws MojoExecutionException, MojoFailureException
+    private void deployProject( ProjectBuildingRequest pbr, ProjectDeployerRequest pir, ArtifactRepository repo )
+        throws MojoFailureException, MojoExecutionException
     {
-        List<Artifact> deployableArtifacts = new ArrayList<Artifact>();
-        
-        Artifact artifact = request.getProject().getArtifact();
-        String packaging = request.getProject().getPackaging();
-        File pomFile = request.getProject().getFile();
-
-        List<Artifact> attachedArtifacts = request.getProject().getAttachedArtifacts();
-
-        ArtifactRepository repo =
-            getDeploymentRepository( request.getProject(), request.getAltDeploymentRepository(),
-                                     request.getAltReleaseDeploymentRepository(),
-                                     request.getAltSnapshotDeploymentRepository() );
-
-        String protocol = repo.getProtocol();
-
-        if ( protocol.equalsIgnoreCase( "scp" ) )
-        {
-            File sshFile = new File( System.getProperty( "user.home" ), ".ssh" );
-
-            if ( !sshFile.exists() )
-            {
-                sshFile.mkdirs();
-            }
-        }
-
-        // Deploy the POM
-        boolean isPomArtifact = "pom".equals( packaging );
-        if ( !isPomArtifact )
-        {
-            ProjectArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, pomFile );
-            artifact.addMetadata( metadata );
-        }
-        else
-        {
-            artifact.setFile( pomFile );
-        }
-
-        if ( request.isUpdateReleaseInfo() )
-        {
-            artifact.setRelease( true );
-        }
-
-        artifact.setRepository( repo );
-
-        int retryFailedDeploymentCount = request.getRetryFailedDeploymentCount();
-
         try
         {
-            if ( isPomArtifact )
-            {
-                deployableArtifacts.add( artifact );
-            }
-            else
-            {
-                File file = artifact.getFile();
-
-                if ( file != null && file.isFile() )
-                {
-                    deployableArtifacts.add( artifact );
-                }
-                else if ( !attachedArtifacts.isEmpty() )
-                {
-                    throw new MojoExecutionException( "The packaging plugin for this project did not assign "
-                                   + "a main file to the project but it has attachments. Change packaging to 'pom'." );
-                }
-                else
-                {
-                    throw new MojoExecutionException( "The packaging for this project did not assign "
-                        + "a file to the build artifact" );
-                }
-            }
-
-            for ( Artifact attached : attachedArtifacts )
-            {
-                // This is here when AttachedArtifact is used, like m-sources-plugin:2.0.4
-                try
-                {
-                    attached.setRepository( repo );
-                }
-                catch ( UnsupportedOperationException e )
-                {
-                    getLog().warn( attached.getId() + " has been attached with deprecated code, "
-                        + "try to upgrade the responsible plugin" );
-                }
-                
-                deployableArtifacts.add( attached );
-            }
-            
-            deploy( deployableArtifacts, repo, retryFailedDeploymentCount );
+            projectDeployer.deployProject( pbr, pir, repo );
         }
-        catch ( ArtifactDeployerException e )
+        catch ( IOException e )
         {
-            throw new MojoExecutionException( e.getMessage(), e );
+            throw new MojoFailureException( "IOException", e );
         }
+        catch ( NoFileAssignedException e )
+        {
+            throw new MojoExecutionException( "NoFileAssignedException", e );
+        }
+
     }
 
-    ArtifactRepository getDeploymentRepository( MavenProject project, String altDeploymentRepository,
-                                                String altReleaseDeploymentRepository,
-                                                String altSnapshotDeploymentRepository )
+    ArtifactRepository getDeploymentRepository( ProjectDeployerRequest pdr )
+
         throws MojoExecutionException, MojoFailureException
     {
+        MavenProject project = pdr.getProject();
+        String altDeploymentRepository = pdr.getAltDeploymentRepository();
+        String altReleaseDeploymentRepository = pdr.getAltReleaseDeploymentRepository();
+        String altSnapshotDeploymentRepository = pdr.getAltSnapshotDeploymentRepository();
+
         ArtifactRepository repo = null;
 
         String altDeploymentRepo;
@@ -320,9 +282,8 @@
 
         if ( repo == null )
         {
-            String msg =
-                "Deployment failed: repository element was not specified in the POM inside"
-                    + " distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter";
+            String msg = "Deployment failed: repository element was not specified in the POM inside"
+                + " distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter";
 
             throw new MojoExecutionException( msg );
         }
diff --git a/src/main/java/org/apache/maven/plugins/deploy/DeployRequest.java b/src/main/java/org/apache/maven/plugins/deploy/DeployRequest.java
deleted file mode 100644
index cdb99f7..0000000
--- a/src/main/java/org/apache/maven/plugins/deploy/DeployRequest.java
+++ /dev/null
@@ -1,149 +0,0 @@
-package org.apache.maven.plugins.deploy;

-

-/*

- * 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 org.apache.maven.project.MavenProject;

-

-/**

- * 

- * @author Robert Scholte

- * @since 2.8.1

- */

-class DeployRequest

-{

-

-    // From AbstractDeployMojo

-    

-    private boolean updateReleaseInfo;

-    

-    private int retryFailedDeploymentCount;

-    

-    // From DeployMojo

-    

-    private MavenProject project;

-    

-    private String altDeploymentRepository;

-    

-    private String altSnapshotDeploymentRepository;

-    

-    private String altReleaseDeploymentRepository;

-

-    /**

-     * @return the updateReleaseInfo

-     */

-    public boolean isUpdateReleaseInfo()

-    {

-        return updateReleaseInfo;

-    }

-

-    /**

-     * @param updateReleaseInfo the updateReleaseInfo to set

-     */

-    public DeployRequest setUpdateReleaseInfo( boolean updateReleaseInfo )

-    {

-        this.updateReleaseInfo = updateReleaseInfo;

-        return this;

-    }

-

-    /**

-     * @return the retryFailedDeploymentCount

-     */

-    public int getRetryFailedDeploymentCount()

-    {

-        return retryFailedDeploymentCount;

-    }

-

-    /**

-     * @param retryFailedDeploymentCount the retryFailedDeploymentCount to set

-     */

-    public DeployRequest setRetryFailedDeploymentCount( int retryFailedDeploymentCount )

-    {

-        this.retryFailedDeploymentCount = retryFailedDeploymentCount;

-        return this;

-    }

-

-    /**

-     * @return the project

-     */

-    public MavenProject getProject()

-    {

-        return project;

-    }

-

-    /**

-     * @param project the project to set

-     */

-    public DeployRequest setProject( MavenProject project )

-    {

-        this.project = project;

-        return this;

-    }

-

-    /**

-     * @return the altDeploymentRepository

-     */

-    public String getAltDeploymentRepository()

-    {

-        return altDeploymentRepository;

-    }

-

-    /**

-     * @param altDeploymentRepository the altDeploymentRepository to set

-     */

-    public DeployRequest setAltDeploymentRepository( String altDeploymentRepository )

-    {

-        this.altDeploymentRepository = altDeploymentRepository;

-        return this;

-    }

-

-    /**

-     * @return the altSnapshotDeploymentRepository

-     */

-    public String getAltSnapshotDeploymentRepository()

-    {

-        return altSnapshotDeploymentRepository;

-    }

-

-    /**

-     * @param altSnapshotDeploymentRepository the altSnapshotDeploymentRepository to set

-     */

-    public DeployRequest setAltSnapshotDeploymentRepository( String altSnapshotDeploymentRepository )

-    {

-        this.altSnapshotDeploymentRepository = altSnapshotDeploymentRepository;

-        return this;

-    }

-

-    /**

-     * @return the altReleaseDeploymentRepository

-     */

-    public String getAltReleaseDeploymentRepository()

-    {

-        return altReleaseDeploymentRepository;

-    }

-

-    /**

-     * @param altReleaseDeploymentRepository the altReleaseDeploymentRepository to set

-     */

-    public DeployRequest setAltReleaseDeploymentRepository( String altReleaseDeploymentRepository )

-    {

-        this.altReleaseDeploymentRepository = altReleaseDeploymentRepository;

-        return this;

-    }

-}

diff --git a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java
index 97f2d3f..17e63c1 100644
--- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java
@@ -41,6 +41,7 @@
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.ProjectBuildingRequest;
 import org.apache.maven.repository.internal.MavenRepositorySystemSession;
+import org.apache.maven.shared.project.deploy.ProjectDeployerRequest;
 import org.codehaus.plexus.util.FileUtils;
 import org.junit.Ignore;
 import org.mockito.InjectMocks;
@@ -405,6 +406,13 @@
                                  "target/test-classes/unit/basic-deploy-test/plugin-config.xml" );
         
         DeployMojo mojo = ( DeployMojo ) lookupMojo( "deploy", testPom );
+
+        MockitoAnnotations.initMocks( this );
+
+        ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class );
+        when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest );
+        
+        setVariableValueToObject( mojo, "session", session );
         
         assertNotNull( mojo );
         
@@ -598,9 +606,12 @@
 
         project.setVersion( "1.0-SNAPSHOT" );
 
+        ProjectDeployerRequest pdr =
+                        new ProjectDeployerRequest()
+                            .setProject( project )
+                            .setAltDeploymentRepository( "altSnapshotDeploymentRepository::default::http://localhost" );
         assertEquals( repository,
-                      mojo.getDeploymentRepository( project, null, null,
-                                                    "altSnapshotDeploymentRepository::default::http://localhost" ) );
+                      mojo.getDeploymentRepository( pdr ));
     }
 
     public void testAltReleaseDeploymentRepository()
@@ -618,9 +629,13 @@
 
         project.setVersion( "1.0" );
 
+        ProjectDeployerRequest pdr =
+                        new ProjectDeployerRequest()
+                            .setProject( project )
+                            .setAltReleaseDeploymentRepository( "altReleaseDeploymentRepository::default::http://localhost" );
+
         assertEquals( repository,
-                      mojo.getDeploymentRepository( project, null,
-                                                    "altReleaseDeploymentRepository::default::http://localhost", null ) );
+                      mojo.getDeploymentRepository( pdr ));
     }
     
     private void addFileToList( File file, List<String> fileList )
diff --git a/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactDeployerStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactDeployerStub.java
index 518e36b..9bdf48a 100644
--- a/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactDeployerStub.java
+++ b/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactDeployerStub.java
@@ -39,7 +39,7 @@
     }
 
     @Override
-    public void deploy( ProjectBuildingRequest arg0, ArtifactRepository arg1, Collection<Artifact> arg2 )
+    public void deploy( ProjectBuildingRequest arg0, ArtifactRepository arg1, Collection<Artifact> arg2)
         throws ArtifactDeployerException
     {
         // does nothing