-
Notifications
You must be signed in to change notification settings - Fork 460
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
Unfortunate automated execution in Eclipse via m2e #1814
Comments
As a work-around to the described behavior, the following snippet can be added to the pom (project or parent) to help inform the m2e plugin to ignore the spotless plugin. Note this MUST go into the pluginManagement section of the pom.
|
A PR that improves your situation would be welcome. @kwin feel free to chime in if you have an opinion. |
Please don’t change the default value for runOnIncremental but rather add a plugin configuration for bailing out on incremental build (similar to what is done in https://github.com/apache/jackrabbit-filevault-package-maven-plugin/blob/c0433155e825130d1c9a435f5fb837af8e9c46d4/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/mojo/FormatDocviewXmlMojo.java#L110). Newer m2e versions execute Mojos by default anyway: https://github.com/eclipse-m2e/m2e-core/blob/master/RELEASE_NOTES.md#mojos-without-a-mapping-are-now-executed-by-default-in-incremental-builds |
Clear stale messages during "check" mojo Allow to parameterize message severity Add Spotless prefix to messages This closes diffplug#1814 This closes diffplug#2037
I wanted to bring up what I generally believe to be an unfortunate misconfiguration of the m2e lifecycle mapping recently added as part of #1413 released as plugin-maven-2.29.0
While I believe adding m2e support is probably a good idea, the lifecycle-mapping-metadata.xml [1] specifies "runOnIncremental" to be 'true'. This is frustrating while working inside of Eclipse, as any save to a source file instantly causes a reformatting of the source, which is definitely not expected behavior.
The jarring experience here is that often, while you're "thinking" or in the middle of development, you don't necessarily want your source code to be reformatted unexpectedly just by merely saving the file. You might not consider the code as "complete" yet and want to leave your current formatting in place. With spotless configured to run on save, it's often the case that the newly formatted code is not as readable as what the developer is currently expressing while in the development mode.
Even for example creating a new empty class in the project, the source code is immediately reformatted which often results in the closing of the empty curly braces (if using the google format plugin). That is, the plugin is being executed even when a source file has not yet even been saved, making the class difficult to immediately type code into as the cursor focus is lost!
If not specified, the m2e project assumes the default of runOnIncremental to be 'false', which would be a much more reasonable setting for the lifecycle mapping. Or setting the action to "ignore" would prevent the plugin from executing inside of the Eclipse lifecycle entirely.
In general, while I appreciate having the "opinionated" source formatting being performed on my code during the traditional maven lifecycle (I bind spotless to my verify phase), having it executed for every save in the IDE is overkill and disruptive to productivity. A developer should be able to edit their source in whatever format they desire while developing and then coerce the formatting as a last step after the session is complete.
I would be more than happy to provide a PR that reduces the execution behavior of the plugin as described above. I'd personally prefer if the plugin was set to the "ignore" action. But at minimum, runOnIncremental should likely be changed to the default value of 'false' which would at least help with this issue.
Thanks.
[1] https://github.com/diffplug/spotless/blob/main/plugin-maven/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
The text was updated successfully, but these errors were encountered: