Skip to content

Commit 80ee33f

Browse files
Guard eclipse() to spotless tasks and keep P2 mirror on pinned version (skills)
Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
1 parent fd72be6 commit 80ee33f

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

build.gradle

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ buildscript {
4545

4646
plugins {
4747
id 'java-library'
48-
id 'com.diffplug.spotless' version '6.25.0'
48+
id 'com.diffplug.spotless' version '8.10.1'
4949
id "io.freefair.lombok" version "8.10.2"
5050
id "de.undercouch.download" version "5.6.0"
5151
}
@@ -344,14 +344,24 @@ jacocoTestReport {
344344
}
345345
}
346346

347+
// Only wire the Eclipse JDT step when a spotless task is actually being run, so non-spotless
348+
// Gradle invocations (test, assemble) don't provision the formatter at configuration time.
349+
def runningSpotlessTask = gradle.startParameter.taskNames.any { it.toLowerCase(Locale.ROOT).contains('spotless') }
350+
347351
spotless {
348352
if (JavaVersion.current() >= JavaVersion.VERSION_17) {
349353
// Spotless configuration for Java files
350354
java {
351355
removeUnusedImports()
352356
importOrder 'java', 'javax', 'org', 'com'
353357
licenseHeaderFile 'spotless.license.java'
354-
eclipse().withP2Mirrors(Map.of("https://download.eclipse.org/", "https://ci.opensearch.org/")).configFile rootProject.file('.eclipseformat.xml')
358+
// Pin 4.29 explicitly: spotless 8.10.0+ ships an embedded lockfile for it, so the
359+
// formatter resolves from Maven Central through the mirror below instead of querying a
360+
// P2 update site at configuration time. Keep withP2Mirrors so any non-lockfile fallback
361+
// still hits the ci.opensearch.org mirror rather than the eclipse.org origin.
362+
if (runningSpotlessTask) {
363+
eclipse('4.29').withP2Mirrors(Map.of("https://download.eclipse.org/", "https://ci.opensearch.org/")).configFile rootProject.file('.eclipseformat.xml')
364+
}
355365
}
356366
} else {
357367
logger.lifecycle("Spotless plugin requires Java 17 or higher. Skipping Spotless tasks.")

0 commit comments

Comments
 (0)