diff --git a/lib-extra/build.gradle b/lib-extra/build.gradle index a9e50d7d97..5e056a8384 100644 --- a/lib-extra/build.gradle +++ b/lib-extra/build.gradle @@ -50,6 +50,9 @@ def NEEDS_P2_DEPS = [ 'groovy', 'jdt' ] +if (!JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) { + NEEDS_P2_DEPS.remove('cdt') +} for (needsP2 in NEEDS_P2_DEPS) { sourceSets.register(needsP2) { compileClasspath += sourceSets.main.output @@ -74,11 +77,12 @@ tasks.withType(Test).configureEach { apply plugin: 'dev.equo.p2deps' p2deps { - // (alphabetic order please) - into 'cdtCompileOnly', { - p2repo 'https://download.eclipse.org/eclipse/updates/4.26/' - p2repo 'https://download.eclipse.org/tools/cdt/releases/11.0/' - install 'org.eclipse.cdt.core' + if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) { + into 'cdtCompileOnly', { + p2repo 'https://download.eclipse.org/eclipse/updates/4.26/' + p2repo 'https://download.eclipse.org/tools/cdt/releases/11.0/' + install 'org.eclipse.cdt.core' + } } into 'groovyCompileOnly', { p2repo 'https://download.eclipse.org/eclipse/updates/4.26/' diff --git a/lib-extra/src/main/java/com/diffplug/spotless/extra/cpp/EclipseCdtFormatterStep.java b/lib-extra/src/main/java/com/diffplug/spotless/extra/cpp/EclipseCdtFormatterStep.java index 81c4f9dc85..9582eeed31 100644 --- a/lib-extra/src/main/java/com/diffplug/spotless/extra/cpp/EclipseCdtFormatterStep.java +++ b/lib-extra/src/main/java/com/diffplug/spotless/extra/cpp/EclipseCdtFormatterStep.java @@ -38,7 +38,7 @@ public final class EclipseCdtFormatterStep { private EclipseCdtFormatterStep() {} private static final String NAME = "eclipse cdt formatter"; - private static final Jvm.Support JVM_SUPPORT = Jvm. support(NAME).add(11, "11.0").add(17, "11.6"); + private static final Jvm.Support JVM_SUPPORT = Jvm. support(NAME).add(17, "11.6"); public static String defaultVersion() { return JVM_SUPPORT.getRecommendedFormatterVersion(); diff --git a/lib-extra/src/test/java/com/diffplug/spotless/extra/cpp/EclipseCdtFormatterStepTest.java b/lib-extra/src/test/java/com/diffplug/spotless/extra/cpp/EclipseCdtFormatterStepTest.java index 144310b654..c2a1c4703f 100644 --- a/lib-extra/src/test/java/com/diffplug/spotless/extra/cpp/EclipseCdtFormatterStepTest.java +++ b/lib-extra/src/test/java/com/diffplug/spotless/extra/cpp/EclipseCdtFormatterStepTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2024 DiffPlug + * Copyright 2016-2025 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,8 +15,11 @@ */ package com.diffplug.spotless.extra.cpp; +import static org.junit.jupiter.api.condition.JRE.JAVA_17; + import java.util.stream.Stream; +import org.junit.jupiter.api.condition.EnabledForJreRange; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; @@ -30,6 +33,7 @@ public EclipseCdtFormatterStepTest() { @ParameterizedTest @MethodSource + @EnabledForJreRange(min = JAVA_17) void formatWithVersion(String version) throws Exception { harnessFor(version).test("main.c", "#include ;\nint main(int argc, \nchar *argv[]) {}", @@ -37,6 +41,6 @@ void formatWithVersion(String version) throws Exception { } private static Stream formatWithVersion() { - return Stream.of("10.6", "10.7", EclipseCdtFormatterStep.defaultVersion()); + return Stream.of("11.0", "11.6", EclipseCdtFormatterStep.defaultVersion()); } }