Skip to content

Replace spotbugs with errorprone #1073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 8, 2025
Merged

Conversation

jqno
Copy link
Owner

@jqno jqno commented May 8, 2025

No description provided.

@jqno jqno force-pushed the replace-spotbugs-with-errorprone branch from 535f47f to 09e4ded Compare May 8, 2025 17:49
@jqno jqno merged commit c088b30 into main May 8, 2025
17 checks passed
@@ -241,10 +239,38 @@
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<showWarnings>true</showWarnings>
<fork>true</fork>
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @jqno, out of curiosity, what made you go with fork=true instead of having a .mvn/jvm.config configuration?

I'm asking because I'm introducing ErrorProne too, and I picked the jvm.config direction so far, so I'm curious about your reasoning 🙂

Copy link
Owner Author

@jqno jqno May 9, 2025

Choose a reason for hiding this comment

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

😄

First I want to say, I don't like that we have to add all these directives in the first place. But since we have to... I picked this approach because this way, I can keep it inside the codebase, and anybody who wants to clone or fork, can just run the build without setup.

With a ~/.mvn/jvm.config, you have to tell people to set that up, and figure something out for running it in CI, and also it will apply to all your other Maven projects on that machine as well. So this just seemed like the easier way 😄

In the end though, I'm quite happy with the fact that ErrorProne does work on my 25-ea build, where Spotbugs didn't. It's nice to see all those builds be green, even if they're only experimental ones for future Java versions.

Copy link
Contributor

Choose a reason for hiding this comment

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

With a ~/.mvn/jvm.config, you have to tell people to set that up, and figure something out for running it in CI, and also it will apply to all your other Maven projects on that machine as well. So this just seemed like the easier way 😄

I wasn't precise - I'm configuring these under the Maven Wrapper folder (see spring-projects/spring-batch#4807) so .mvn/jvm.config is on git and should be picked up automatically by most users.

(I'm not sure if you run your locally installed Maven and not via ./mnvw, maybe it still looks for that config? I haven't tried it yet)

Copy link
Owner Author

Choose a reason for hiding this comment

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

Ahhh, I didn't think of that possibility. I don't use the Maven Wrapper myself, so I wasn't aware that you can configure it like that. That actually sounds interesting, though I'm not sure I can fix my muscle memory to type ./mvnw instead of mvn 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

I just tried to execute my locally installed mvn, it seems to work 🙂 and it's also documented, unrelated to the wrapper:

Starting with Maven 3.3.1+ you can define JVM configuration via .mvn/jvm.config file which means you can define the options for your build on a per project base. This file will become part of your project and will be checked in along with your project. So no need anymore for MAVEN_OPTS, .mavenrc files.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Well then, I guess the answer to your original question is, because I didn't read the documentation 😅

Knowing this, there doesn't seem to be a very good reason for one or the other, apart for personal preference maybe? I think I'll leave it in the pom, at least for now, since it's already working well as it is... Also, I think I like having this stuff close to the rest of the ErrorProne config

Copy link
Contributor

Choose a reason for hiding this comment

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

It likely depends on the project, but not forking can improve performance. (Similar to how you use the jar-no-fork goal for the maven-source-plugin.)

Copy link
Owner Author

Choose a reason for hiding this comment

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

Oh that's good to know. Might change it then after all 😅 Thanks!

Copy link

Choose a reason for hiding this comment

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

Ahhh, I didn't think of that possibility. I don't use the Maven Wrapper myself, so I wasn't aware that you can configure it like that. That actually sounds interesting, though I'm not sure I can fix my muscle memory to type ./mvnw instead of mvn 😅

@jqno No need to fix your muscle memory, let the shell do it for you with a small function 😉
https://github.com/merikan/.dotfiles/blob/main/config/sh/functions#L64-L80

Copy link
Owner Author

Choose a reason for hiding this comment

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

Thanks @merikan, I should have thought of that too! I might steal some other functions from that file as well 😇

Copy link
Contributor

@Stephan202 Stephan202 left a comment

Choose a reason for hiding this comment

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

Nice; Error Prone is very cool :)

@@ -241,10 +239,38 @@
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<showWarnings>true</showWarnings>
<fork>true</fork>
Copy link
Contributor

Choose a reason for hiding this comment

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

It likely depends on the project, but not forking can improve performance. (Similar to how you use the jar-no-fork goal for the maven-source-plugin.)

@jqno jqno deleted the replace-spotbugs-with-errorprone branch June 11, 2025 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants