Allow setting the local P2 cache dir in the Spotless Gradle plugin by bric3 · Pull Request #2944 · diffplug/spotless (original) (raw)

Conversation

@bric3

This adds a way to control in which directory the Eclipse based formatters will be cached. This PR adds a cacheDirectory method in the config of each Eclipse based steps.

The reason is that, by default the eclipse resolver will place the downloaded artifacts in ~/.m2/repository/dev/equo/p2-data, this folder is a bit alien in Gradle based build. And having it nested in the maven repository structure makes it a bit harder to manage in a CI.

Given it's a Gradle related change, I choose to not add this under the maven plugin since .m2/ is already maven managed.

@bric3

bric3

@bric3

@jochenberger

Maybe the Gradle plug-in could also set a more sensible default?

@jochenberger

Somewhere inside $GRADLE_USER_HOME for example?

@bric3

I hesitated to do that, as it's a breaking change.

@jochenberger

IMHO, if we just break a potentially existing cache, it's not so much of an issue. But maybe you're right. 🤷🏼‍♂️

@bric3

@bric3

@nedtwigg

It's been a long time, but I recall the Solstice cache directory being changed because somebody felt strongly it was in the wrong place before. I think the point of ~/.m2 is that it makes it more likely that a CI runner with automatically cache it, instead of needed special setup just for Spotless deps to get cached.

I'm okay with changing it, but it needs to be clearly laid out in the changelog "Eclipse dependencies were cached at X by default, now they are cached at Y by default"

@jochenberger

That might have been me actually. And I still think that ~/.m2 is not a very good default in the Gradle ecosystem.

@bric3

I think the point of ~/.m2 is that it makes it more likely that a CI runner with automatically cache it

Yeah, I think it totally makes sense on maven. But on gradle builds it doesn't.

It's a breaking change, but now that the cache directory is configurable, users can easily revert to the path they want. That said I understand you might want to postpone the change.

@nedtwigg

I'm okay with this change. If you are both happy with it (@bric3 and @jochenberger) then I'm happy to merge.

@jochenberger

@nedtwigg

@bric3

@bric3 bric3 deleted the add-cache-directory-dsl branch

May 27, 2026 13:56

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})