maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stuart McCulloch <mccu...@gmail.com>
Subject Re: Residual package goal state affects outcome of Mojo definition in descriptor file.
Date Thu, 19 Dec 2013 15:47:04 GMT
On 19 Dec 2013, at 15:31, Jeremy Whiting <jwhiting@redhat.com> 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 <mojo> 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 Dec 19 10:17:23 GMT 2013
> [INFO] Final Memory: 18M/333M
> [INFO] ------------------------------------------------------------------------
> $ cat target/classes/META-INF/maven/plugin.xml
> <?xml version="1.0" encoding="UTF-8"?>
> 
> <!-- Generated by maven-plugin-tools 3.2 on 2013-12-19 -->
> 
> <plugin>
> .....
>  <mojos/>
> .....
> </plugin>
> $ cat target/classes/META-INF/maven/org.hibernate.orm.tooling/hibernate-enhance-maven-plugin/plugin-help.xml

> <?xml version="1.0" encoding="UTF-8"?>
> 
> <!-- Generated by maven-plugin-tools 3.2 on 2013-12-19 -->
> 
> <plugin>
>  <name>Enhance Plugin of the Hibernate project for use with Maven build system.</name>
>  <description></description>
>  <groupId>org.hibernate.orm.tooling</groupId>
> <artifactId>hibernate-enhance-maven-plugin</artifactId>
>  <version>4.2.8.Final</version>
>  <goalPrefix>hibernate-enhance</goalPrefix>
>  <mojos/>
> </plugin>
> $
> 
> Example 2)
> 
> $ mvn clean package 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] --- 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 1 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] Nothing to compile - all classes are up to date
> [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]
> [INFO] --- maven-plugin-plugin:3.2:addPluginArtifactMetadata (default-addPluginArtifactMetadata)
@ hibernate-enhance-maven-plugin ---
> [INFO] ------------------------------------------------------------------------
> [INFO] BUILD SUCCESS
> [INFO] ------------------------------------------------------------------------
> [INFO] Total time: 5.049s
> [INFO] Finished at: Thu Dec 19 10:17:41 GMT 2013
> [INFO] Final Memory: 21M/578M
> [INFO] ------------------------------------------------------------------------
> $ cat target/classes/META-INF/maven/plugin.xml
> <?xml version="1.0" encoding="UTF-8"?>
> 
> <!-- Generated by maven-plugin-tools 3.2 on 2013-12-19 -->
> 
> <plugin>
> ......
>  <mojos>
>    <mojo>
>      <goal>enhance</goal>
>      <description>This plugin will enhance Entity objects.</description>
> <requiresDirectInvocation>false</requiresDirectInvocation>
>      <requiresProject>true</requiresProject>
>      <requiresReports>false</requiresReports>
>      <aggregator>false</aggregator>
>      <requiresOnline>false</requiresOnline>
>      <inheritedByDefault>true</inheritedByDefault>
>      <phase>compile</phase>
>      <executePhase>compile</executePhase>
>      <executeGoal>enhance</executeGoal>
> <implementation>org.hibernate.bytecode.enhance.plugins.MavenEnhancePlugin</implementation>
>      <language>java</language>
> <instantiationStrategy>per-lookup</instantiationStrategy>
> <executionStrategy>once-per-session</executionStrategy>
>      <threadSafe>false</threadSafe>
>      <parameters>
>        <parameter>
>          <name>dir</name>
>          <type>java.lang.String</type>
>          <required>false</required>
>          <editable>true</editable>
>          <description></description>
>        </parameter>
>      </parameters>
>      <configuration>
>        <dir implementation="java.lang.String" default-value="${project.build.outputDirectory}">${dir}</dir>
>      </configuration>
>    </mojo>
>  </mojos>
> ....
> </plugin>
> $ cat target/classes/META-INF/maven/org.hibernate.orm.tooling/hibernate-enhance-maven-plugin/plugin-help.xml

> <?xml version="1.0" encoding="UTF-8"?>
> 
> <!-- Generated by maven-plugin-tools 3.2 on 2013-12-19 -->
> 
> <plugin>
>  <name>Enhance Plugin of the Hibernate project for use with Maven build system.</name>
>  <description></description>
>  <groupId>org.hibernate.orm.tooling</groupId>
> <artifactId>hibernate-enhance-maven-plugin</artifactId>
>  <version>4.2.8.Final</version>
>  <goalPrefix>hibernate-enhance</goalPrefix>
>  <mojos>
>    <mojo>
>      <goal>enhance</goal>
>      <description>This plugin will enhance Entity objects.</description>
> <requiresDirectInvocation>false</requiresDirectInvocation>
>      <requiresProject>true</requiresProject>
>      <requiresReports>false</requiresReports>
>      <aggregator>false</aggregator>
>      <requiresOnline>false</requiresOnline>
>      <inheritedByDefault>true</inheritedByDefault>
>      <phase>compile</phase>
>      <executePhase>compile</executePhase>
>      <executeGoal>enhance</executeGoal>
> <implementation>org.hibernate.bytecode.enhance.plugins.MavenEnhancePlugin</implementation>
>      <language>java</language>
> <instantiationStrategy>per-lookup</instantiationStrategy>
> <executionStrategy>once-per-session</executionStrategy>
>      <threadSafe>false</threadSafe>
>      <parameters>
>        <parameter>
>          <name>dir</name>
>          <type>java.lang.String</type>
>          <required>false</required>
>          <editable>true</editable>
>          <description></description>
>        </parameter>
>      </parameters>
>      <configuration>
>        <dir implementation="java.lang.String" default-value="${project.build.outputDirectory}">${dir}</dir>
>      </configuration>
>    </mojo>
>  </mojos>
> </plugin>
> $
> 
> I would have expected the Mojo definition to be generated the first time the package
goal is executed. Is this not supposed to work first time round ?
> 
> Regards,
> Jeremy
> 
> $ java -version
> java version "1.7.0_45"
> OpenJDK Runtime Environment (fedora-2.4.3.0.fc19-x86_64 u45-b15)
> OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)
> $ mvn -version
> Apache Maven 3.0.4 (r1232337; 2012-01-17 08:44:56+0000)
> Maven home: /home/whitingjr/java/apache/maven/apache-maven-3.0.4
> Java version: 1.7.0_45, vendor: Oracle Corporation
> Java home: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.60-2.4.3.0.fc19.x86_64/jre
> Default locale: en_GB, platform encoding: UTF-8
> OS name: "linux", version: "3.11.10-200.fc19.x86_64", arch: "amd64", family: "unix"
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Mime
View raw message