-
Notifications
You must be signed in to change notification settings - Fork 193
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
Support for Mapstruct and Lombok #874
Comments
Support for |
It seems there is some compiler classpath isolation going on. I tried
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>mapstruct</artifactId>
<groupId>xyz</groupId>
<version>1.0</version>
<properties>
<m2e.apt.activation>jdt_apt</m2e.apt.activation>
<maven.compiler.fork>true</maven.compiler.fork>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<org.mapstruct.version>1.3.0.Final</org.mapstruct.version>
<org.projectlombok.version>1.18.6</org.projectlombok.version>
<org.springframework.version>4.3.23.RELEASE</org.springframework.version>
</properties>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>2.5.6</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-jdk8</artifactId>
<version>${org.mapstruct.version}</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${org.projectlombok.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>properties</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
<compilerArguments>
<javaAgentClass>lombok.launch.Agent</javaAgentClass>
</compilerArguments>
<compilerArgument>-J-Xbootclasspath/a:${org.mapstruct:mapstruct-processor:jar}</compilerArgument>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>3.3.0-01</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>2.5.6-02</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${org.projectlombok.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project> |
I tried with groovy-eclipse-compiler version 3.3.0-01 but still got errors ; strange I don't fall into the same case like you :
even with :
and : together in the plugin configuration. |
In my example, forking is set in the properties element: Annotation processor paths are optional; if not supplied the classpath is scanned. I tried with anno proc paths, but it did not help the class loading. You should not need to list lombok in the proc paths since the agent class is set explicitly. I would not suggest ever setting classpath compiler arg explicitly. You can add dependencies within the compiler's But I think there is a bug in ecj for apt classloading: https://youtrack.jetbrains.com/issue/IDEA-189760 I can try and debug when I get more time to confirm that the class loader is being closed and that's why it can't find processor classes. |
I can confirm that lombok and mapstruct can be used individually -- may have been known but wanted to have it on record. There are samples for both here: https://github.com/groovy/groovy-eclipse/tree/master/extras/groovy-eclipse-compiler-tests/src/it The combination of lombok and mapstruct is not working properly in ecj (basis of I can offer a couple of suggestions for you:
|
This discussion may be relevant as well: projectlombok/lombok#1359 |
Thank you for the information, |
I am running into the same issue. I hope in the future there will be support for lombok and mapstruct at the same time without any workarounds. I think I will try to move my code with dependencies on lombok and groovy-eclipse into a separate internal library where my main project will depend upon. Thanks for the good work! |
I would like to re-open the topic that has already been discussed, and related to compilation problems occuring when using the groovy-eclipse-commpiler, Mapstruct and Lomboc together.
Something is not clear for me when you combile these different components in a maven config.
Here is the maven config I use :
Versions specified :
java.version = 1.8
org.mapstruct.version = 1.3.0.Final
lombok.version = 1.18.6
With this config I run into the classnotfoundexception: org.mapstruct.ap.spi.AstModifyingAnnotationProcessor error.
If I add lombok.jar in the classpath argument for the compiler, like this for exemple :
...\repository\org\mapstruct\mapstruct-processor\1.3.0.Final/mapstruct-processor-1.3.0.Final
-> this time the compilation is ok but the mapper implementations are not generated by MapStruct !
Commenting or not the annotationProcessorPaths part does not change anything.
Is this still a bug in the groovy-eclipse-compiler plugin or did I miss something ?
The text was updated successfully, but these errors were encountered: