question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

annotation processor of mapstruct can not generate Impl class in vscode.

See original GitHub issue

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!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:31 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
snjezacommented, Apr 12, 2021

@pumano could you try the following patch:

diff --git a/build.gradle b/build.gradle
index 18beeb8..965f6de 100644
--- a/build.gradle
+++ b/build.gradle
@@ -2,6 +2,7 @@ plugins {
        id 'org.springframework.boot' version '2.4.4'
        id 'io.spring.dependency-management' version '1.0.11.RELEASE'
        id 'java'
+       id 'eclipse'
 }
 
 group = 'com.example.vscode'
@@ -26,3 +27,14 @@ dependencies {
 test {
        useJUnitPlatform()
 }
+
+eclipse {
+    classpath {
+        containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
+        file.whenMerged { cp ->
+            def entries = cp.entries;
+            def src = new org.gradle.plugins.ide.eclipse.model.SourceFolder('build/generated/sources/annotationProcessor/java/main/', null)
+            entries.add(src)
+        } 
+    }
+}
1reaction
PandaGeek1024commented, Mar 27, 2021

works fine when building with gradle command, looks like mainly a vscode thing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

visual studio code - Using java MapStruct with VSCode
I found the solution: add @ComponentScan(basePackages = "com.api.demo/build/classes/java/main/com/api/demo/service/mapper") and it works (to ...
Read more >
IDE Support
To fully leverage this in your IDE, make sure the annotation processor runs with each compilation. Eclipse. Maven Integration. If you are working...
Read more >
mapstruct/mapstruct-users - Gitter
I want to create a configuration interface annotated with @Mapper and all the required attributes and then extend this mapper interface to my...
Read more >
Mapstruct Is Not Generating Implementation Classes
Why is it not possible for MapStruct to generate implementations for ... It uses annotationprocessing to generate mapper class implementations during If ...
Read more >
Lombok Changelog
Lombok will thus copy some of these new annotations e.g. to generated getters ... fail (lombok's old val implementation supported it, javac's var...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found