[hibernate-dev] Annotation Processors

Steve Ebersole steve at hibernate.org
Mon Dec 2 12:12:59 EST 2013


Well technically it is not valid according to the javac spec, which was 
David's point (which I assume who you are referring to).  And in fact 
we get a slew of errors from running `javac -proc:only`.  We just 
happen to eat/ignore them.

For example, take hibernate-core as it is the more "complex".  There we 
generate:
1) Antlr sources - non apt
2) Jaxb sources - non apt
3) JBoss Logging - apt

By the time we get to `javac -proc:only` for #3 javac errors out 
validly in cases were the source being processed references either the 
Antlr or the Jaxb generated sources.  It just happens to work here 
because JBoss Logging is never needing to process any of the sources 
that javac throws out (prior to even calling the AP).

Take hibernate-envers as another example.  There we generate:
1) JBoss Logging - apt
2) JPA metamodel generator - apt

Again this "works" because we happen to ignore the errors from javac.

But imagine that hibernate-envers instead did:
1) Jaxb - non apt
2) JBoss Logging - apt
3) JPA metamodel generator - apt

and further say that one or more of the sources that JPA metamodel 
generator needs to process reference classes that come from sources 
generated by Jaxb.  What would happen is that javac would immediately 
log that error and stop processing that source file before the JPA 
metamodel generator had a chance to see it.  This is where what we do 
breaks down.

In  general we are just lucky that it works for us ;)



On Mon 02 Dec 2013 10:46:20 AM CST, Hardy Ferentschik wrote:
>
> On 2 Jan 2013, at 16:07, Steve Ebersole <steve at hibernate.org> wrote:
>
>> So I am also working on reverting the change to use -proc:both with a
>> single compile phase.  However,  what we will end up with is still a
>> single -proc:only phase no matter how many processors are run.  They
>> will output to a unified directory
>
> +1 I have always said, that at least the processors should run in a dedicated phase.
> Happy to let them all run at the same time.
>
> Funny enough there are people there seems to be people who claim that this is not a
> valid setup ;-)
>
>> (${buildDir}/generated-src/apt/${sourceSet.name}) and will still give
>> us a single command up from to generateSources.
>
> sounds good
>


More information about the hibernate-dev mailing list