Hi Jeremy,
problem is not in phase.
When I use EnhancementTask by maven-antrun-plugin on compile phase, code is enhanced with warnings.
Quote:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>Enhance domain classes</id>
<configuration>
<target>
<taskdef name="enhance"
classname="org.hibernate.tool.enhance.EnhancementTask">
<classpath>
<path refid="maven.compile.classpath" />
<path refid="maven.plugin.classpath" />
</classpath>
</taskdef>
<enhance>
<fileset dir="${project.build.outputDirectory}">
<include name="entity/*.class" />
</fileset>
</enhance>
</target>
</configuration>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Quote:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Hibernate Enhance by Maven Plugin Test 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The artifact junit:junit-dep:jar:4.11 has been relocated to junit:junit:jar:4.11
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ test-enhance-maven-plugin ---
[INFO] Deleting D:\Vlado\Development\Workspace\test-enhance-maven-plugin\target
[INFO]
[INFO] --- aspectj-maven-plugin:1.5:compile (default) @ test-enhance-maven-plugin ---
[WARNING] advice defined in org.springframework.scheduling.aspectj.AbstractAsyncExecutionAspect has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch]
[INFO]
[INFO] --- aspectj-maven-plugin:1.5:test-compile (default) @ test-enhance-maven-plugin ---
[WARNING] advice defined in org.springframework.orm.jpa.aspectj.JpaExceptionTranslatorAspect has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.scheduling.aspectj.AbstractAsyncExecutionAspect has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch]
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ test-enhance-maven-plugin ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ test-enhance-maven-plugin ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-antrun-plugin:1.7:run (Enhance domain classes) @ test-enhance-maven-plugin ---
[INFO] Executing tasks
main:
[enhance] Starting Hibernate EnhancementTask execution
[enhance] Unable to delete class file [Child.class]
[enhance] Unable to delete class file [Parent.class]
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.652s
[INFO] Finished at: Thu Dec 12 10:51:44 CET 2013
[INFO] Final Memory: 17M/222M
[INFO] ------------------------------------------------------------------------
When I use enhance-maven-plugin there are build errors.
Quote:
<plugin>
<groupId>org.hibernate</groupId>
<artifactId>enhance-maven-plugin</artifactId>
<version>${hibernate.version}</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
Quote:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Hibernate Enhance by Maven Plugin Test 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The artifact junit:junit-dep:jar:4.11 has been relocated to junit:junit:jar:4.11
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ test-enhance-maven-plugin ---
[INFO] Deleting D:\Vlado\Development\Workspace\test-enhance-maven-plugin\target
[INFO]
[INFO] --- aspectj-maven-plugin:1.5:compile (default) @ test-enhance-maven-plugin ---
[WARNING] advice defined in org.springframework.scheduling.aspectj.AbstractAsyncExecutionAspect has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch]
[INFO]
[INFO] --- aspectj-maven-plugin:1.5:test-compile (default) @ test-enhance-maven-plugin ---
[WARNING] advice defined in org.springframework.orm.jpa.aspectj.JpaExceptionTranslatorAspect has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.scheduling.aspectj.AbstractAsyncExecutionAspect has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch]
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ test-enhance-maven-plugin ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ test-enhance-maven-plugin ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- enhance-maven-plugin:4.2.8.Final:enhance (default) @ test-enhance-maven-plugin ---
[INFO] Started enhance plugin.....
[ERROR] Unable to enhance class [entity.Child]
org.hibernate.bytecode.enhance.EnhancementException: Unable to enhance persistent attribute [entity.Child:parent]
at org.hibernate.bytecode.enhance.spi.Enhancer.enhancePersistentAttribute(Enhancer.java:363)
at org.hibernate.bytecode.enhance.spi.Enhancer.enhancePersistentAttributes(Enhancer.java:342)
at org.hibernate.bytecode.enhance.spi.Enhancer.enhanceAsEntity(Enhancer.java:256)
at org.hibernate.bytecode.enhance.spi.Enhancer.enhance(Enhancer.java:242)
at org.hibernate.bytecode.enhance.spi.Enhancer.enhance(Enhancer.java:176)
at org.hibernate.bytecode.enhance.plugins.MavenEnhancePlugin.processEntityClassFile(MavenEnhancePlugin.java:145)
at org.hibernate.bytecode.enhance.plugins.MavenEnhancePlugin.processClassFile(MavenEnhancePlugin.java:132)
at org.hibernate.bytecode.enhance.plugins.MavenEnhancePlugin.execute(MavenEnhancePlugin.java:82)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
at org.codehaus.classworlds.Launcher.main(Launcher.java:46)
Caused by: javassist.NotFoundException: entity.Parent
at javassist.ClassPool.get(ClassPool.java:450)
at javassist.bytecode.Descriptor.toCtClass(Descriptor.java:592)
at javassist.bytecode.Descriptor.toCtClass(Descriptor.java:542)
at javassist.CtField.getType(CtField.java:371)
at org.hibernate.bytecode.enhance.spi.Enhancer.resolveAttributeTypeDescriptor(Enhancer.java:1087)
at org.hibernate.bytecode.enhance.spi.Enhancer.enhancePersistentAttribute(Enhancer.java:354)
... 29 more
[ERROR] Unable to delete class file [Parent.class]
[INFO] Enhance plugin completed.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.346s
[INFO] Finished at: Thu Dec 12 10:48:52 CET 2013
[INFO] Final Memory: 22M/217M
[INFO] ------------------------------------------------------------------------
I donĀ“t know how to attach the test project, so I can send you it by mail, if you want.
In output there you can see, that there is aspectj plugin used for compile time weaving, but without it, it is the same result.