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/08/11 18:03:19 UTC

svn commit: r803177 - in /maven/plugins/trunk/maven-deploy-plugin/src: it/offline/ main/java/org/apache/maven/plugin/deploy/

Author: bentmann
Date: Tue Aug 11 16:03:19 2009
New Revision: 803177

URL: http://svn.apache.org/viewvc?rev=803177&view=rev
Log:
[MDEPLOY-109] Have plugin itself respect Maven's online/offline mode

Added:
    maven/plugins/trunk/maven-deploy-plugin/src/it/offline/
    maven/plugins/trunk/maven-deploy-plugin/src/it/offline/invoker.properties   (with props)
    maven/plugins/trunk/maven-deploy-plugin/src/it/offline/pom.xml   (with props)
    maven/plugins/trunk/maven-deploy-plugin/src/it/offline/setup.bsh   (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/DeployFileMojo.java
    maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java

Added: maven/plugins/trunk/maven-deploy-plugin/src/it/offline/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/offline/invoker.properties?rev=803177&view=auto
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/it/offline/invoker.properties (added)
+++ maven/plugins/trunk/maven-deploy-plugin/src/it/offline/invoker.properties Tue Aug 11 16:03:19 2009
@@ -0,0 +1,4 @@
+invoker.goals.1 = deploy
+
+invoker.goals.2 = --offline deploy
+invoker.buildResult.2 = failure

Propchange: maven/plugins/trunk/maven-deploy-plugin/src/it/offline/invoker.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-deploy-plugin/src/it/offline/invoker.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-deploy-plugin/src/it/offline/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/offline/pom.xml?rev=803177&view=auto
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/it/offline/pom.xml (added)
+++ maven/plugins/trunk/maven-deploy-plugin/src/it/offline/pom.xml Tue Aug 11 16:03:19 2009
@@ -0,0 +1,81 @@
+<?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.om</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+
+  <description>
+    Tests that the deployment fails when Maven is in offline mode.
+  </description>
+
+  <properties>
+    <maven.test.skip>true</maven.test.skip>
+  </properties>
+
+  <distributionManagement>
+    <repository>
+      <id>it</id>
+      <url>file:///${basedir}/target/repo</url>
+      <uniqueVersion>false</uniqueVersion>
+    </repository>
+  </distributionManagement>
+
+  <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>
+      </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-jar-plugin</artifactId>
+        <version>2.1</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>
+    </plugins>
+  </build>
+
+</project>

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

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

Added: maven/plugins/trunk/maven-deploy-plugin/src/it/offline/setup.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/offline/setup.bsh?rev=803177&view=auto
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/it/offline/setup.bsh (added)
+++ maven/plugins/trunk/maven-deploy-plugin/src/it/offline/setup.bsh Tue Aug 11 16:03:19 2009
@@ -0,0 +1,14 @@
+import java.io.*;
+import java.util.*;
+
+import org.codehaus.plexus.util.*;
+
+File file = new File( localRepositoryPath, "org/apache/maven/its/deploy/om" );
+System.out.println( "Deleting " + file );
+FileUtils.deleteDirectory( file );
+
+file = new File( basedir, "target/repo" );
+System.out.println( "Deleting " + file );
+FileUtils.deleteDirectory( file );
+
+return true;

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

Propchange: maven/plugins/trunk/maven-deploy-plugin/src/it/offline/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=803177&r1=803176&r2=803177&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 Tue Aug 11 16:03:19 2009
@@ -23,6 +23,7 @@
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoFailureException;
 
 /**
  * @version $Id$
@@ -50,6 +51,14 @@
     private ArtifactRepository localRepository;
 
     /**
+     * Flag whether Maven is currently in online/offline mode.
+     * 
+     * @parameter default-value="${settings.offline}"
+     * @readonly
+     */
+    private boolean offline;
+
+    /**
      * Parameter used to update the metadata to make the artifact as release.
      * 
      * @parameter expression="${updateReleaseInfo}" default-value="false"
@@ -77,4 +86,14 @@
     {
         this.localRepository = localRepository;
     }
+
+    void failIfOffline()
+        throws MojoFailureException
+    {
+        if ( offline )
+        {
+            throw new MojoFailureException( "Cannot deploy artifacts when Maven is in offline mode" );
+        }
+    }
+
 }

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=803177&r1=803176&r2=803177&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 Tue Aug 11 16:03:19 2009
@@ -195,6 +195,8 @@
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
+        failIfOffline();
+
         initProperties();
 
         validateArtifactInformation();

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=803177&r1=803176&r2=803177&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 Tue Aug 11 16:03:19 2009
@@ -117,13 +117,14 @@
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
-        
         if ( skip )
         {
             getLog().info( "Skipping artifact deployment" );
             return;
         }
-        
+
+        failIfOffline();
+
         ArtifactRepository repo = getDeploymentRepository();
 
         String protocol = repo.getProtocol();