From 570bb47130c78f0242cdbf970e8893b8f7b38488 Mon Sep 17 00:00:00 2001 From: Dennis Lundberg Date: Mon, 5 Nov 2012 20:50:43 +0000 Subject: [PATCH] [MPLUGIN-223] HelpMojo is not extracted when using java-annotations extractor - Add an IT to verify that this issue has been solved git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1405948 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/it/mplugin-223/invoker.properties | 15 ++++ .../src/it/mplugin-223/pom.xml | 84 +++++++++++++++++++ .../maven/plugins/plugin/it/MyMojo.java | 81 ++++++++++++++++++ .../src/it/mplugin-223/verify.groovy | 28 +++++++ 4 files changed, 208 insertions(+) create mode 100644 maven-plugin-plugin/src/it/mplugin-223/invoker.properties create mode 100644 maven-plugin-plugin/src/it/mplugin-223/pom.xml create mode 100644 maven-plugin-plugin/src/it/mplugin-223/src/main/java/org/apache/maven/plugins/plugin/it/MyMojo.java create mode 100644 maven-plugin-plugin/src/it/mplugin-223/verify.groovy diff --git a/maven-plugin-plugin/src/it/mplugin-223/invoker.properties b/maven-plugin-plugin/src/it/mplugin-223/invoker.properties new file mode 100644 index 0000000..adce2cd --- /dev/null +++ b/maven-plugin-plugin/src/it/mplugin-223/invoker.properties @@ -0,0 +1,15 @@ +# 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. +invoker.goals.1 = clean verify -DskipTests diff --git a/maven-plugin-plugin/src/it/mplugin-223/pom.xml b/maven-plugin-plugin/src/it/mplugin-223/pom.xml new file mode 100644 index 0000000..9272025 --- /dev/null +++ b/maven-plugin-plugin/src/it/mplugin-223/pom.xml @@ -0,0 +1,84 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.plugin.its + massembly-223 + 1.0-SNAPSHOT + maven-plugin + + massembly-223 Maven Plugin + http://maven.apache.org + + + @project.version@ + UTF-8 + + + + + org.apache.maven + maven-plugin-api + 2.2.1 + + + org.apache.maven.plugin-tools + maven-plugin-annotations + ${mavenPluginPluginVersion} + provided + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.4 + + + org.apache.maven.plugins + maven-plugin-plugin + ${mavenPluginPluginVersion} + + + java-annotations + + true + + + + mojo-descriptor + + descriptor + + + + help-goal + + helpmojo + + + + + + + diff --git a/maven-plugin-plugin/src/it/mplugin-223/src/main/java/org/apache/maven/plugins/plugin/it/MyMojo.java b/maven-plugin-plugin/src/it/mplugin-223/src/main/java/org/apache/maven/plugins/plugin/it/MyMojo.java new file mode 100644 index 0000000..14c7b92 --- /dev/null +++ b/maven-plugin-plugin/src/it/mplugin-223/src/main/java/org/apache/maven/plugins/plugin/it/MyMojo.java @@ -0,0 +1,81 @@ +package org.apache.maven.plugins.plugin.it; + +/* + * 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 org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +/** + * Goal which touches a timestamp file. + */ +@Mojo(name = "touch", defaultPhase = LifecyclePhase.PROCESS_RESOURCES) +public class MyMojo + extends AbstractMojo +{ + /** + * Location of the file. + */ + @Parameter(defaultValue = "${project.build.directory}", required = true) + private File outputDirectory; + + public void execute() + throws MojoExecutionException + { + File f = outputDirectory; + + if ( !f.exists() ) + { + f.mkdirs(); + } + + File touch = new File( f, "touch.txt" ); + + FileWriter w = null; + try + { + w = new FileWriter( touch ); + + w.write( "touch.txt" ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Error creating file " + touch, e ); + } + finally + { + if ( w != null ) + { + try + { + w.close(); + } + catch ( IOException e ) + { + // ignore + } + } + } + } +} diff --git a/maven-plugin-plugin/src/it/mplugin-223/verify.groovy b/maven-plugin-plugin/src/it/mplugin-223/verify.groovy new file mode 100644 index 0000000..9091497 --- /dev/null +++ b/maven-plugin-plugin/src/it/mplugin-223/verify.groovy @@ -0,0 +1,28 @@ +/* + * 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. + */ + +File descriptorFile = new File( basedir, "target/classes/META-INF/maven/plugin.xml" ); +assert descriptorFile.isFile() + +def pluginDescriptor = new XmlParser().parse( descriptorFile ); + +def mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "help" }[0] + +// check help mojo plugin descriptor +assert mojo != null + +return true;