Author: bentmann
Date: Sun Dec 20 17:30:52 2009
New Revision: 892616

URL: http://svn.apache.org/viewvc?rev=892616&view=rev
Log:
[MDEPLOY-89] Skip won't work if distribution management is not specified

Added:
    maven/plugins/trunk/maven-deploy-plugin/src/it/skip/
    maven/plugins/trunk/maven-deploy-plugin/src/it/skip/pom.xml   (with props)
    maven/plugins/trunk/maven-deploy-plugin/src/it/skip/setup.bsh   (with props)
    
maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/stubs/MavenProjectStub.java
   (with props)
Modified:
    
maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java
    
maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.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/resources/unit/basic-deploy-pom/plugin-config.xml
    
maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/basic-deploy-scp/plugin-config.xml
    
maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/basic-deploy-test/plugin-config.xml
    
maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/basic-deploy-with-attached-artifacts/plugin-config.xml

Added: maven/plugins/trunk/maven-deploy-plugin/src/it/skip/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/skip/pom.xml?rev=892616&view=auto
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/it/skip/pom.xml (added)
+++ maven/plugins/trunk/maven-deploy-plugin/src/it/skip/pom.xml Sun Dec 20 
17:30:52 2009
@@ -0,0 +1,78 @@
+<?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.deploy.skip</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0</version>
+  <packaging>pom</packaging>
+
+  <description>
+    Tests the skipping of deployment upon user request via configuration.
+  </description>
+
+  <!-- NOTE: This must pass although the POM does not define 
<distributionManagement> (MDEPLOY-89) -->
+
+  <properties>
+    <maven.test.skip>true</maven.test.skip>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.0.2</version>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-deploy-plugin</artifactId>
+        <version>@project.version@</version>
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-install-plugin</artifactId>
+        <version>2.2</version>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-resources-plugin</artifactId>
+        <version>2.2</version>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.3.1</version>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-site-plugin</artifactId>
+        <version>2.0-beta-5</version>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Propchange: maven/plugins/trunk/maven-deploy-plugin/src/it/skip/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-deploy-plugin/src/it/skip/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-deploy-plugin/src/it/skip/setup.bsh
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/skip/setup.bsh?rev=892616&view=auto
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/it/skip/setup.bsh (added)
+++ maven/plugins/trunk/maven-deploy-plugin/src/it/skip/setup.bsh Sun Dec 20 
17:30:52 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/deploy/skip" 
);
+System.out.println( "Deleting " + file );
+FileUtils.deleteDirectory( file );
+
+return true;

Propchange: maven/plugins/trunk/maven-deploy-plugin/src/it/skip/setup.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-deploy-plugin/src/it/skip/setup.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: 
maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java?rev=892616&r1=892615&r2=892616&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java
 Sun Dec 20 17:30:52 2009
@@ -44,7 +44,7 @@
     protected ArtifactFactory artifactFactory;
 
     /**
-     * @parameter expression="${localRepository}"
+     * @parameter default-value="${localRepository}"
      * @required
      * @readonly
      */

Modified: 
maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java?rev=892616&r1=892615&r2=892616&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java
 Sun Dec 20 17:30:52 2009
@@ -27,6 +27,7 @@
 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.artifact.ProjectArtifactMetadata;
 import org.codehaus.plexus.PlexusConstants;
 import org.codehaus.plexus.PlexusContainer;
@@ -58,6 +59,13 @@
     private static final Pattern ALT_REPO_SYNTAX_PATTERN = Pattern.compile( 
"(.+)::(.+)::(.+)" );
 
     /**
+     * @parameter default-value="${project}"
+     * @required
+     * @readonly
+     */
+    private MavenProject project;
+
+    /**
      * @parameter default-value="${project.artifact}"
      * @required
      * @readonly
@@ -79,12 +87,6 @@
     private File pomFile;
 
     /**
-     * @parameter 
expression="${project.distributionManagementArtifactRepository}"
-     * @readonly
-     */
-    private ArtifactRepository deploymentRepository;
-
-    /**
      * Specifies an alternative repository to which the project artifacts 
should be deployed ( other
      * than those specified in &lt;distributionManagement&gt; ).
      * <br/>
@@ -204,14 +206,6 @@
     private ArtifactRepository getDeploymentRepository()
         throws MojoExecutionException, MojoFailureException
     {
-        if ( deploymentRepository == null && altDeploymentRepository == null )
-        {
-            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 );
-        }
-
         ArtifactRepository repo = null;
 
         if ( altDeploymentRepository != null )
@@ -247,7 +241,15 @@
         
         if ( repo == null )
         {
-            repo = deploymentRepository;
+            repo = project.getDistributionManagementArtifactRepository();
+        }
+
+        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";
+
+            throw new MojoExecutionException( msg );
         }
 
         return repo;

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=892616&r1=892615&r2=892616&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 Dec 20 17:30:52 2009
@@ -33,6 +33,7 @@
 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.project.MavenProject;
 import org.codehaus.plexus.util.FileUtils;
 
 /**
@@ -64,16 +65,27 @@
         
         localRepo = new File( LOCAL_REPO );
 
-        if( localRepo.exists() )
+        if ( localRepo.exists() )
         {
             FileUtils.deleteDirectory( localRepo );
         }
 
-        if( remoteRepo.exists() )
+        if ( remoteRepo.exists() )
         {
             FileUtils.deleteDirectory( remoteRepo );
         }
     }
+
+    public void tearDown()
+        throws Exception
+    {
+        super.tearDown();
+        
+        if( remoteRepo.exists() )
+        {
+            //FileUtils.deleteDirectory( remoteRepo );
+        }
+    }
     
     public void testDeployTestEnvironment()
         throws Exception
@@ -110,7 +122,7 @@
         
         artifact.setFile( file );        
         
-        ArtifactRepositoryStub repo = ( ArtifactRepositoryStub ) 
getVariableValueFromObject( mojo, "deploymentRepository" );
+        ArtifactRepositoryStub repo = getRepoStub( mojo );
 
         assertNotNull( repo );
         
@@ -212,7 +224,7 @@
 
         artifact.setFile( file );
 
-        ArtifactRepositoryStub repo = (ArtifactRepositoryStub) 
getVariableValueFromObject( mojo, "deploymentRepository" );
+        ArtifactRepositoryStub repo = getRepoStub( mojo );
 
         assertNotNull( repo );
 
@@ -258,7 +270,7 @@
         
         artifact.setArtifactHandlerExtension( packaging );
         
-        ArtifactRepositoryStub repo = ( ArtifactRepositoryStub ) 
getVariableValueFromObject( mojo, "deploymentRepository" ); 
+        ArtifactRepositoryStub repo = getRepoStub( mojo );
         
         repo.setAppendToUrl( "basic-deploy-pom" );
         
@@ -315,7 +327,7 @@
         
         artifact.setFile( testPom );
         
-        ArtifactRepositoryStub repo = ( ArtifactRepositoryStub ) 
getVariableValueFromObject( mojo, "deploymentRepository" ); 
+        ArtifactRepositoryStub repo = getRepoStub( mojo );
         
         repo.setAppendToUrl( "basic-deploy-updateReleaseParam" );        
         
@@ -373,7 +385,7 @@
         
         List attachedArtifacts = ( ArrayList ) getVariableValueFromObject( 
mojo, "attachedArtifacts" );
 
-        ArtifactRepositoryStub repo = ( ArtifactRepositoryStub ) 
getVariableValueFromObject( mojo, "deploymentRepository" ); 
+        ArtifactRepositoryStub repo = getRepoStub( mojo );
         
         repo.setAppendToUrl( "basic-deploy-with-attached-artifacts" );         
 
         
@@ -543,15 +555,12 @@
         }
         return expectedFiles.size();
     }    
-    
-    public void tearDown()
+
+    private ArtifactRepositoryStub getRepoStub( Object mojo )
         throws Exception
     {
-        super.tearDown();
-        
-        if( remoteRepo.exists() )
-        {
-            //FileUtils.deleteDirectory( remoteRepo );
-        }
+        MavenProject project = (MavenProject) getVariableValueFromObject( 
mojo, "project" );
+        return (ArtifactRepositoryStub) 
project.getDistributionManagementArtifactRepository();
     }
+
 }

Added: 
maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/stubs/MavenProjectStub.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/stubs/MavenProjectStub.java?rev=892616&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/stubs/MavenProjectStub.java
 (added)
+++ 
maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/stubs/MavenProjectStub.java
 Sun Dec 20 17:30:52 2009
@@ -0,0 +1,35 @@
+package org.apache.maven.plugin.deploy.stubs;
+
+/*
+ * 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.artifact.repository.ArtifactRepository;
+
+public class MavenProjectStub
+    extends org.apache.maven.plugin.testing.stubs.MavenProjectStub
+{
+
+    private ArtifactRepositoryStub deploymentRepository;
+
+    public ArtifactRepository getDistributionManagementArtifactRepository()
+    {
+        return deploymentRepository;
+    }
+
+}

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/stubs/MavenProjectStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/stubs/MavenProjectStub.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: 
maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/basic-deploy-pom/plugin-config.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/basic-deploy-pom/plugin-config.xml?rev=892616&r1=892615&r2=892616&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/basic-deploy-pom/plugin-config.xml
 (original)
+++ 
maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/basic-deploy-pom/plugin-config.xml
 Sun Dec 20 17:30:52 2009
@@ -28,7 +28,9 @@
           <artifact 
implementation="org.apache.maven.plugin.deploy.stubs.DeployArtifactStub" />
           <attachedArtifacts />
           <localRepository>${localRepository}</localRepository>
-          <deploymentRepository 
implementation="org.apache.maven.plugin.deploy.stubs.ArtifactRepositoryStub" />
+          <project 
implementation="org.apache.maven.plugin.deploy.stubs.MavenProjectStub">
+            <deploymentRepository 
implementation="org.apache.maven.plugin.deploy.stubs.ArtifactRepositoryStub" />
+          </project>
           <updateReleaseInfo>true</updateReleaseInfo>
         </configuration>
       </plugin>

Modified: 
maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/basic-deploy-scp/plugin-config.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/basic-deploy-scp/plugin-config.xml?rev=892616&r1=892615&r2=892616&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/basic-deploy-scp/plugin-config.xml
 (original)
+++ 
maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/basic-deploy-scp/plugin-config.xml
 Sun Dec 20 17:30:52 2009
@@ -28,7 +28,9 @@
           <artifact 
implementation="org.apache.maven.plugin.deploy.stubs.DeployArtifactStub" />
           <attachedArtifacts />
           <localRepository>${localRepository}</localRepository>
-          <deploymentRepository 
implementation="org.apache.maven.plugin.deploy.stubs.ArtifactRepositoryStub2" />
+          <project 
implementation="org.apache.maven.plugin.deploy.stubs.MavenProjectStub">
+            <deploymentRepository 
implementation="org.apache.maven.plugin.deploy.stubs.ArtifactRepositoryStub2" />
+          </project>
           <updateReleaseInfo>false</updateReleaseInfo>
           <deployer 
implementation="org.apache.maven.plugin.deploy.stubs.ArtifactDeployerStub" />
         </configuration>

Modified: 
maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/basic-deploy-test/plugin-config.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/basic-deploy-test/plugin-config.xml?rev=892616&r1=892615&r2=892616&view=diff
==============================================================================
Binary files - no diff available.

Modified: 
maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/basic-deploy-with-attached-artifacts/plugin-config.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/basic-deploy-with-attached-artifacts/plugin-config.xml?rev=892616&r1=892615&r2=892616&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/basic-deploy-with-attached-artifacts/plugin-config.xml
 (original)
+++ 
maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/basic-deploy-with-attached-artifacts/plugin-config.xml
 Sun Dec 20 17:30:52 2009
@@ -30,7 +30,9 @@
             <attachedArtifact 
implementation="org.apache.maven.plugin.deploy.stubs.AttachedArtifactStub" />
           </attachedArtifacts>
           <localRepository>${localRepository}</localRepository>
-          <deploymentRepository 
implementation="org.apache.maven.plugin.deploy.stubs.ArtifactRepositoryStub" />
+          <project 
implementation="org.apache.maven.plugin.deploy.stubs.MavenProjectStub">
+            <deploymentRepository 
implementation="org.apache.maven.plugin.deploy.stubs.ArtifactRepositoryStub" />
+          </project>
           <updateReleaseInfo>true</updateReleaseInfo>
         </configuration>
       </plugin>


Reply via email to