-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expose annotation processor and remove hider enclosing class #973
Comments
It's not really hidden, it's just been renamed. You're looking for:
If this is something more involved, then... we can't do much without more info on how @dave-lo fixed this issue. I don't even know what the issue is :/ parked for closing on January 1st 2016 without more feedback. |
Well goal is to be able to order procs using -proc of javac. AnnotationProcessorHider doesnt allow it ATM AFAIK |
I am hitting with this issue too. The problem for me is that a corporate parent pom has the compiler plugin configured with |
Can you tell us the platform you're using and the exact version of javac? On linux you need to make sure the
|
1.8u45 and u60 |
Windows, Linux, Mac. javac directly, Ant, Maven, Gradle? Did you try my suggestion? |
Linux or mac, mvn. Tried but never got a good ordering with other processors. edit: mvn doesnt quote the processors names so can be the issue: https://issues.apache.org/jira/browse/MCOMPILER-256 |
Could it be that Maven interpret the $ sign as a property? Try using the following:
|
Hi, as you know, I am working on MapStruct, an annotation processor for generating type-safe bean mappings. Users have been reporting issues when working with MapStruct and Lombok together in one project. These issues stem from the fact that MapStruct does not "see" the property accessors generated by Lombok, causing the MapStruct-generated mappers to be incomplete. In general, MapStruct needs to be prepared for the fact that other processors may add property accessors by generating super-classes of the processed types (that's a pattern foreseen in the JSR 269 architecture). At the moment we don't support that yet, but we can do so by examining the super-type mirror(s) of processed types and if those have type kind ERROR, defer processing of the sub-types to a future round, by which the missing super-types will have been generated. I hoped to do the same with Lombok-processed entities, but atm. I am lacking a way to decide whether a type has been fully amended or not (so MapStruct needs to defer its handling). So basically I am after something similar to checking the type kind of super-types as described above. I don't know how this could look like, but maybe you guys have any idea? |
I have an idea on how to fix this in general.
Possibly we can omit step 1 and 2 by using reflection to read and modify javac's internal structure. That would be the best for all users, but the Lombok processor should probably be invoked first, unless we can some serious hacking at class loading time. What do you think? Might/would this work? |
Will there be a solution in the near future for this bug? Would be great if lombok would work with MapStruct out of the box. :-) |
Any progress here, lombok + mapstruct is a wonderful integration for Spring Boot.Like jhipster use mapstruct for dto, and spring boot suggest use lombok for entity and data model.Due to this issue, we can not use lombok + mapstruct, that'a awful.So, please. |
I've been working around this issue by making a separate module for my lombok classes and compiling that module first. This stinks. I wish lombok and mapstruct were compatible with each other. After so long with no resolution, my team is trying to decide whether to rip out lombok or mapstruct so that we can consolidate the code. |
Any updates on this? I really like both MapStruct and Lombok but will have to drop one of them as splitting the project into multiple modules is not an option... |
I am running similar issue when using lombok and Selma, Selma can't see the getter/setter lombok generates using @DaTa. Don't like the idea splitting the project into separate modules to make this work. Querydsl and lombok have similar issue, the solution is to set processors including lombok and querydsl annotation processors. Similar solution should be possible for lombok and Selma. Here is the link for Querydsl and lombok issue: https://github.com/ewerk/gradle-plugins/issues/59 |
Most of the chat and implementation talk on this problem has been held on issue mapstruct/mapstruct#510. We've got a solution in place and will release it soon. |
Your release 1.16.14 says "Lombok can now be used together with other annotation processors that are looking for lombok-generated methods, but only if lombok is the first annotation processor executed. The most commonly used annotation processor affected by this change is MapStruct; we've worked with the mapstruct team specifically to allow any order. Other annotation processors might follow the framework we've built to make this possible; point the authors of any such processor to us and we'll get it sorted" I am attempting to make this upgrade on doanduyhai/Achilles#289 and am wondering if there is any documentation on what needs to be done to repeat what has been done here. |
Yes. We're implementing the AstModifyingAnnotationProcessor, and registered our implementation in META-INF/serviced. Any processor that needs to process AST's after lombok has done its work can query the |
You can find an example in the mapstruct code. |
Hey guys, I know this is a very old and closed issue. Sorry if this is not the best place to start a new conversation. In the end, I found a straightforward solution to define the order in which annotation processors must run, without requiring any source code changes. I just added <plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>5.0</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<processors>
<!-- Defines the order in wich the annotation processors must execute.
Lombok needs to be the first one, because if you are using it,
the generated DTOs may include Lombok's annotations
and may need the code generated by it (such as getters and setters). -->
<processor>lombok.launch.AnnotationProcessorHider$AnnotationProcessor</processor>
<processor>io.github.manoelcampos.dtogen.DTOProcessor</processor>
</processors>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
</dependency>
<dependency>
<groupId>io.github.manoelcampos</groupId>
<artifactId>dtogen</artifactId>
<version>1.0.7</version>
</dependency>
</dependencies>
</plugin> You can check the entire pom.xml here. I hope this information helps other developers. By the way, I've created a very cool library that uses annotations on an Entity class and automatically generates DTO records. You can check the DTOGen library here. |
Just an update for other users facing the same issue or defining the order of annotation processors. Anyway, the plugin is very old. Current version of the maven-compiler-plugin enables setting the annotation processors order as below: <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<encoding>UTF-8</encoding>
<annotationProcessorPaths>
<!-- Defines the order in which the annotation processors must execute.
Lombok needs to be the first one, because if you are using it,
the generated DTOs may include Lombok's annotations
and may need the code generated by it (such as getters and setters). -->
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<path>
<groupId>io.github.manoelcampos</groupId>
<artifactId>dtogen</artifactId>
<version>${dtogen.version}</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<arg>-processor</arg>
<arg>lombok.launch.AnnotationProcessorHider$AnnotationProcessor,io.github.manoelcampos.dtogen.DTOProcessor</arg>
</compilerArgs>
</configuration>
</plugin> |
That plugin is causing issues with JDK 21. Now it uses the good and old maven-compiler-plugin to define the order in which Lombok and DTOGen processors are executed. More details at projectlombok/lombok#973 Signed-off-by: Manoel Campos <[email protected]>
When mixing annotation processors it is super important to be able to control their execution order, today it is almost impossible to do it properly with lombok cause of the hider class.
Is it possible to try to make it more open?
Side note: here is one conflicting annotation processor for instance mapstruct/mapstruct#510
The text was updated successfully, but these errors were encountered: