[MCOMPILER-1006] Fix <proc>only</proc> not triggering annotation processors#1017
[MCOMPILER-1006] Fix <proc>only</proc> not triggering annotation processors#1017Manas-Dikshit wants to merge 7 commits intoapache:masterfrom
Conversation
|
please fix formatting |
|
fixed. |
| * Base class of Mojos compiling Java source code. | ||
| * This plugin uses the {@link JavaCompiler} interface from JDK 6+. | ||
| * Each instance shall be used only once, then discarded. | ||
| * Base class of Mojos compiling Java source code. This plugin uses the |
There was a problem hiding this comment.
please revert this unnecesary changes to javadocs here and bellow.
There was a problem hiding this comment.
I would add that the previous formatting was intentional. We try to change lines after a natural separator such as a dot, or a comma if the line is too long. This is because in commits, changes are shown on a line-by-line basis. When sentences are on their own line, then if (for example) the sentence "Base class of Mojos…" is changed, it is easier to see that the "This plugin uses…" sentence is not modified.
|
avoid changing javadocs comments if not needed. |
|
Also add test that will show problem described in #1006 |
Added a fix to ensure that annotation processors only run when specified.
|
I have restored the previous code and only changed what i want to, means where the Maven Compiler Plugin did not execute annotation processors properly when only was set. The main thing is i actually formatted the code in the code editor not used the formatting command. making sure that it is now ready for review. |
| throw new CompilationFailureException("I/O error while compiling the project.", e); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Keep blank line between methods.
|
According this runner, this pull request does not compile. |
Updated the condition to check 'proc' from compilerConfiguration instead of configuration.
| compile(compiler, configuration); | ||
| return; | ||
| } | ||
| // ------------------------------------------------------------------------------- |
There was a problem hiding this comment.
Just looking for the first time at this pull request seriously (my previous comment was only formatting). What is the purpose of this addition? It does exactly the same thing as before — just invoking compiler(compiler, configuration) — with only a log added.
|
I appreciate your time in reviewing this code. I want to clarify that the intent of this patch is not just to add a log but to ensure that the compiler will run when only is set. |
|
If we remove the whole |
|
You are right, @desruisseaux. The current structure of the if (“only”.equalsIgnoreCase(compilerConfiguration.getProc())) block appears redundant, but it still executes compile(compiler, configuration) just like the next line. |
Summary
This PR fixes issue #1006, where the Maven Compiler Plugin did not execute annotation processors properly when
<proc>only</proc>was set. Previously, the plugin exited early with the message "Nothing to compile - all classes are up to date," which stopped annotation processors from running.Changes
execute()method to make sure that when<proc>only</proc>is set, the compiler runs even if no Java source files have changed.Rationale
Annotation processors like Log4j’s
PluginProcessormust run independently of source compilation. This change makes the plugin behave likejavac -proc:onlyand clears up confusion from misleading log messages.Impact
<proc>only</proc>.Verification
target/generated-sources/annotations.mvn -Prun-its verify.Please review and let me know if you want me to add an integration test for this specific use case.