Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ buildscript {
plugins {
id 'java-library'
id 'maven-publish'
id 'com.diffplug.spotless' version '6.25.0'
id 'com.diffplug.spotless' version '8.10.1'
}

repositories {
Expand Down Expand Up @@ -121,13 +121,23 @@ test {
}
}

// Only wire the Eclipse JDT step when a spotless task is actually being run, so non-spotless
// Gradle invocations (test, assemble) don't provision the formatter at configuration time.
def runningSpotlessTask = gradle.startParameter.taskNames.any { it.toLowerCase(Locale.ROOT).contains('spotless') }

spotless {
java {
removeUnusedImports()
importOrder 'java', 'javax', 'org', 'com'
licenseHeaderFile 'spotless.license.java'

eclipse().withP2Mirrors(Map.of("https://download.eclipse.org/", "https://ci.opensearch.org/")).configFile rootProject.file('.eclipseformat.xml')
// Pin 4.29 explicitly: spotless 8.10.0+ ships an embedded lockfile for it, so the
// formatter resolves from Maven Central through the mirror below instead of querying a
// P2 update site at configuration time. Keep withP2Mirrors so any non-lockfile fallback
// still hits the ci.opensearch.org mirror rather than the eclipse.org origin.
if (runningSpotlessTask) {
eclipse('4.29').withP2Mirrors(Map.of("https://download.eclipse.org/", "https://ci.opensearch.org/")).configFile rootProject.file('.eclipseformat.xml')
}
}
}

Expand Down
Loading