Skip to content

Centralize spotless setup as a buildSrc convention plugin.#11384

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

Centralize spotless setup as a buildSrc convention plugin.#11384
AlexeyKuznetsov-DD wants to merge 6 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

Copy link
Copy Markdown
Contributor

@bric3 bric3 May 19, 2026

Choose a reason for hiding this comment

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

Wait I'm thinking, about something to handle test-published-dependencies/. The spot convention could be something to put in the future included build build-logic/.

So this could be imported there. 🤔

See the pointer I left on #11404.

Comment thread build.gradle.kts
Comment thread buildSrc/src/main/kotlin/dd-trace-java.spotless-conventions.gradle.kts Outdated
@AlexeyKuznetsov-DD AlexeyKuznetsov-DD requested a review from bric3 May 16, 2026 01:33
Copy link
Copy Markdown
Contributor

@bric3 bric3 left a comment

Choose a reason for hiding this comment

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

That's a nice simplification! I found a few other simple gotcha, otherwise good to go !

Comment thread buildSrc/build.gradle.kts
`java-gradle-plugin`
`kotlin-dsl`
`jvm-test-suite`
id("com.diffplug.spotless") version "8.4.0"
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: This actually removes spotless from the buildSrc project

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.

I moved it inside spotless convention plugin, see
To process whole dd-trace-java with single ./gradlew spotlessApply command.
Also folders like test-published-dependencies will be processed too.

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.

Imho this looks incorrect to modify these project from the main dd-trace-java.

"ktlint_standard_trailing-comma-on-declaration-site" to "disabled"
)

val EXCLUDED_PROJECTS = setOf(":dd-java-agent:agent-jmxfetch")
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.

issue: This looks wrong. Spotless was applied to this module before.

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.

Hmm, as far as I understand it is external project that injected into dd-trace-java and it should have its own spotless or other way to clean code.

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.

:dd-java-agent:agent-jmxfetch is from us, but dd-java-agent/agent-jmxfetch/integrations-core is a git submodule.

)
}

private fun configureProjectFormatting(project: Project) {
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.

issue: It seems that project-local markdown and misc formats were not carried over.

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.

Not sure what is wrong, but I can see in my branch the following changes
I actually think we need to add folders like .claude, docs to process md files.
Let me know WDYT?

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.

It's just that I don;t sse markdown and misc being configured, so that seems a bit strange, compared to previous spotless.gradle.

format 'markdown', {
toggleOffOn()
target '*.md', '.github/**/*.md', 'src/**/*.md', 'application/**/*.md'
leadingTabsToSpaces()
endWithNewline()
}
format 'misc', {
toggleOffOn()
target '.gitignore', '*.sh', 'tooling/*.sh', '.gitlab/*.sh'
leadingTabsToSpaces()
trimTrailingWhitespace()
endWithNewline()
}

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