Author: stephenc
Date: Thu Jun  9 09:20:50 2011
New Revision: 1133737

URL: http://svn.apache.org/viewvc?rev=1133737&view=rev
Log:
[MPLUGIN-174] Add standard skip configuration option.

o There may be valid use cases where the skip property is useful.

Added:
    maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/
    maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/invoker.properties
    maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/pom.xml
    maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/src/
    maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/src/main/
    maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/src/main/java/
    maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/src/main/java/org/
    
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/src/main/java/org/apache/
    
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/src/main/java/org/apache/maven/
    
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/src/main/java/org/apache/maven/plugin/
    
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/src/main/java/org/apache/maven/plugin/coreit/
    
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/src/main/java/org/apache/maven/plugin/coreit/CoreIt0013Mojo.java
    
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
    
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/src/main/java/org/apache/maven/plugin/coreit/SecondMojo.java
    maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/verify.groovy
Modified:
    
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
    
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java
    
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java
    
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/UpdatePluginRegistryMojo.java
    
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/metadata/AddPluginArtifactMetadataMojo.java

Added: 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/invoker.properties
URL: 
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/invoker.properties?rev=1133737&view=auto
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/invoker.properties 
(added)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/invoker.properties 
Thu Jun  9 09:20:50 2011
@@ -0,0 +1,2 @@
+invoker.goals = install
+invoker.mavenOpts = -Dmaven.plugin.skip=true
\ No newline at end of file

Added: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/pom.xml?rev=1133737&view=auto
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/pom.xml (added)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/pom.xml Thu Jun  9 
09:20:50 2011
@@ -0,0 +1,56 @@
+<?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>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.it0013</groupId>
+  <artifactId>mplugin-174</artifactId>
+  <version>1.0</version>
+  <packaging>maven-plugin</packaging>
+
+  <name>MPLUGIN-174</name>
+  <description>
+    Test the skip property
+  </description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-plugin-plugin</artifactId>
+        <version>@project.version@</version>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/src/main/java/org/apache/maven/plugin/coreit/CoreIt0013Mojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/src/main/java/org/apache/maven/plugin/coreit/CoreIt0013Mojo.java?rev=1133737&view=auto
==============================================================================
--- 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/src/main/java/org/apache/maven/plugin/coreit/CoreIt0013Mojo.java
 (added)
+++ 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/src/main/java/org/apache/maven/plugin/coreit/CoreIt0013Mojo.java
 Thu Jun  9 09:20:50 2011
@@ -0,0 +1,67 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * 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.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Touches a test file.
+ * 
+ * @goal it0013
+ */
+public class CoreIt0013Mojo
+    extends AbstractMojo
+{
+    
+    /**
+     * @parameter expression="${project.build.directory}"
+     * @required
+     */
+    private String outputDirectory;
+
+    public void execute()
+        throws MojoExecutionException
+    {
+        getLog().info( "outputDirectory = " + outputDirectory );
+
+        File f = new File( outputDirectory );
+        
+        if ( !f.exists() )
+        {
+            f.mkdirs();
+        }
+        
+        File touch = new File( f, "touch.txt" );
+        
+        try
+        {
+            touch.createNewFile();
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Error writing verification 
file.", e );
+        }                
+    }
+
+}

Added: 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java?rev=1133737&view=auto
==============================================================================
--- 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
 (added)
+++ 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
 Thu Jun  9 09:20:50 2011
@@ -0,0 +1,72 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * 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.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Touches a test file.
+ * 
+ * @goal first
+ * @requiresDependencyResolution test
+ * @phase integration-test
+ * @execute phase="generate-sources" lifecycle="cobertura"
+ * @deprecated Don't use!
+ * @since 1.2
+ */
+public class FirstMojo
+    extends AbstractMojo
+{
+    
+    /**
+     * Project directory.
+     * @parameter default-value="${basedir}"
+     * @readonly
+     */
+    private File basedir;
+    
+    /**
+     * @parameter expression="${first.touchFile}" 
default-value="${project.build.directory}/touch.txt"
+     * @required
+     */
+    private File touchFile;
+
+    /**
+     * @parameter alias="alias"
+     * @deprecated As of 0.2
+     * @since 0.1
+     */
+    private String aliasedParam;
+
+    /**
+     * @component role="org.apache.maven.project.MavenProjectHelper" 
roleHint="test"
+     */
+    private Object projectHelper;
+
+    public void execute()
+        throws MojoExecutionException
+    {
+    }
+
+}

Added: 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/src/main/java/org/apache/maven/plugin/coreit/SecondMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/src/main/java/org/apache/maven/plugin/coreit/SecondMojo.java?rev=1133737&view=auto
==============================================================================
--- 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/src/main/java/org/apache/maven/plugin/coreit/SecondMojo.java
 (added)
+++ 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/src/main/java/org/apache/maven/plugin/coreit/SecondMojo.java
 Thu Jun  9 09:20:50 2011
@@ -0,0 +1,39 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * 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.plugin.AbstractMojo;
+
+/**
+ * Does nothing special.
+ * 
+ * @goal second
+ * @requiresDependencyCollection compile
+ * @threadSafe
+ */
+public class SecondMojo
+    extends AbstractMojo
+{
+
+    public void execute()
+    {
+    }
+
+}

Added: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/verify.groovy
URL: 
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/verify.groovy?rev=1133737&view=auto
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/verify.groovy 
(added)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/skip/verify.groovy Thu 
Jun  9 09:20:50 2011
@@ -0,0 +1,4 @@
+File descriptorFile = new File( basedir, 
"target/classes/META-INF/maven/plugin.xml" );
+assert !descriptorFile.isFile()
+
+return true;

Modified: 
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java?rev=1133737&r1=1133736&r2=1133737&view=diff
==============================================================================
--- 
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
 (original)
+++ 
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
 Thu Jun  9 09:20:50 2011
@@ -107,6 +107,14 @@ public abstract class AbstractGeneratorM
     protected Set<String> extractors;
 
     /**
+     * Set this to "true" to skip invoking any goals or reports of the plugin.
+     *
+     * @parameter default-value="false" expression="${maven.plugin.skip}"
+     * @since 2.8
+     */
+    protected boolean skip;
+
+    /**
      * @return the output directory where files will be generated.
      */
     protected abstract File getOutputDirectory();
@@ -124,6 +132,11 @@ public abstract class AbstractGeneratorM
         {
             return;
         }
+        if ( skip )
+        {
+            getLog().warn( "Execution skipped" );
+            return;
+        }
 
         if ( project.getArtifactId().toLowerCase().startsWith( "maven-" ) 
             && project.getArtifactId().toLowerCase().endsWith( "-plugin" )

Modified: 
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java?rev=1133737&r1=1133736&r2=1133737&view=diff
==============================================================================
--- 
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java
 (original)
+++ 
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java
 Thu Jun  9 09:20:50 2011
@@ -79,7 +79,7 @@ public class HelpGeneratorMojo
     {
         super.execute();
 
-        if ( !project.getCompileSourceRoots().contains( 
outputDirectory.getAbsolutePath() ) )
+        if ( !project.getCompileSourceRoots().contains( 
outputDirectory.getAbsolutePath() ) && !skip )
         {
             project.addCompileSourceRoot( outputDirectory.getAbsolutePath() );
         }

Modified: 
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java
URL: 
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java?rev=1133737&r1=1133736&r2=1133737&view=diff
==============================================================================
--- 
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java
 (original)
+++ 
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java
 Thu Jun  9 09:20:50 2011
@@ -131,6 +131,22 @@ public class PluginReport
      */
     protected String goalPrefix;
 
+    /**
+     * Set this to "true" to skip invoking any goals or reports of the plugin.
+     *
+     * @parameter default-value="false" expression="${maven.plugin.skip}"
+     * @since 2.8
+     */
+    private boolean skip;
+
+    /**
+     * Set this to "true" to skip generating the report.
+     *
+     * @parameter default-value="false" 
expression="${maven.plugin.report.skip}"
+     * @since 2.8
+     */
+    private boolean skipReport;
+
     /** {@inheritDoc} */
     protected Renderer getSiteRenderer()
     {
@@ -163,6 +179,11 @@ public class PluginReport
         {
             return;
         }
+        if (skip || skipReport)
+        {
+            getLog().info( "Maven Plugin Plugin Report generation skipped." );
+            return;
+        }
 
         // Copy from AbstractGeneratorMojo#execute()
         String defaultGoalPrefix = 
PluginDescriptor.getGoalPrefixFromArtifactId( project.getArtifactId() );

Modified: 
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/UpdatePluginRegistryMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/UpdatePluginRegistryMojo.java?rev=1133737&r1=1133736&r2=1133737&view=diff
==============================================================================
--- 
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/UpdatePluginRegistryMojo.java
 (original)
+++ 
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/UpdatePluginRegistryMojo.java
 Thu Jun  9 09:20:50 2011
@@ -94,12 +94,33 @@ public class UpdatePluginRegistryMojo
      */
     private MavenPluginRegistryBuilder pluginRegistryBuilder;
 
+    /**
+     * Set this to "true" to skip invoking any goals or reports of the plugin.
+     *
+     * @parameter default-value="false" expression="${maven.plugin.skip}"
+     * @since 2.8
+     */
+    private boolean skip;
+
+    /**
+     * Set this to "true" to skip updating the plugin registry.
+     *
+     * @parameter default-value="false" 
expression="${maven.plugin.update.registry.skip}"
+     * @since 2.8
+     */
+    private boolean skipUpdatePluginRegistry;
+
     /** {@inheritDoc} */
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
         if ( usePluginRegistry )
         {
+            if ( skip || skipUpdatePluginRegistry )
+            {
+                getLog().warn( "Execution skipped" );
+                return;
+            }
             updatePluginVersionInRegistry( groupId, artifactId, version );
         }
     }

Modified: 
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/metadata/AddPluginArtifactMetadataMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/metadata/AddPluginArtifactMetadataMojo.java?rev=1133737&r1=1133736&r2=1133737&view=diff
==============================================================================
--- 
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/metadata/AddPluginArtifactMetadataMojo.java
 (original)
+++ 
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/metadata/AddPluginArtifactMetadataMojo.java
 Thu Jun  9 09:20:50 2011
@@ -58,10 +58,23 @@ public class AddPluginArtifactMetadataMo
      */
     private String goalPrefix;
 
+    /**
+     * Set this to "true" to skip invoking any goals or reports of the plugin.
+     *
+     * @parameter default-value="false" expression="${maven.plugin.skip}"
+     * @since 2.8
+     */
+    private boolean skip;
+
     /** {@inheritDoc} */
     public void execute()
         throws MojoExecutionException
     {
+        if ( skip )
+        {
+            getLog().warn( "Execution skipped" );
+            return;
+        }
         Artifact projectArtifact = project.getArtifact();
 
         Versioning versioning = new Versioning();


Reply via email to