[
http://opensource.atlassian.com/projects/hibernate/browse/METAGEN-45?page...
]
Hardy Ferentschik commented on METAGEN-45:
------------------------------------------
Changing the code to something like this seems to work:
{code}
public boolean process(final Set<? extends TypeElement> annotations, final
RoundEnvironment roundEnvironment) {
if ( roundEnvironment.processingOver() || annotations.size() == 0) {
return ALLOW_OTHER_PROCESSORS_TO_CLAIM_ANNOTATIONS;
}
if ( context.isPersistenceUnitCompletelyXmlConfigured() ) {
context.logMessage(
Diagnostic.Kind.OTHER,
"Skipping the processing of annotations since persistence unit is purely xml
configured."
);
return ALLOW_OTHER_PROCESSORS_TO_CLAIM_ANNOTATIONS;
}
Set<? extends Element> elements = roundEnvironment.getRootElements();
for ( Element element : elements ) {
if ( isJPAEntity( element ) ) {
context.logMessage( Diagnostic.Kind.OTHER, "Processing annotated class " +
element.toString() );
handleRootElementAnnotationMirrors( element );
}
}
createMetaModelClasses();
return ALLOW_OTHER_PROCESSORS_TO_CLAIM_ANNOTATIONS;
}
{code}
Note the {{annotations.size() == 0}} check. It seems that I get three calls of
{{process}}. If this round is not explicitly skipped the generated Java files will get not
compiled either. The final call is where {{roundEnvironment.processingOver() == true}}.
The question is where this middle call comes from and whether it really should be made.
Generated metamodel sources are not compiled in JDK 6
-----------------------------------------------------
Key: METAGEN-45
URL:
http://opensource.atlassian.com/projects/hibernate/browse/METAGEN-45
Project: Hibernate Metamodel Generator
Issue Type: Bug
Components: processor
Affects Versions: 1.0.0.Final, 1.1.0.CR1
Environment: jdk 1.6.0_22, maven-compiler-plugin 2.2+, Eclipse 3.5+
Reporter: Artem Troitskiy
Assignee: Hardy Ferentschik
I tried to generate metamodel classes during maven build as described in the
documentation (using automatic annotation processing in JDK 6) and noticed that metamodel
source files are generated but not compiled. I also see the same problem when I try to
configure metamodel generation in Eclipse as described in the documentation.
Googling around showed that many people face the same problem in both maven and Eclipse.
Further investigation showed that:
* Generated sources are compiled by maven when version of maven-compiler-plugin is below
2.2, and not compiled otherwise.
* This behaviour is related to {{TODO}} in
{{org/hibernate/jpamodelgen/test/util/CompilationTest.java}} - if I remove the second
compilation phase there, tests fail for the very same reason.
* Currently annotation processor generates metamodel sources at the final round of
annotation processing. However, when I modify
{{org/hibernate/jpamodelgen/JPAMetaModelEntityProcessor.java}} to generate metamodel at
the first round, tests pass and everything works fine in maven and Eclipse. It looks like
sources generated at the final round are not compiled.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira