3
  • I'm using Project Lombok, a (spurious) JSR 269 implementation providing useful features like the generation of getters and setters at compile time while keeping the source code clean:

    @Getter @Setter private String foo;
    
  • I'd like to use another annotation processor (a JSR 269 implementation like hibernate-jpamodelgen) to generate the JPA Canonical Metamodel (JSR 317), but no matter how hard I try (Maven, Eclipse, etc...) it does seem that there is no way to instruct it to start reading the entities from the generated code, instead that from the source (that, being not yet interpreted by Lombok, does not even compile).

Is there a way to pipe the two annotation processors in the way needed?

Community
  • 1
  • 1
Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
  • 2
    I think [this question](http://stackoverflow.com/q/29193806/1743880) is about the same problem (ordering of annotation processors). – Tunaki Oct 13 '15 at 13:16
  • I actually have no idea if it is solvable or not (just read the target post). But, I think this should be closed as duplicate of the other question, do you agree? – Tunaki Oct 13 '15 at 13:36
  • @Tunaki I think that this question is not duplicate of [that](https://stackoverflow.com/questions/29193806/specifying-order-of-annotation-processors). I can suggest a solution for _this_ question: add `@Access(AccessType.FIELD)` annotation for entity class. But it not suitable for _that_ question. – Tarwirdur Turon Feb 22 '18 at 17:06
  • 2
    The solution to this post worked for me: https://stackoverflow.com/questions/44602317/cant-build-maven-jhipster-project-with-lombok – N Dierauf Jan 17 '19 at 20:02
  • Thank you for posting your comment here, @NDierauf! – Andrea Ligios Jan 17 '19 at 22:06

1 Answers1

2

You might be able to configure your build to first run delombok on your source files and compile the rest later.

Disclosure: I am a lombok developer.

Roel Spilker
  • 32,258
  • 10
  • 68
  • 58
  • Thank you. Could you expand a bit about its usage ? It seems (at least for the Maven plugin) that I should move all my Lombok-annotated Java files from `src/main/java` to `src/main/lombok`, but I'm still not sure how nor why the second annotation processor should find the delomboked files, since my entities (from which the metamodel would be generated) *are* Lombok-annotated and hence would be in `src/main/lombok`. As it seems, it could work to separate Lombok files and make other AP work on the non-lombok files, but does it work for Lombok annotated files too ? Sorry if I'm not clear enough – Andrea Ligios Oct 14 '15 at 09:32
  • You don't need to separate the lomboked files from the non-lomboked files. Delombok is capable of handling non-lomboked files as well. I am not familiar with the maven plugin myself. However, it could by that by default is processes the `src/main/lombok` directory, but I expect that that's configurable. – Roel Spilker Oct 14 '15 at 15:31