[
https://issues.apache.org/jira/browse/MCOMPILER-538?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17798711#comment-17798711
]
zosrothko commented on MCOMPILER-538:
-------------------------------------
Hello
I do not have any annotation in a small multmodule maven project and the error
below is blocking the full maven rebuild
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:3.12.0:testCompile
(default-testCompile) on project entitymodule: Fatal error compiling: basedir
C:\MXW\Clients\SwissLife\ArchieV3\DEV\Modules\multimodulemavenproject\entitymodule\target\generated-test-sources\test-annotations
does not exist -> [Help 1]
[E
Below the javac command line from: mvn clean install -X
[DEBUG] Using compiler 'javac'.
[DEBUG] Adding
C:\MXW\Modules\multimodulemavenproject\entitymodule\target\generated-test-sources\test-annotations
to test-compile source roots:
C:\MXW\Modules\multimodulemavenproject\entitymodule\src\test\java
[DEBUG] New test-compile source roots:
C:\MXW\Modules\multimodulemavenproject\entitymodule\src\test\java
C:\MXW\Modules\multimodulemavenproject\entitymodule\target\generated-test-sources\test-annotations
[DEBUG] CompilerReuseStrategy: reuseCreated
[DEBUG] useIncrementalCompilation enabled
[INFO] New dependency detected:
C:\MXW\Modules\multimodulemavenproject\entitymodule\target\classes\com\baeldung\entity\User.class
[INFO] Recompiling the module because of changed dependency.
[DEBUG] Classpath:
[DEBUG] C:\MXW\Modules\multimodulemavenproject\entitymodule\target\test-classes
[DEBUG] Modulepath:
[DEBUG] C:\MXW\Modules\multimodulemavenproject\entitymodule\target\classes
[DEBUG] Source roots:
[DEBUG] C:\MXW\Modules\multimodulemavenproject\entitymodule\src\test\java
[DEBUG]
C:\MXW\Modules\multimodulemavenproject\entitymodule\target\generated-test-sources\test-annotations
[DEBUG] Command line options:
[DEBUG] -d
C:\MXW\Modules\multimodulemavenproject\entitymodule\target\test-classes
-classpath
C:\MXW\Modules\multimodulemavenproject\entitymodule\target\test-classes;
--module-path
C:\MXW\Modules\multimodulemavenproject\entitymodule\target\classes;
-sourcepath
C:\MXW\Modules\multimodulemavenproject\entitymodule\src\test\java;C:\MXW\Modules\multimodulemavenproject\entitymodule\target\generated-test-sources\test-annotations;
-s
C:\MXW\Modules\multimodulemavenproject\entitymodule\target\generated-test-sources\test-annotations
-g --release 11 -encoding UTF-8
--patch-module
com.baeldung.entitymodule=C:\MXW\Modules\multimodulemavenproject\entitymodule\target\classes;C:\MXW\Modules\multimodulemavenproject\entitymodule\src\test\java;C:\MXW\Modules\multimodulemavenproject\entitymodule\target\generated-test-sources\test-annotations;
--add-reads com.baeldung.entitymodule=ALL-UNNAMED
-XDuseUnsharedTable=true
> Do not add target/generated-sources/annotations to the source roots
> -------------------------------------------------------------------
>
> Key: MCOMPILER-538
> URL: https://issues.apache.org/jira/browse/MCOMPILER-538
> Project: Maven Compiler Plugin
> Issue Type: Bug
> Affects Versions: 3.11.0
> Reporter: Daniel Mensinger
> Assignee: Slawomir Jaranowski
> Priority: Major
> Fix For: next-release
>
>
> Adding the generated source root ({{target/generated-sources/annotations}})
> is not required for javac. Additionally adding the generated source root
> results in compilation errors with annotation processors generating code
> unless the generated-sources dir is cleaned.
> Specifically, the following steps result in compilation errors:
> # run {{mvn clean}}
> # Modify a source file that is consumed by the annotation processor so that
> there is a compilation error, but the annotation processor still runs (add or
> remove a parameter in a method call).
> # run {{mvn compile}} --> the generated file exists but there is no class
> file for the source file.
> # Fix the "bug" from step 2
> # run {{mvn compile}} again --> compilation should succeed, but it fails.
> ----
> Example code:
> [https://github.com/mensinda/quarkus-stuff/tree/annotationProcessingTest]
> Use the {{annotationProcessingTest}} branch!
> For step 2 this change can be used:
> {code:java}
> diff --git a/code/src/main/java/bar/MyAnnotatedClass.java
> b/code/src/main/java/bar/MyAnnotatedClass.java
> index bbfef7a..a303924 100644
> --- a/code/src/main/java/bar/MyAnnotatedClass.java
> +++ b/code/src/main/java/bar/MyAnnotatedClass.java
> @@ -4,7 +4,7 @@ import foo.MyAnnotation;
> @MyAnnotation
> public class MyAnnotatedClass {
> - MyGeneratedClass generatedClass = new MyGeneratedClass();
> + MyGeneratedClass generatedClass = new MyGeneratedClass(false);
> // foo
> {code}
>
> To see that *not* adding {{target/generated-sources/annotations}} helps run
> {{mvn -X compile}} and copy the {{Command line options:}}. Then run {{javac}}
> manually, but remove the {{target/generated-sources/annotations}} from the
> {{-sourcepath}} list, but *not* the {{-s}} parameter.
> ----
> PR with a fix: https://github.com/apache/maven-compiler-plugin/pull/191
--
This message was sent by Atlassian Jira
(v8.20.10#820010)