You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2010/05/01 14:54:31 UTC
svn commit: r940004 - in /maven/plugin-tools/trunk:
maven-plugin-plugin/src/it/help-package/
maven-plugin-plugin/src/it/help-package/src/
maven-plugin-plugin/src/it/help-package/src/main/
maven-plugin-plugin/src/it/help-package/src/main/java/ maven-plu...
Author: bentmann
Date: Sat May 1 12:54:30 2010
New Revision: 940004
URL: http://svn.apache.org/viewvc?rev=940004&view=rev
Log:
[MPLUGIN-168] Provide ability to set package of HelpMojo
Added:
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/invoker.properties (with props)
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/pom.xml (with props)
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/src/
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/src/main/
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/src/main/java/
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/src/main/java/test/
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/src/main/java/test/MyMojo.java (with props)
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/verify.bsh (with props)
Modified:
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java
maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java
Added: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/invoker.properties?rev=940004&view=auto
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/invoker.properties (added)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/invoker.properties Sat May 1 12:54:30 2010
@@ -0,0 +1 @@
+invoker.goals = compile
Propchange: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/invoker.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/invoker.properties
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/pom.xml?rev=940004&view=auto
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/pom.xml (added)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/pom.xml Sat May 1 12:54:30 2010
@@ -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>
Propchange: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/src/main/java/test/MyMojo.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/src/main/java/test/MyMojo.java?rev=940004&view=auto
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/src/main/java/test/MyMojo.java (added)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/src/main/java/test/MyMojo.java Sat May 1 12:54:30 2010
@@ -0,0 +1,18 @@
+package test;
+
+import org.apache.maven.plugin.AbstractMojo;
+
+/**
+ * MOJO-DESCRIPTION.
+ *
+ * @goal test
+ */
+public class MyMojo
+ extends AbstractMojo
+{
+
+ public void execute()
+ {
+ }
+
+}
Propchange: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/src/main/java/test/MyMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/src/main/java/test/MyMojo.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/verify.bsh?rev=940004&view=auto
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/verify.bsh (added)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/verify.bsh Sat May 1 12:54:30 2010
@@ -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 );
+}
Propchange: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/verify.bsh
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/help-package/verify.bsh
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
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=940004&r1=940003&r2=940004&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 Sat May 1 12:54:30 2010
@@ -44,6 +44,15 @@ public class HelpGeneratorMojo
*/
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} */
protected File getOutputDirectory()
{
@@ -53,7 +62,7 @@ public class HelpGeneratorMojo
/** {@inheritDoc} */
protected Generator createGenerator()
{
- return new PluginHelpGenerator();
+ return new PluginHelpGenerator().setHelpPackageName( helpPackageName );
}
/** {@inheritDoc} */
Modified: maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java?rev=940004&r1=940003&r2=940004&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java Sat May 1 12:54:30 2010
@@ -65,6 +65,8 @@ public class PluginHelpGenerator
/** Default goal */
private static final String HELP_GOAL = "help";
+ private String helpPackageName;
+
/**
* Default constructor
*/
@@ -134,6 +136,12 @@ public class PluginHelpGenerator
}
}
+ public PluginHelpGenerator setHelpPackageName( String helpPackageName )
+ {
+ this.helpPackageName = helpPackageName;
+ return this;
+ }
+
// ----------------------------------------------------------------------
// Private methods
// ----------------------------------------------------------------------
@@ -145,7 +153,7 @@ public class PluginHelpGenerator
* <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();
@@ -155,7 +163,11 @@ public class PluginHelpGenerator
descriptor.setGoal( HELP_GOAL );
- String packageName = discoverPackageName( pluginDescriptor );
+ String packageName = helpPackageName;
+ if ( StringUtils.isEmpty( packageName ) )
+ {
+ packageName = discoverPackageName( pluginDescriptor );
+ }
if ( StringUtils.isNotEmpty( packageName ) )
{
descriptor.setImplementation( packageName + '.' + HELP_MOJO_CLASS_NAME );