Skip to content

Comments

Partially support isolated projects#2854

Open
inorichi wants to merge 6 commits intodiffplug:mainfrom
inorichi:feature/isolated_projects
Open

Partially support isolated projects#2854
inorichi wants to merge 6 commits intodiffplug:mainfrom
inorichi:feature/isolated_projects

Conversation

@inorichi
Copy link

This PR adds partial support for isolated projects.

They're supported as long as predeclareDeps() is not called in the root extension.

The PR does the following:

  • Removes .getRootProject.file(...) since it's not supported by isolated projects.
  • Removes the GradleCompat file because project.findProperty and project.hasProperty can't be used and the compat file is not meaningful anymore.
  • Moves the SpotlessTaskService reference from RegisterDependenciesTask to SpotlessExtension as the task is not really owning the task service. This simplifies some dependencies needing to get the task reference first.
  • Makes the SpotlessExtension not reference the RegisterDependenciesTask which is created in the root project and moves all of that to SpotlessExtensionPredeclare. Since this task is only needed (AFAIK) for predeclared, it makes sense that the task is only referenced there.
  • Some tests needed adjustments because RegisterDependenciesTask is not executed when predeclared is not used.
  • Adds a test that verifies isolated projects compatibility.

@nedtwigg
Copy link
Member

Wonderful! Looks like it needs a ./gradlew spotlessApply before CI can check it. Will also need changelog entries and doc updates where appropriate.

@inorichi inorichi force-pushed the feature/isolated_projects branch from 3db843d to 611af68 Compare February 20, 2026 18:38
@inorichi inorichi force-pushed the feature/isolated_projects branch from 611af68 to f7829b5 Compare February 20, 2026 18:40
@inorichi inorichi force-pushed the feature/isolated_projects branch from 41e3f19 to bebb746 Compare February 20, 2026 19:25
@inorichi
Copy link
Author

Fixed. Sorry I rebased and force pushed the changes, it's an habit of mine...

I added the changelog entry, but I'm not sure where I should update the documentation.

@nedtwigg
Copy link
Member

I'm not sure where I should update the documentation.

https://github.com/diffplug/spotless/tree/main/plugin-gradle#dependency-resolution-modes

This should have a note of some kind saying "breaks isolated projects" or something like that.

Assuming CI passes and no other contributors have any objections, I'll merge and release next week.

@nedtwigg nedtwigg requested a review from Goooler February 20, 2026 20:54
@inorichi
Copy link
Author

I added a note where you suggested, let me know if it's good enough.

Regarding CI, it seems like there are different isolated project error outputs, while I get the following locally:

- Build file '0/build.gradle': Cannot access project ':' from project ':0'

CI sees this:

- Build file '0/build.gradle': Project ':0' cannot access 'Project.tasks' functionality on another project ':'

And that breaks the test I created. I don't understand the difference, since I'm running the gradle wrapper too and should run the same gradle version. I'll investigate...

@inorichi
Copy link
Author

inorichi commented Feb 21, 2026

Okay, it seems like CI was executing that test on Gradle 9, and the message is different on that version, I've changed the test to .containsAnyOf("Cannot access project", "cannot access 'Project.tasks'") so that Gradle 8 and 9 are supported.

Edit: I just saw that GradleIntegrationHarness runs different gradle versions based on the JDK used, that's what happened.

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