Author: sebb
Date: Mon Jul 1 00:07:44 2013
New Revision: 1498196
URL: http://svn.apache.org/r1498196
Log:
New version of HelperMojo with GAV inserted at build time
Added:
maven/sandbox/trunk/plugins/maven-gpgsignfiles-plugin/src/main/templates/
maven/sandbox/trunk/plugins/maven-gpgsignfiles-plugin/src/main/templates/org/
maven/sandbox/trunk/plugins/maven-gpgsignfiles-plugin/src/main/templates/org/apache/
maven/sandbox/trunk/plugins/maven-gpgsignfiles-plugin/src/main/templates/org/apache/maven/
maven/sandbox/trunk/plugins/maven-gpgsignfiles-plugin/src/main/templates/org/apache/maven/gpg/
maven/sandbox/trunk/plugins/maven-gpgsignfiles-plugin/src/main/templates/org/apache/maven/gpg/HelperMojo.java
- copied, changed from r1497612,
maven/sandbox/trunk/plugins/maven-gpgsignfiles-plugin/src/main/java/org/apache/maven/plugin/gpg/HelpMojo.java
Modified:
maven/sandbox/trunk/plugins/maven-gpgsignfiles-plugin/pom.xml
Modified: maven/sandbox/trunk/plugins/maven-gpgsignfiles-plugin/pom.xml
URL:
http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-gpgsignfiles-plugin/pom.xml?rev=1498196&r1=1498195&r2=1498196&view=diff
==============================================================================
--- maven/sandbox/trunk/plugins/maven-gpgsignfiles-plugin/pom.xml (original)
+++ maven/sandbox/trunk/plugins/maven-gpgsignfiles-plugin/pom.xml Mon Jul 1
00:07:44 2013
@@ -189,6 +189,13 @@ This is intended as a temporary measure
<delete>
<fileset dir="target/generated-sources"
includes="**/HelpMojo.java"/>
</delete>
+ <copy todir="target/generated-sources/plugin">
+ <fileset dir="src/main/templates" includes="**/HelperMojo.java"/>
+ <filterset>
+ <filter token="GAV"
value="${project.groupId}:${project.artifactId}:${project.version}"/>
+ </filterset>
+ </copy>
+ <echo>Copied/replaced</echo>
</target>
</configuration>
</plugin>
Copied:
maven/sandbox/trunk/plugins/maven-gpgsignfiles-plugin/src/main/templates/org/apache/maven/gpg/HelperMojo.java
(from r1497612,
maven/sandbox/trunk/plugins/maven-gpgsignfiles-plugin/src/main/java/org/apache/maven/plugin/gpg/HelpMojo.java)
URL:
http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-gpgsignfiles-plugin/src/main/templates/org/apache/maven/gpg/HelperMojo.java?p2=maven/sandbox/trunk/plugins/maven-gpgsignfiles-plugin/src/main/templates/org/apache/maven/gpg/HelperMojo.java&p1=maven/sandbox/trunk/plugins/maven-gpgsignfiles-plugin/src/main/java/org/apache/maven/plugin/gpg/HelpMojo.java&r1=1497612&r2=1498196&rev=1498196&view=diff
==============================================================================
---
maven/sandbox/trunk/plugins/maven-gpgsignfiles-plugin/src/main/java/org/apache/maven/plugin/gpg/HelpMojo.java
(original)
+++
maven/sandbox/trunk/plugins/maven-gpgsignfiles-plugin/src/main/templates/org/apache/maven/gpg/HelperMojo.java
Mon Jul 1 00:07:44 2013
@@ -43,10 +43,8 @@ import org.xml.sax.SAXException;
* Nor does it handle default values
*/
@Mojo (name = "help", requiresProject=false )
-public class HelpMojo extends DescribeMojo
+public class HelperMojo extends DescribeMojo
{
- // Where to find plugin config
- private static final String PLUGIN_PATH = "/META-INF/maven/plugin.xml";
// ----------------------------------------------------------------------
// Mojo components
@@ -71,7 +69,7 @@ public class HelpMojo extends DescribeMo
public void execute()
throws MojoExecutionException
{
- final String pluginId = getpluginGA();
+ final String pluginId = "@GAV@"; // replaced by POM
Field f = null;
boolean isAccessible = true; // assume accessible
try
@@ -106,80 +104,6 @@ public class HelpMojo extends DescribeMo
// ----------------------------------------------------------------------
// Private methods
// ----------------------------------------------------------------------
- private String getpluginGA() throws MojoExecutionException {
- Document doc = build();
- Node plugin = getSingleChild( doc, "plugin" );
- String id = getValue( plugin, "groupId" ) + ":" + getValue( plugin,
"artifactId" );
- return id;
- }
-
- private Document build()
- throws MojoExecutionException
- {
- getLog().debug( "load plugin-help.xml: " + PLUGIN_PATH );
- InputStream is = getClass().getResourceAsStream( PLUGIN_PATH );
- try
- {
- DocumentBuilderFactory dbFactory =
DocumentBuilderFactory.newInstance();
- DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
- return dBuilder.parse( is );
- }
- catch ( IOException e )
- {
- throw new MojoExecutionException( e.getMessage(), e );
- }
- catch ( ParserConfigurationException e )
- {
- throw new MojoExecutionException( e.getMessage(), e );
- }
- catch ( SAXException e )
- {
- throw new MojoExecutionException( e.getMessage(), e );
- }
- finally
- {
- try {
- is.close();
- } catch (IOException e) {
- }
- }
- }
-
- private List<Node> findNamedChild( Node node, String elementName )
- {
- List<Node> result = new ArrayList<Node>();
- NodeList childNodes = node.getChildNodes();
- for ( int i = 0; i < childNodes.getLength(); i++ )
- {
- Node item = childNodes.item( i );
- if ( elementName.equals( item.getNodeName() ) )
- {
- result.add( item );
- }
- }
- return result;
- }
-
- private Node getSingleChild( Node node, String elementName )
- throws MojoExecutionException
- {
- List<Node> namedChild = findNamedChild( node, elementName );
- if ( namedChild.isEmpty() )
- {
- throw new MojoExecutionException( "Could not find " + elementName
+ " in plugin-help.xml" );
- }
- if ( namedChild.size() > 1 )
- {
- throw new MojoExecutionException( "Multiple " + elementName + " in
plugin-help.xml" );
- }
- return namedChild.get( 0 );
- }
-
- private String getValue( Node node, String elementName )
- throws MojoExecutionException
- {
- return getSingleChild( node, elementName ).getTextContent();
- }
// ----------------------------------------------------------------------
// Static methods