GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [MPOM-453] Disable annotation processing by compiler by slawekjaranowski · Pull Request #157 · apache/maven-parent

Conversation

@slawekjaranowski

@slawekjaranowski slawekjaranowski commented Jan 14, 2024

Copy link
Copy Markdown
Member

No description provided.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@cstamas

cstamas commented Jan 14, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This can be a problem, as no way to override this later (only in java 20? "full"?) @bmarwell will tell 😄

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@slawekjaranowski

slawekjaranowski commented Jan 14, 2024

Copy link
Copy Markdown
Member Author

We use sisu-maven-plugin for generating list of components, so should be ok.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@slawekjaranowski
slawekjaranowski requested review from bmarwell, cstamas and kwin January 15, 2024 20:53
@cstamas

cstamas commented Jan 15, 2024

Copy link
Copy Markdown
Member

With a grain of salt... I'd rather define compiler.proc=none property and allow that property to be changed, than this. As if project DOES need annotation processing, and is below Java 21 (see https://bugs.openjdk.org/browse/JDK-8309870) then there is no way to override it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kwin

kwin commented Jan 15, 2024

Copy link
Copy Markdown
Member

I think it is best practice to only enable annotation processors by their fully qualified class name. This is possible by setting https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#annotationProcessors. This should IMHO take precedence (but I haven’t checked) over proc being none.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@slawekjaranowski

slawekjaranowski commented Jan 16, 2024

Copy link
Copy Markdown
Member Author

I need more tests ... like possibility to override

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@slawekjaranowski
slawekjaranowski marked this pull request as draft January 16, 2024 09:08
@bmarwell

bmarwell commented Jan 19, 2024

Copy link
Copy Markdown
Contributor

We could introduce a property, eg maven.compiler.apt.default or similar. Easy to override per project via .mvn/jvm.options.

I think the way to go is to introduce a new default lifecycle in the compiler plugin in both the compile and test compile Mojos.

This means running a new execution default-process in generate-sources with -proc:only and running a new execution default-test-process in generate-test-sources.

I do this in all of my projects like this.

However, not sure how incremental works with this proposal.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@slawekjaranowski

slawekjaranowski commented Jan 20, 2024

Copy link
Copy Markdown
Member Author
  • m-compiler-p proc parameter doesn't have a property
  • we can use property which can be overridded by empty value, to achieve default behavior, in child project
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@slawekjaranowski
slawekjaranowski marked this pull request as ready for review January 20, 2024 11:17
slachiewicz
slachiewicz approved these changes Jan 20, 2024
View reviewed changes
bmarwell
bmarwell approved these changes Jan 21, 2024
View reviewed changes

@bmarwell bmarwell left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me as of now. Maybe we can look into a project using an annotation processor to make use of the two phases I mentioned and see what we get from it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
kwin
kwin approved these changes Jan 25, 2024
View reviewed changes

@kwin kwin left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but would appreciate some comment in the code for the property

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pom.xml Resolved

Uh oh!

There was an error while loading. Please reload this page.

slawekjaranowski added 3 commits January 27, 2024 10:44
@slawekjaranowski
[MPOM-453] Disable annotation processing by compiler
a20af06
@slawekjaranowski
[MPOM-453] use property
d1aec72
@slawekjaranowski
[MPOM-453] add comment
434d558
@slawekjaranowski
slawekjaranowski force-pushed the MPOM-453 branch from 0ad1425 to 434d558 Compare January 27, 2024 09:47
@slawekjaranowski
slawekjaranowski merged commit 7e2a52b into master Jan 27, 2024
@slawekjaranowski
slawekjaranowski deleted the MPOM-453 branch January 27, 2024 10:08
@slawekjaranowski slawekjaranowski added this to the MAVEN-42 milestone Jan 27, 2024
@slawekjaranowski slawekjaranowski mentioned this pull request Mar 5, 2024
[MCOMPILER-548] JDK 21 throws annotations processing warning that can not be turned off apache/maven-compiler-plugin#200
Merged
7 tasks done
gemmellr
gemmellr reviewed Jun 25, 2024
View reviewed changes
Comment thread pom.xml
Comment on lines +948 to +949
<!-- in order to restore default annotation processing behaviour, please override with empty value -->
<maven.compiler.proc>none</maven.compiler.proc>

@gemmellr gemmellr Jun 25, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a trick to this 'override with empty value' instruction? I tried this general approach after seeing it described here, but haven't been able to get it to work. Using Maven 3.9.4 and compiler-plugin 3.13.0, when I try this I simply get: error: invalid flag: -proc:

Setting the maven.compiler.proc property in the parent disables implicit annotation processing as desired. Setting it again to empty (<maven.compiler.proc></maven.compiler.proc>) in a child pom to override that disabling does alter the property, however it then just causes an error from the compiler seemingly because it is simple being passed -proc bare which it doesnt accept, resulting in the error: invalid flag: -proc:

What am I missing?

(It works if I use "full" instead of empty for the child pom property override, but just as was discussed on this PR and the related one, I dont want to use "full" because of its reliance on recent JDK builds for the backported support of that value)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@kwin kwin Jun 25, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty values don't work unfortunately due to https://github.com/eclipse-sisu/sisu.plexus/issues/29.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@gemmellr gemmellr Jun 25, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little confused given it was you that had asked for the comment about empty override to be added hehe.

So it seems like the comment is really just wrong, and this approach of setting maven.compiler.proc to "none" in a parent is actually unworkable if you dont want to then have to set "full" as the property override value, and require everyone having updated JDKs < 21 with support for that value backported.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@slawekjaranowski slawekjaranowski Jun 25, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have configuration like:

<properties>
  <maven.compiler.proc>none</maven.compiler.proc>
</properties>

....

<configuration>
            <proc>${maven.compiler.proc}</proc>
</configuration>

is such case we can set empty value for property in child - it will work

such configuration in child

<configuration>
            <proc/>
</configuration>

will not work

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@slawekjaranowski slawekjaranowski Jun 25, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please try

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@gemmellr gemmellr Jun 25, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is one of a few variants I tried before asking (so is your example that wont work), and I believe is precisely what I was doing at the point when I commented earlier. I had also tried before that with just setting the property in the parent+child (i.e not explicitly configuring <proc> with its value), but had noticed you were using the value indirectly to set <proc> rather than just the property itself so I did then try that too.

I tried that version again now per your note to be sure, and it again netted only the error: invalid flag: -proc: failure.

Given it has been part of your parent pom for months, do you know if there is an actual instance of this in use somewhere in the maven project as example?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@slawekjaranowski slawekjaranowski Jun 25, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ups ...

% git diff
diff --git a/pom.xml b/pom.xml
index e5e60d9..2072a86 100644
--- a/pom.xml
+++ b/pom.xml
@@ -68,6 +68,7 @@
     <mavenVersion>3.6.3</mavenVersion>
     <resolverVersion>1.4.1</resolverVersion>
     <project.build.outputTimestamp>2024-06-02T15:17:10Z</project.build.outputTimestamp>
+    <maven.compiler.proc />
   </properties>
mvn -V clean compile 
Apache Maven 3.9.8 (36645f6c9b5079805ea5009217e36f2cffd34256)

ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile) on project maven-help-plugin: Fatal error compiling: error: invalid flag: -proc: -> [Help 1]
mvn -V clean compile      
Apache Maven 4.0.0-beta-3 (e92f645c2749eb2a4f5a8843cf01e7441e4b559f)

[INFO] BUILD SUCCESS

by default I use Maven 4 ....
so comment is wrong 😖

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@gemmellr gemmellr Jun 26, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunate. Will likely just need to avoid maven.compiler.proc=none for any projects that do want to do some annotation processing, as its likely to be some time before requiring Maven 4 is viable for some of them.

I did think of an ugly alternative that seems like it may actually work: defining annotationProcessorPaths in the parent pom with a path that doesnt have any annotation processor, thus stopping it finding any unless annotationProcessorPaths is updated. Then use annotationProcessorPaths definitions with combine.children="append" (or perhaps combine.self="override" when sure there are no other potential processors...in my case there are) to add all the actual processor paths when/where needed. Stops implicit search of all the deps, and stops the warnings on JDK21/22.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jira-importer

jira-importer commented Mar 6, 2025

Copy link
Copy Markdown

Resolve #316

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@kwin kwin kwin approved these changes
@bmarwell bmarwell bmarwell approved these changes
@slachiewicz slachiewicz slachiewicz approved these changes
@cstamas cstamas Awaiting requested review from cstamas
+1 more reviewer
@gemmellr gemmellr gemmellr left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

MAVEN-42

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@slawekjaranowski @cstamas @kwin @bmarwell @jira-importer @gemmellr @slachiewicz
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.