-
Notifications
You must be signed in to change notification settings - Fork 455
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
annotation processor of mapstruct can not generate Impl class in vscode. #1660
Comments
Please attach a sample project reproducing the issue |
I tested with a Maven project and it worked fine. Since you're using gradle, you might want to follow the instructions in http://dplatz.de/blog/2018/gradle-apt.html so that annotation processing configuration files can be generated by gradle |
It's my demo project. bin/ dir is generated by VSCODE and build/ dir is generated by "gradle build". bin/ dir does't generate DemoCopierImpl.class but build dir does. |
I have try in VSCODE,but it does't work, perhaps it works with Eclipse. |
your example doesn't even build from CLI:
|
https://github.com/yousetme/mapstruct-gradle-demo |
I have the same problem but I am using maven for the build. <dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>${mapstruct.version}</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</dependency> Here is a build plugin <plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>xxx</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>${java.version}</release>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
<compilerArgs>-Amapstruct.defaultComponentModel=spring</compilerArgs>
</configuration>
</plugin>
</plugins> No Impl class is generated. |
Still not available in VSCODE? |
got the same problem |
Getting the same problem, any updates? |
works fine when building with gradle command, looks like mainly a vscode thing. |
@PandaGeek1024 @pumano @chiragai could you attach a project example? |
@snjeza yes, I prepare repo for it: https://github.com/pumano/vscode-mapstruct-tests You got looks like path to |
@pumano could you try the following patch:
|
@snjeza wow! Works like a charm! Would be good to have it out of the box if possible. Ok for this simple project problem solved, but for multimodule gradle project - same problem. |
@pumano could you attach a multimodule project? |
Ok I will prepare it soon |
I have the same problem. When can you fix it? |
Hello everyone! I am happy to say I found a way to solve this. I got it working with Spring Boot + Lombok + Mapstruct with Maven Wrapper. The key is to put the mapstuct and mapstruct-processor as dependencies. Here is how the result pom.xml looks like.
|
@ad798 It's good, but how to solve this via gradle... |
Was this problem solved? I just got the same one. @chiragai Thanks |
yeah! |
I solved this problem by adding this dependency in my project module, while my project compiled succeessfully but didn't generate implementation classes. ` ` |
Hello, I am getting the same error when mapstruct generates impl class for my Mapper, one of the classes is not listed as import. Then if I open the impl class I'm able import the package, but mapstruct doesn't not import it during generation of the class and therefore the class could not be used. I'm using gradle and Intelij. Is there any updates or work done on this? |
I have the same problem but I am using gradle for the build. |
@javohircomunity I have managed to find a way to get this running by using in my interface the following annotation:
|
I haven't any import class, There are many String fields. |
*Impl.class didn't generate by vscode run , but it work well by gradle bootRun. So everytime I copy *Impl.class from build(gradle compile folder) to bin(vscode compile folder) by hand let vscode to run. |
@snjeza 's patch is fixing it: #1660 (comment) |
There also seems a specific setup where mapstruct doesnt build *Impl of abstract classes extending other classes. We have in our project one specific abstract class which doesnt get an *Impl class, but in IntelliJ it does. As soon as I remove the "extends from", the *Impl is created. I've not come around to investigate this and create a sample project, but I'll update here as soon as I have a better bug report. |
Mapstruct has supported IDEA and eclipse to generate copier class automatically,but VSCODE doesn't work.
https://mapstruct.org/documentation/ide-support/
Steps To Reproduce
1.define java class
@Mapper(componentModel = "spring")
public interface AccountingFlowDtoCopier extends ObjectCopier<AccountingFlow, AccountingFlowDto> {
}
2.
gradle build
works and generate AccountingFlowDtoCopierImpl.class to {projectRootDir}/build dir.2.VSCODE compile file to {projectRootDir}/bin dir and AccountingFlowDtoCopierImpl.class can not generate.
is there some magic? thank!
The text was updated successfully, but these errors were encountered: