maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r404736 - in /maven/plugins/trunk/maven-release-plugin/src: main/java/org/apache/maven/plugins/release/ test/java/org/apache/maven/plugins/release/ test/java/org/apache/maven/plugins/release/stubs/ test/resources/mojos/perform/
Date Sun, 07 May 2006 07:19:21 GMT
Author: brett
Date: Sun May  7 00:19:18 2006
New Revision: 404736

URL: http://svn.apache.org/viewcvs?rev=404736&view=rev
Log:
if there is no distributionManagement > site, then don't default to site-deploy

Added:
    maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/stubs/
    maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/stubs/MavenProjectStub.java
  (with props)
Modified:
    maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java
    maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PerformReleaseMojo.java
    maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/PerformReleaseMojoTest.java
    maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform-with-args.xml
    maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform-with-scm.xml
    maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform.xml

Modified: maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java?rev=404736&r1=404735&r2=404736&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java
(original)
+++ maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java
Sun May  7 00:19:18 2006
@@ -84,7 +84,7 @@
      * @required
      * @readonly
      */
-    private MavenProject project;
+    protected MavenProject project;
 
     /**
      * @component

Modified: maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PerformReleaseMojo.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PerformReleaseMojo.java?rev=404736&r1=404735&r2=404736&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PerformReleaseMojo.java
(original)
+++ maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PerformReleaseMojo.java
Sun May  7 00:19:18 2006
@@ -40,7 +40,7 @@
      *
      * @parameter expression="${goals}"
      */
-    private String goals = "deploy site-deploy";
+    private String goals;
 
     /**
      * The checkout directory.
@@ -75,6 +75,17 @@
             if ( connectionUrl != null )
             {
                 releaseConfiguration.setUrl( connectionUrl );
+            }
+
+            if ( goals == null )
+            {
+                // set default
+                goals = "deploy";
+                if ( project.getDistributionManagement() != null &&
+                    project.getDistributionManagement().getSite() != null )
+                {
+                    goals += " site-deploy";
+                }
             }
 
             releaseManager.perform( releaseConfiguration, workingDirectory, goals, useReleaseProfile
);

Modified: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/PerformReleaseMojoTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/PerformReleaseMojoTest.java?rev=404736&r1=404735&r2=404736&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/PerformReleaseMojoTest.java
(original)
+++ maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/PerformReleaseMojoTest.java
Sun May  7 00:19:18 2006
@@ -16,7 +16,9 @@
  * limitations under the License.
  */
 
+import org.apache.maven.model.DistributionManagement;
 import org.apache.maven.model.Profile;
+import org.apache.maven.model.Site;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
@@ -42,8 +44,7 @@
     public void testPerform()
         throws Exception
     {
-        PerformReleaseMojo mojo = (PerformReleaseMojo) lookupMojo( "perform", getTestFile(
-            "target/test-classes/mojos/perform/perform.xml" ) );
+        PerformReleaseMojo mojo = getMojoWithProjectSite( "perform.xml" );
 
         ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
         releaseConfiguration.setSettings( mojo.getSettings() );
@@ -60,11 +61,45 @@
         assertTrue( true );
     }
 
-    public void testPerformWithExecutionException()
+    public void testPerformWithoutSite()
+        throws Exception
+    {
+        PerformReleaseMojo mojo = (PerformReleaseMojo) lookupMojo( "perform", getTestFile(
+            "target/test-classes/mojos/perform/" + "perform.xml" ) );
+
+        ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+        releaseConfiguration.setSettings( mojo.getSettings() );
+
+        Mock mock = new Mock( ReleaseManager.class );
+        Constraint[] constraints = new Constraint[]{new IsEqual( releaseConfiguration ),
+            new IsEqual( new File( getBasedir(), "target/checkout" ) ), new IsEqual( "deploy"
),
+            new IsEqual( Boolean.TRUE )};
+        mock.expects( new InvokeOnceMatcher() ).method( "perform" ).with( constraints );
+        mojo.setReleaseManager( (ReleaseManager) mock.proxy() );
+
+        mojo.execute();
+
+        assertTrue( true );
+    }
+
+    private PerformReleaseMojo getMojoWithProjectSite( String fileName )
         throws Exception
     {
         PerformReleaseMojo mojo = (PerformReleaseMojo) lookupMojo( "perform", getTestFile(
-            "target/test-classes/mojos/perform/perform.xml" ) );
+            "target/test-classes/mojos/perform/" + fileName ) );
+
+        MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project"
);
+        DistributionManagement distributionManagement = new DistributionManagement();
+        distributionManagement.setSite( new Site() );
+        project.setDistributionManagement( distributionManagement );
+
+        return mojo;
+    }
+
+    public void testPerformWithExecutionException()
+        throws Exception
+    {
+        PerformReleaseMojo mojo = getMojoWithProjectSite( "perform.xml" );
 
         ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
         releaseConfiguration.setSettings( mojo.getSettings() );
@@ -92,8 +127,7 @@
     public void testPerformWithExecutionFailure()
         throws Exception
     {
-        PerformReleaseMojo mojo = (PerformReleaseMojo) lookupMojo( "perform", getTestFile(
-            "target/test-classes/mojos/perform/perform.xml" ) );
+        PerformReleaseMojo mojo = getMojoWithProjectSite( "perform.xml" );
 
         ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
         releaseConfiguration.setSettings( mojo.getSettings() );
@@ -121,8 +155,7 @@
     public void testPerformWithScm()
         throws Exception
     {
-        PerformReleaseMojo mojo = (PerformReleaseMojo) lookupMojo( "perform", getTestFile(
-            "target/test-classes/mojos/perform/perform-with-scm.xml" ) );
+        PerformReleaseMojo mojo = getMojoWithProjectSite( "perform-with-scm.xml" );
 
         ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
         releaseConfiguration.setSettings( mojo.getSettings() );
@@ -143,8 +176,7 @@
     public void testPerformWithProfiles()
         throws Exception
     {
-        PerformReleaseMojo mojo = (PerformReleaseMojo) lookupMojo( "perform", getTestFile(
-            "target/test-classes/mojos/perform/perform.xml" ) );
+        PerformReleaseMojo mojo = getMojoWithProjectSite( "perform.xml" );
 
         ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
         releaseConfiguration.setSettings( mojo.getSettings() );
@@ -172,8 +204,7 @@
     public void testPerformWithProfilesAndArguments()
         throws Exception
     {
-        PerformReleaseMojo mojo = (PerformReleaseMojo) lookupMojo( "perform", getTestFile(
-            "target/test-classes/mojos/perform/perform-with-args.xml" ) );
+        PerformReleaseMojo mojo = getMojoWithProjectSite( "perform-with-args.xml" );
 
         ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
         releaseConfiguration.setSettings( mojo.getSettings() );

Added: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/stubs/MavenProjectStub.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/stubs/MavenProjectStub.java?rev=404736&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/stubs/MavenProjectStub.java
(added)
+++ maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/stubs/MavenProjectStub.java
Sun May  7 00:19:18 2006
@@ -0,0 +1,54 @@
+package org.apache.maven.plugins.release.stubs;
+
+import org.apache.maven.model.DistributionManagement;
+import org.apache.maven.model.Model;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * Stub for MavenProject.
+ * <p/>
+ * TODO: shouldn't need to do this, but the "stub" in the harness just throws away values
you set.
+ * Just overriding the ones I need for this plugin.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @noinspection ClassNameSameAsAncestorName
+ */
+public class MavenProjectStub
+    extends org.apache.maven.plugin.testing.stubs.MavenProjectStub
+{
+    public void setDistributionManagement( DistributionManagement distributionManagement
)
+    {
+        getModel().setDistributionManagement( distributionManagement );
+    }
+
+    public Model getModel()
+    {
+        Model model = super.getModel();
+        if ( model == null )
+        {
+            model = new Model();
+            setModel( model );
+        }
+        return model;
+    }
+
+    public DistributionManagement getDistributionManagement()
+    {
+        return getModel().getDistributionManagement();
+    }
+}

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

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

Modified: maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform-with-args.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform-with-args.xml?rev=404736&r1=404735&r2=404736&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform-with-args.xml
(original)
+++ maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform-with-args.xml
Sun May  7 00:19:18 2006
@@ -21,7 +21,7 @@
         <artifactId>maven-release-plugin</artifactId>
         <configuration>
           <settings implementation="org.apache.maven.settings.Settings"/>
-          <project implementation="org.apache.maven.plugin.testing.stubs.MavenProjectStub"/>
+          <project implementation="org.apache.maven.plugins.release.stubs.MavenProjectStub"/>
           <workingDirectory>${basedir}/target/checkout</workingDirectory>
           <useReleaseProfile>true</useReleaseProfile>
           <arguments>-Dmaven.test.skip=true</arguments>

Modified: maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform-with-scm.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform-with-scm.xml?rev=404736&r1=404735&r2=404736&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform-with-scm.xml
(original)
+++ maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform-with-scm.xml
Sun May  7 00:19:18 2006
@@ -21,7 +21,7 @@
         <artifactId>maven-release-plugin</artifactId>
         <configuration>
           <settings implementation="org.apache.maven.settings.Settings"/>
-          <project implementation="org.apache.maven.plugin.testing.stubs.MavenProjectStub"/>
+          <project implementation="org.apache.maven.plugins.release.stubs.MavenProjectStub"/>
           <workingDirectory>${basedir}/target/checkout</workingDirectory>
           <useReleaseProfile>true</useReleaseProfile>
           <connectionUrl>scm-url</connectionUrl>

Modified: maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform.xml?rev=404736&r1=404735&r2=404736&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform.xml
(original)
+++ maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform.xml
Sun May  7 00:19:18 2006
@@ -21,7 +21,7 @@
         <artifactId>maven-release-plugin</artifactId>
         <configuration>
           <settings implementation="org.apache.maven.settings.Settings"/>
-          <project implementation="org.apache.maven.plugin.testing.stubs.MavenProjectStub"/>
+          <project implementation="org.apache.maven.plugins.release.stubs.MavenProjectStub"/>
           <workingDirectory>${basedir}/target/checkout</workingDirectory>
           <useReleaseProfile>true</useReleaseProfile>
         </configuration>



Mime
View raw message