Skip to content

Centralize spotless setup as a buildSrc convention plugin. - #11384

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

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

@AlexeyKuznetsov-DDAlexeyKuznetsov-DD commented May 15, 2026

Copy link
Copy Markdown
Contributor

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-DDAlexeyKuznetsov-DD self-assigned this May 15, 2026
@AlexeyKuznetsov-DDAlexeyKuznetsov-DD changed the title Alexeyk/spotless convention pluginCentralize 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
ContributorAuthor

Choose a reason for hiding this comment

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

handled

@bric3bric3May 19, 2026

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.

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

So this could be imported there. 🤔

See the pointer I left on #11404.

Comment threadbuild.gradle.kts
Comment threadbuildSrc/src/main/kotlin/dd-trace-java.spotless-conventions.gradle.kts Outdated

@bric3bric3 left a comment

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.

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

`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
ContributorAuthor

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 wholedd-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
ContributorAuthor

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 externalproject 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
ContributorAuthor

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()
}

@AlexeyKuznetsov-DD

Copy link
Copy Markdown
ContributorAuthor

Not worth to go this way.

@AlexeyKuznetsov-DD
AlexeyKuznetsov-DD deleted the alexeyk/spotless-convention-plugin branch August 7, 2026 17:48
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@AlexeyKuznetsov-DD@bric3