Skip to content

Centralize spotless setup as a buildSrc convention plugin.#11384

Draft
AlexeyKuznetsov-DD wants to merge 4 commits into
masterfrom
alexeyk/spotless-convention-plugin
Draft

Centralize spotless setup as a buildSrc convention plugin.#11384
AlexeyKuznetsov-DD wants to merge 4 commits into
masterfrom
alexeyk/spotless-convention-plugin

Conversation

@AlexeyKuznetsov-DD
Copy link
Copy Markdown
Contributor

@AlexeyKuznetsov-DD AlexeyKuznetsov-DD commented May 15, 2026

What Does This Do

Move the Spotless configuration out of gradle/spotless.gradle into a buildSrc convention plugin (dd-trace-java.spotless-conventions). Also upgrades Spotless to 8.5.0 and tweaks a dedicated CI job with extra heap to avoid OOM.

Motivation

Refactor legacy Groovy scripts to modern Kotlin convention plugins.

Additional Notes

To simplify review this PR has ONLY BUILD CHANGES!!! for now. Once reviewed I will run spotlessApply before merge to master.

Note

For the first run, it’s recommended to execute the following commands to avoid errors and crashing with an OutOfMemoryError or hanging during GC:

./gradlew clean spotlessApply --no-build-cache --no-daemon --parallel --max-workers=2

After the initial run, the spotless artifacts will be cached, and it should be safe to run it as usual:

./gradlew spotlessApply

@AlexeyKuznetsov-DD AlexeyKuznetsov-DD self-assigned this May 15, 2026
@AlexeyKuznetsov-DD AlexeyKuznetsov-DD changed the title Alexeyk/spotless convention plugin Centralize spotless setup as a buildSrc convention plugin. May 15, 2026
version = versionFromFile

apply from: "$sharedConfigDirectory/repositories.gradle"
apply from: "$sharedConfigDirectory/spotless.gradle"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: FYI test-published-dependencies/ is a complete different project. And it doesn't have access to the included build that buildSrc is (unless we do something different).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handled

Comment thread build.gradle.kts
predeclareDeps()
}

with(extensions["spotlessPredeclare"] as SpotlessExtension) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: 8.5.0 allows to use spotlessPredeclare {} directly

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, but finally I applied a bit different approach.

val spotlessExcludedProjects = setOf(":dd-java-agent:agent-jmxfetch")

// Spotless applied per-module for parallel execution, configured centrally here.
allprojects {
Copy link
Copy Markdown
Contributor

@bric3 bric3 May 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: I think I wouldn't use allproject it breaks isolation: they do cross-project configuration, this coupling is usually a bad thing and it can also affect negatively the capability of having a working configuration cache.

Instead, I suggest to apply the same spotless convention plugin, were it was declared before, in particular the root build.gradle.kts and in the java_no_deps.gradle.

And, let this plugin react differently if it's the root project or not, like it is in the body of the allproject lambda.

I'm not quite sure, at this point, but it might be sensible to declare spotless directly in the test-published-dependencies/, the project is less prone to modifications and doesn't have a lot of code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. Refactored to apply per project at java_no_deps.gradle

@AlexeyKuznetsov-DD AlexeyKuznetsov-DD requested a review from bric3 May 16, 2026 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants