Skip to content

Allow setting the local P2 cache dir in the Spotless Gradle plugin#2944

Open
bric3 wants to merge 3 commits into
diffplug:mainfrom
bric3:add-cache-directory-dsl
Open

Allow setting the local P2 cache dir in the Spotless Gradle plugin#2944
bric3 wants to merge 3 commits into
diffplug:mainfrom
bric3:add-cache-directory-dsl

Conversation

@bric3
Copy link
Copy Markdown
Contributor

@bric3 bric3 commented May 21, 2026

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.

  • a summary of the change
  • either
    • a link to the issue you are resolving (for small changes)
    • a link to the PR you just created (for big changes likely to have discussion)

Comment thread plugin-gradle/CHANGES.md Outdated
@jochenberger
Copy link
Copy Markdown
Contributor

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

@jochenberger
Copy link
Copy Markdown
Contributor

Somewhere inside $GRADLE_USER_HOME for example?

@bric3
Copy link
Copy Markdown
Contributor Author

bric3 commented May 21, 2026

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

@jochenberger
Copy link
Copy Markdown
Contributor

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

@bric3
Copy link
Copy Markdown
Contributor Author

bric3 commented May 22, 2026

Actually I slept on it, and I kind of agree with you know, it could be considered a bug.

And as a matter of fact, under the hood spotless uses a "fake" eclipse, and there's a mechanism that is supposedly handling Gradle, but it only works if the GRADLE_USER_HOME env var is there. See

https://github.com/equodev/equo-ide/blob/731353e7046f7f7e73da7fd5524991168bccc045/solstice/src/main/java/dev/equo/solstice/p2/CacheLocations.java#L80-L104

I suppose there are various reasons why it's like that in solstice. But spotless knows where it is run so it should provide sensible defaults. I'm commiting someting in that regard.

Set Gradle's default P2 cache under Gradle user home and Maven's under
the local repository, while keeping explicit cacheDirectory overrides
for both plugins.

Solstice uses the maven m2 directory unless GRADLE_USER_HOME is set
https://github.com/equodev/equo-ide/blob/main/solstice/src/main/java/dev/equo/solstice/p2/CacheLocations.java#L80-L104
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.

2 participants