Return-Path: Delivered-To: apmail-maven-commits-archive@www.apache.org Received: (qmail 47902 invoked from network); 11 Aug 2009 16:03:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 11 Aug 2009 16:03:39 -0000 Received: (qmail 92244 invoked by uid 500); 11 Aug 2009 16:03:45 -0000 Delivered-To: apmail-maven-commits-archive@maven.apache.org Received: (qmail 92126 invoked by uid 500); 11 Aug 2009 16:03:45 -0000 Mailing-List: contact commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list commits@maven.apache.org Received: (qmail 92117 invoked by uid 99); 11 Aug 2009 16:03:45 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Aug 2009 16:03:45 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Aug 2009 16:03:41 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 34CA52388981; Tue, 11 Aug 2009 16:03:20 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r803177 - in /maven/plugins/trunk/maven-deploy-plugin/src: it/offline/ main/java/org/apache/maven/plugin/deploy/ Date: Tue, 11 Aug 2009 16:03:19 -0000 To: commits@maven.apache.org From: bentmann@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090811160320.34CA52388981@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 @@ + + + + + + 4.0.0 + + org.apache.maven.its.deploy.om + test + 1.0-SNAPSHOT + jar + + + Tests that the deployment fails when Maven is in offline mode. + + + + true + + + + + it + file:///${basedir}/target/repo + false + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + + org.apache.maven.plugins + maven-install-plugin + 2.2 + + + org.apache.maven.plugins + maven-jar-plugin + 2.1 + + + org.apache.maven.plugins + maven-resources-plugin + 2.2 + + + org.apache.maven.plugins + maven-surefire-plugin + 2.3.1 + + + + + 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();