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

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!

About this issue

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

Most upvoted comments

@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)
+        } 
+    }
+}

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