[MPLUGIN-174] Add standard skip configuration option.

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

git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1133737 13f79535-47bb-0310-9956-ffa450edef68
master
Stephen Connolly 2011-06-09 09:20:50 +00:00
parent bf39ba1803
commit 595cc6897c
11 changed files with 309 additions and 1 deletions

View File

@ -0,0 +1,2 @@
invoker.goals = install
invoker.mavenOpts = -Dmaven.plugin.skip=true

View File

@ -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>

View File

@ -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 );
}
}
}

View File

@ -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
{
}
}

View File

@ -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()
{
}
}

View File

@ -0,0 +1,4 @@
File descriptorFile = new File( basedir, "target/classes/META-INF/maven/plugin.xml" );
assert !descriptorFile.isFile()
return true;

View File

@ -106,6 +106,14 @@ public abstract class AbstractGeneratorMojo
*/
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.
*/
@ -124,6 +132,11 @@ public abstract class AbstractGeneratorMojo
{
return;
}
if ( skip )
{
getLog().warn( "Execution skipped" );
return;
}
if ( project.getArtifactId().toLowerCase().startsWith( "maven-" )
&& project.getArtifactId().toLowerCase().endsWith( "-plugin" )

View File

@ -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() );
}

View File

@ -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() );

View File

@ -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 );
}
}

View File

@ -58,10 +58,23 @@ public class AddPluginArtifactMetadataMojo
*/
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();