[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-ffa450edef68master
parent
bf39ba1803
commit
595cc6897c
|
|
@ -0,0 +1,2 @@
|
||||||
|
invoker.goals = install
|
||||||
|
invoker.mavenOpts = -Dmaven.plugin.skip=true
|
||||||
|
|
@ -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>
|
||||||
|
|
@ -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 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
File descriptorFile = new File( basedir, "target/classes/META-INF/maven/plugin.xml" );
|
||||||
|
assert !descriptorFile.isFile()
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
@ -106,6 +106,14 @@ public abstract class AbstractGeneratorMojo
|
||||||
*/
|
*/
|
||||||
protected Set<String> extractors;
|
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.
|
* @return the output directory where files will be generated.
|
||||||
*/
|
*/
|
||||||
|
|
@ -124,6 +132,11 @@ public abstract class AbstractGeneratorMojo
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ( skip )
|
||||||
|
{
|
||||||
|
getLog().warn( "Execution skipped" );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( project.getArtifactId().toLowerCase().startsWith( "maven-" )
|
if ( project.getArtifactId().toLowerCase().startsWith( "maven-" )
|
||||||
&& project.getArtifactId().toLowerCase().endsWith( "-plugin" )
|
&& project.getArtifactId().toLowerCase().endsWith( "-plugin" )
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ public class HelpGeneratorMojo
|
||||||
{
|
{
|
||||||
super.execute();
|
super.execute();
|
||||||
|
|
||||||
if ( !project.getCompileSourceRoots().contains( outputDirectory.getAbsolutePath() ) )
|
if ( !project.getCompileSourceRoots().contains( outputDirectory.getAbsolutePath() ) && !skip )
|
||||||
{
|
{
|
||||||
project.addCompileSourceRoot( outputDirectory.getAbsolutePath() );
|
project.addCompileSourceRoot( outputDirectory.getAbsolutePath() );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -131,6 +131,22 @@ public class PluginReport
|
||||||
*/
|
*/
|
||||||
protected String goalPrefix;
|
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} */
|
/** {@inheritDoc} */
|
||||||
protected Renderer getSiteRenderer()
|
protected Renderer getSiteRenderer()
|
||||||
{
|
{
|
||||||
|
|
@ -163,6 +179,11 @@ public class PluginReport
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (skip || skipReport)
|
||||||
|
{
|
||||||
|
getLog().info( "Maven Plugin Plugin Report generation skipped." );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Copy from AbstractGeneratorMojo#execute()
|
// Copy from AbstractGeneratorMojo#execute()
|
||||||
String defaultGoalPrefix = PluginDescriptor.getGoalPrefixFromArtifactId( project.getArtifactId() );
|
String defaultGoalPrefix = PluginDescriptor.getGoalPrefixFromArtifactId( project.getArtifactId() );
|
||||||
|
|
|
||||||
|
|
@ -94,12 +94,33 @@ public class UpdatePluginRegistryMojo
|
||||||
*/
|
*/
|
||||||
private MavenPluginRegistryBuilder pluginRegistryBuilder;
|
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} */
|
/** {@inheritDoc} */
|
||||||
public void execute()
|
public void execute()
|
||||||
throws MojoExecutionException, MojoFailureException
|
throws MojoExecutionException, MojoFailureException
|
||||||
{
|
{
|
||||||
if ( usePluginRegistry )
|
if ( usePluginRegistry )
|
||||||
{
|
{
|
||||||
|
if ( skip || skipUpdatePluginRegistry )
|
||||||
|
{
|
||||||
|
getLog().warn( "Execution skipped" );
|
||||||
|
return;
|
||||||
|
}
|
||||||
updatePluginVersionInRegistry( groupId, artifactId, version );
|
updatePluginVersionInRegistry( groupId, artifactId, version );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,10 +58,23 @@ public class AddPluginArtifactMetadataMojo
|
||||||
*/
|
*/
|
||||||
private String goalPrefix;
|
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} */
|
/** {@inheritDoc} */
|
||||||
public void execute()
|
public void execute()
|
||||||
throws MojoExecutionException
|
throws MojoExecutionException
|
||||||
{
|
{
|
||||||
|
if ( skip )
|
||||||
|
{
|
||||||
|
getLog().warn( "Execution skipped" );
|
||||||
|
return;
|
||||||
|
}
|
||||||
Artifact projectArtifact = project.getArtifact();
|
Artifact projectArtifact = project.getArtifact();
|
||||||
|
|
||||||
Versioning versioning = new Versioning();
|
Versioning versioning = new Versioning();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue