On 19 Dec 2013, at 15:31, Jeremy Whiting wrote:
> Hi,
> I am using the maven-plugin-plugin for a hibernate project to provide a user
> plugin. I am finding the Mojo definition is not generated. I found a
> workaround for the issue. This discussion is related to the issue discussed
> here
> http://mail-archives.apache.org/mod_mbox/maven-users/201303.mbox/ajax/%3C201303081348.35442.thomas%40koch.ro%3E
>
> I'm using Java5 annotations to define things like the goal and lifecycle
> phase. There are no parameters for the Mojo. These are the only annotations
> defined in the Mojo.
>
> ...
> @Mojo ( name="enhance", defaultPhase = LifecyclePhase.COMPILE )
> @Execute ( goal ="enhance" , phase = LifecyclePhase.COMPILE )
> public class MavenEnhancePlugin extends AbstractMojo implements
> EnhancementContext {
> ...
>
> I've found the two descriptor files generated can be generated either with or
> without a Mojo definition. Depending on the execution of the goal 'package'
> happening sequentially once or twice. Two examples are provided to
> demonstrate this.
> These are two descriptor files referred to.
>
> META-INF/maven/plugin.xml
> META-INF/maven/org.hibernate.orm.tooling/hibernate-enhance-maven-plugin/plugin-help.xml
>
> For comparison here is command line output. Some of it is omitted for
> brevity. You'll notice in "Example 2" after the second package goal execution
> there is a tag in the descriptor.
Based on the log output below this looks like
http://jira.codehaus.org/browse/MNG-5346
ie. the descriptor goal is running before the classes are compiled, and the
Java5 annotation extractor works off the classes.
You’ll need to update your plugin configuration to look like the example in
this link:
http://maven.apache.org/plugin-tools/maven-plugin-plugin/examples/using-annotations.html
ie. add additional executions to run the descriptor goal after the classes have
been compiled.
> Example 1)
>
> $ mvn clean package -DskipTests
> [INFO] Scanning for projects...
> [INFO]
> [INFO]
>
> [INFO] Building Enhance Plugin of the Hibernate project for use with Maven
> build system. 4.2.8.Final
> [INFO]
>
> [INFO]
> [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @
> hibernate-enhance-maven-plugin ---
> [INFO] Deleting
> /run/media/whitingjr/theark/work/redhat/java/jboss/hibernate/hibernate-orm/hibernate-enhance-maven-plugin/target
> [INFO]
> [INFO] --- maven-plugin-plugin:3.2:descriptor (default-descriptor) @
> hibernate-enhance-maven-plugin ---
> [INFO] Using 'UTF-8' encoding to read mojo metadata.
> [INFO] Applying mojo extractor for language: java-annotations
> [INFO] Mojo extractor for language: java-annotations found 0 mojo descriptors.
> [INFO] Applying mojo extractor for language: java
> [INFO] Mojo extractor for language: java found 0 mojo descriptors.
> [INFO] Applying mojo extractor for language: bsh
> [INFO] Mojo extractor for language: bsh found 0 mojo descriptors.
> [INFO]
> [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @
> hibernate-enhance-maven-plugin ---
> [debug] execute contextualize
> [INFO] Using 'UTF-8' encoding to copy filtered resources.
> [INFO] Copying 3 resources
> [INFO]
> [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @
> hibernate-enhance-maven-plugin ---
> [INFO] Compiling 1 source file to
> /run/media/whitingjr/theark/work/redhat/java/jboss/hibernate/hibernate-orm/hibernate-enhance-maven-plugin/target/classes
> [INFO]
> [INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @
> hibernate-enhance-maven-plugin ---
> [debug] execute contextualize
> [INFO] Using 'UTF-8' encoding to copy filtered resources.
> [INFO] skip non existing resourceDirectory
> /run/media/whitingjr/theark/work/redhat/java/jboss/hibernate/hibernate-orm/hibernate-enhance-maven-plugin/src/test/resources
> [INFO]
> [INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @
> hibernate-enhance-maven-plugin ---
> [INFO] No sources to compile
> [INFO]
> [INFO] --- maven-surefire-plugin:2.10:test (default-test) @
> hibernate-enhance-maven-plugin ---
> [INFO] Tests are skipped.
> [INFO]
> [INFO] --- maven-jar-plugin:2.3.1:jar (default-jar) @
> hibernate-enhance-maven-plugin ---
> [INFO] Building jar:
> /run/media/whitingjr/theark/work/redhat/java/jboss/hibernate/hibernate-orm/hibernate-enhance-maven-plugin/target/hibernate-enhance-maven-plugin-4.2.8.Final.jar
> [INFO]
> [INFO] --- maven-plugin-plugin:3.2:addPluginArtifactMetadata
> (default-addPluginArtifactMetadata) @ hibernate-enhance-maven-plugin ---
> [INFO]
>
> [INFO] BUILD SUCCESS
> [INFO]
>
> [INFO] Total time: 4.005s
> [INFO] Finished at: Thu De