We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
Adds the sorting mechanism of the sortpom-maven-plugin.
While the sortpom-maven-plugin is a maven plugin in itself, I like all my code formatting in one plugin, so this PR integrates the pom sorting from that plugin. Configuration options are the same as in the upstream project.
Sorry, something went wrong.
Documentation is still missing, would like to know if this is something you want inside spotless, before I do the tedious documentation work. 😄
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It would be great to add this, but the third-party dep needs to be resolved dynamically via JarState. If every formatter in lib and lib-extra just added itself as a dependency, we would have an absolute nightmare of transitive conflicts, and we would have to publish a new plugin every few days as one or another plugin releases a new version.
JarState
lib
lib-extra
This dep needs to be resolved like this:
spotless/lib/src/main/java/com/diffplug/spotless/java/GoogleJavaFormatStep.java
Line 122 in 85344bd
And the jar should be called using reflection. You can do it raw as we do for google-java-format,
or it might be worth incorporating some pieces of #524
14ee011
b7958a9
#524. Classloading is a bit awkward... Do you have any better idea?
I think the way that you added a sortPom sourceSet is great. I don't understand why JarState::getClassLoader wasn't enough, I don't think you need the serialization tricks nor to make a new kind of classloader. I might be wrong though.
sortPom
JarState::getClassLoader
The classloader you already get from JarState is built like so:
spotless/lib/src/main/java/com/diffplug/spotless/SpotlessCache.java
Line 71 in 85344bd
https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/FeatureClassLoader.java
I might be wrong, but I think that you should be able to pass objects from SortPomStep to SortPomFormatterFunc without serializing them. This stuff is tricky, and I'm very willing to believe that I'm wrong.
SortPomStep
SortPomFormatterFunc
If the serialization stuff really is necessary, then we should either:
FeatureClassLoader
But ideally it isn't necessary in the first place!
2e0a3b3
I'll have another go at the class loading stuff after the other two PRs are in. Can't handle all the parallelity in my brain. 🤣
Added support for Maven POM sorting/formatting
22ddb38
load SortPom from JarState
503f4c0
use FormatterFunc and SortPomState from current ClassLoader
8b7c3eb
I could get rid of the serializing deserializing, but I couldn't get rid of the DelegatingClassLoader.
DelegatingClassLoader
The problem is the following:
ClassLoader
SortPomState
FormatterFunc
buildToolClassLoader
I hope this helps to understand, why I did it in this way. If there is an easier or more elegant solution, I'm all for it. 😄
Fixed SpotBugs errors
c0d1b68
Rename SortPomTest to SortPomMavenTest.
680d95c
Create a no-maven SortPomTest which can run quickly.
4a80576
Rename SortPomState to SortPomCfg, and:
f2c0e4a
- SortPomCfg needs no dependencies, just Strings and booleans - SortPomCfg now has the default values, which simplifies plugin-maven/.../SortPom.java - SortPomStep does the JarState and classloader stuff
FeatureClassLoader now loads com.diffplug.spotless.glue.* via `def…
com.diffplug.spotless.glue.*
bcd3735
…ineClass`, and `com.diffplug.spotless` with `buildToolClassLoader`. This unifies FeatureClassLoader with DelegatingClassLoader.
SortPomStep can now live within the normal src/main/java, and only …
src/main/java
4b780c0
…`SortPomFormatterFunc` needs `src/sortPom/java`.
Fix typo.
6d6ab66
Well I broke eclipse, but I fixed PomStep. Does this approach look good to you @tisoft? You got all the hard parts working, I just massaged things around with an eye towards other parts of Spotless adopting this same "glue" approach.
Fix FeatureClassLoader for eclipse entries.
24bc908
plugin-maven doesn't need any special dependency on the lib jar.
2b85d84
@fvgh, just FYI, we finally have a way to ship glue code without requiring all deps of that glue code. It works like so:
com.diffplug.spotless.glue.
com.diffplug.spotless
com.diffplug.spotless.extra
org.slf4j.
This will allow us to replace a lot of manual reflection code, ala #524.
Generalize the sortPom stuff to facilitate diffplug#524 (glue code).
b95e93b
#524, which will make the project much easier to read and contribute to.
Added documentation for sortPom
617abf5
@nedtwigg Added documentation and changelog entries.
5951f3d
Released in plugin-maven 2.15.0
plugin-maven 2.15.0
I advise the following:
I also anticipate that you will want to add a version property to SortPomCfg, so that you can use the latest version of sortpom without needing to publish a whole new set of Spotless artifacts each time, but that can wait until it's needed.
version
SortPomCfg
nedtwigg nedtwigg requested changes
Successfully merging this pull request may close these issues.