[MPLUGIN-168] Provide ability to set package of HelpMojo
git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@940004 13f79535-47bb-0310-9956-ffa450edef68master
parent
94f941a1e5
commit
8f3fb7e4e2
|
|
@ -0,0 +1 @@
|
||||||
|
invoker.goals = compile
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
<?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.plugin</groupId>
|
||||||
|
<artifactId>help</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<packaging>maven-plugin</packaging>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
Tests generation of the help mojo in a user-specified package (MPLUGIN-168).
|
||||||
|
</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>
|
||||||
|
<configuration>
|
||||||
|
<helpPackageName>test.help</helpPackageName>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>help-goal</id>
|
||||||
|
<goals>
|
||||||
|
<goal>helpmojo</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package test;
|
||||||
|
|
||||||
|
import org.apache.maven.plugin.AbstractMojo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MOJO-DESCRIPTION.
|
||||||
|
*
|
||||||
|
* @goal test
|
||||||
|
*/
|
||||||
|
public class MyMojo
|
||||||
|
extends AbstractMojo
|
||||||
|
{
|
||||||
|
|
||||||
|
public void execute()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
File helpMojo = new File( basedir, "target/classes/test/help/HelpMojo.class" );
|
||||||
|
if ( !helpMojo.isFile() )
|
||||||
|
{
|
||||||
|
throw new FileNotFoundException( "Missing/misplaced: " + helpMojo );
|
||||||
|
}
|
||||||
|
|
@ -44,6 +44,15 @@ public class HelpGeneratorMojo
|
||||||
*/
|
*/
|
||||||
protected File outputDirectory;
|
protected File outputDirectory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the package for the generated <code>HelpMojo</code>. By default, the package will be calculated based
|
||||||
|
* on the packages of the other plugin goals.
|
||||||
|
*
|
||||||
|
* @parameter
|
||||||
|
* @since 2.6
|
||||||
|
*/
|
||||||
|
private String helpPackageName;
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
protected File getOutputDirectory()
|
protected File getOutputDirectory()
|
||||||
{
|
{
|
||||||
|
|
@ -53,7 +62,7 @@ public class HelpGeneratorMojo
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
protected Generator createGenerator()
|
protected Generator createGenerator()
|
||||||
{
|
{
|
||||||
return new PluginHelpGenerator();
|
return new PluginHelpGenerator().setHelpPackageName( helpPackageName );
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,8 @@ public class PluginHelpGenerator
|
||||||
/** Default goal */
|
/** Default goal */
|
||||||
private static final String HELP_GOAL = "help";
|
private static final String HELP_GOAL = "help";
|
||||||
|
|
||||||
|
private String helpPackageName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor
|
* Default constructor
|
||||||
*/
|
*/
|
||||||
|
|
@ -134,6 +136,12 @@ public class PluginHelpGenerator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PluginHelpGenerator setHelpPackageName( String helpPackageName )
|
||||||
|
{
|
||||||
|
this.helpPackageName = helpPackageName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Private methods
|
// Private methods
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
@ -145,7 +153,7 @@ public class PluginHelpGenerator
|
||||||
* <code>null</code>.
|
* <code>null</code>.
|
||||||
* @return The mojo descriptor for the generated help goal, never <code>null</code>.
|
* @return The mojo descriptor for the generated help goal, never <code>null</code>.
|
||||||
*/
|
*/
|
||||||
private static MojoDescriptor makeHelpDescriptor( PluginDescriptor pluginDescriptor )
|
private MojoDescriptor makeHelpDescriptor( PluginDescriptor pluginDescriptor )
|
||||||
{
|
{
|
||||||
MojoDescriptor descriptor = new MojoDescriptor();
|
MojoDescriptor descriptor = new MojoDescriptor();
|
||||||
|
|
||||||
|
|
@ -155,7 +163,11 @@ public class PluginHelpGenerator
|
||||||
|
|
||||||
descriptor.setGoal( HELP_GOAL );
|
descriptor.setGoal( HELP_GOAL );
|
||||||
|
|
||||||
String packageName = discoverPackageName( pluginDescriptor );
|
String packageName = helpPackageName;
|
||||||
|
if ( StringUtils.isEmpty( packageName ) )
|
||||||
|
{
|
||||||
|
packageName = discoverPackageName( pluginDescriptor );
|
||||||
|
}
|
||||||
if ( StringUtils.isNotEmpty( packageName ) )
|
if ( StringUtils.isNotEmpty( packageName ) )
|
||||||
{
|
{
|
||||||
descriptor.setImplementation( packageName + '.' + HELP_MOJO_CLASS_NAME );
|
descriptor.setImplementation( packageName + '.' + HELP_MOJO_CLASS_NAME );
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue