From e7a14403e2556eae9386f4c8e26309d27b9ed8f1 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Wed, 15 Oct 2025 20:23:17 +0200 Subject: [PATCH] Upgrade to spotless 3.0.0 and palantir 2.80.0 --- .../java/org/apache/maven/api/cli/Logger.java | 5 +- .../maven/api/services/RequestTrace.java | 5 +- .../java/org/apache/maven/cli/MavenCli.java | 7 +-- .../transfer/TransferResourceIdentifier.java | 6 ++- .../maven/cli/props/MavenPropertiesTest.java | 3 +- .../main/java/org/apache/maven/utils/Os.java | 7 +-- .../internal/ArtifactDescriptorUtils.java | 4 +- ...serPropertiesArtifactRelocationSource.java | 5 +- .../maven/cling/invoker/LookupInvoker.java | 7 +-- .../cling/invoker/mvnsh/ShellInvoker.java | 3 +- .../transfer/TransferResourceIdentifier.java | 6 ++- .../cling/invoker/mvn/MavenInvokerTest.java | 12 ++--- .../invoker/mvn/MavenInvokerTestSupport.java | 6 +-- .../goals/CompatibilityFixStrategyTest.java | 9 ++-- .../invoker/mvnup/goals/GAVUtilsTest.java | 27 ++++------ .../mvnup/goals/InferenceStrategyTest.java | 51 +++++++------------ .../invoker/mvnup/goals/JDomUtilsTest.java | 30 ++++------- .../mvnup/goals/ModelUpgradeStrategyTest.java | 21 +++----- .../mvnup/goals/ModelVersionUtilsTest.java | 24 +++------ .../goals/PluginUpgradeStrategyTest.java | 33 ++++-------- .../cling/invoker/mvnup/goals/TestUtils.java | 12 ++--- .../concurrent/BuildPlanExecutor.java | 3 +- .../maven/project/DefaultProjectBuilder.java | 5 +- .../maven/project/RepositoryLeakageTest.java | 12 ++--- .../executor/MavenExecutorTestSupport.java | 6 +-- .../org/apache/maven/impl/cache/Cache.java | 15 +++--- .../impl/model/DefaultModelValidator.java | 6 +-- .../resolver/ArtifactDescriptorUtils.java | 4 +- ...serPropertiesArtifactRelocationSource.java | 5 +- .../java/org/apache/maven/impl/util/Os.java | 7 +-- .../impl/DefaultModelXmlFactoryTest.java | 21 +++----- .../impl/DefaultPluginXmlFactoryTest.java | 6 +-- .../maven/impl/XmlFactoryTransformerTest.java | 12 ++--- .../impl/cache/CacheConfigurationTest.java | 7 +-- .../impl/model/InterningTransformerTest.java | 6 +-- .../impl/model/ParentCycleDetectionTest.java | 28 +++------- .../maven/internal/xml/XmlNodeImplTest.java | 12 ++--- pom.xml | 7 +++ 38 files changed, 177 insertions(+), 268 deletions(-) diff --git a/api/maven-api-cli/src/main/java/org/apache/maven/api/cli/Logger.java b/api/maven-api-cli/src/main/java/org/apache/maven/api/cli/Logger.java index cd9aaff994e0..7d5d2aebb581 100644 --- a/api/maven-api-cli/src/main/java/org/apache/maven/api/cli/Logger.java +++ b/api/maven-api-cli/src/main/java/org/apache/maven/api/cli/Logger.java @@ -148,7 +148,10 @@ default void error(@Nonnull String message, @Nullable Throwable error) { * @param message The logging message, never {@code null}. * @param error The error, if applicable. */ - record Entry(@Nonnull Level level, @Nonnull String message, @Nullable Throwable error) {} + record Entry( + @Nonnull Level level, + @Nonnull String message, + @Nullable Throwable error) {} /** * If this is an accumulating log, it will "drain" this instance. It returns the accumulated log entries, and diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/RequestTrace.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/RequestTrace.java index 6dafc3aeaf57..ac67cb64509e 100644 --- a/api/maven-api-core/src/main/java/org/apache/maven/api/services/RequestTrace.java +++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/RequestTrace.java @@ -50,7 +50,10 @@ * object being processed or any application-specific state information. May be null if no * additional data is needed. */ -public record RequestTrace(@Nullable String context, @Nullable RequestTrace parent, @Nullable Object data) { +public record RequestTrace( + @Nullable String context, + @Nullable RequestTrace parent, + @Nullable Object data) { public static final String CONTEXT_PLUGIN = "plugin"; public static final String CONTEXT_PROJECT = "project"; diff --git a/compat/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/compat/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java index d42591953de3..fec07d6979ff 100644 --- a/compat/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java +++ b/compat/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java @@ -544,9 +544,10 @@ void logging(CliRequest cliRequest) throws ExitException { switch (logLevelThreshold.toLowerCase(Locale.ENGLISH)) { case "warn", "warning" -> LogLevelRecorder.Level.WARN; case "error" -> LogLevelRecorder.Level.ERROR; - default -> throw new IllegalArgumentException( - logLevelThreshold - + " is not a valid log severity threshold. Valid severities are WARN/WARNING and ERROR."); + default -> + throw new IllegalArgumentException( + logLevelThreshold + + " is not a valid log severity threshold. Valid severities are WARN/WARNING and ERROR."); }; recorder.setMaxLevelAllowed(level); slf4jLogger.info("Enabled to break the build on log level {}.", logLevelThreshold); diff --git a/compat/maven-embedder/src/main/java/org/apache/maven/cli/transfer/TransferResourceIdentifier.java b/compat/maven-embedder/src/main/java/org/apache/maven/cli/transfer/TransferResourceIdentifier.java index 8789b9b1e1c9..c259ae14d4d6 100644 --- a/compat/maven-embedder/src/main/java/org/apache/maven/cli/transfer/TransferResourceIdentifier.java +++ b/compat/maven-embedder/src/main/java/org/apache/maven/cli/transfer/TransferResourceIdentifier.java @@ -29,7 +29,11 @@ * making it not very suitable for usage in collections. */ @Deprecated -record TransferResourceIdentifier(String repositoryId, String repositoryUrl, String resourceName, @Nullable File file) { +record TransferResourceIdentifier( + String repositoryId, + String repositoryUrl, + String resourceName, + @Nullable File file) { TransferResourceIdentifier(TransferResource resource) { this(resource.getRepositoryId(), resource.getRepositoryUrl(), resource.getResourceName(), resource.getFile()); } diff --git a/compat/maven-embedder/src/test/java/org/apache/maven/cli/props/MavenPropertiesTest.java b/compat/maven-embedder/src/test/java/org/apache/maven/cli/props/MavenPropertiesTest.java index 07aa1e8ba664..72628a365fe9 100644 --- a/compat/maven-embedder/src/test/java/org/apache/maven/cli/props/MavenPropertiesTest.java +++ b/compat/maven-embedder/src/test/java/org/apache/maven/cli/props/MavenPropertiesTest.java @@ -51,8 +51,7 @@ public class MavenPropertiesTest { private MavenProperties properties; - static final String TEST_PROPERTIES = - """ + static final String TEST_PROPERTIES = """ # # test.properties # Used in the PropertiesTest diff --git a/compat/maven-model-builder/src/main/java/org/apache/maven/utils/Os.java b/compat/maven-model-builder/src/main/java/org/apache/maven/utils/Os.java index ef189d6a5153..b4d29435b92a 100644 --- a/compat/maven-model-builder/src/main/java/org/apache/maven/utils/Os.java +++ b/compat/maven-model-builder/src/main/java/org/apache/maven/utils/Os.java @@ -188,9 +188,10 @@ public static boolean isFamily(String family, String actualOsName) { case FAMILY_DOS -> File.pathSeparatorChar == ';' && !isFamily(FAMILY_NETWARE, actualOsName) && !isWindows; case FAMILY_MAC -> actualOsName.contains(FAMILY_MAC) || actualOsName.contains(DARWIN); case FAMILY_TANDEM -> actualOsName.contains("nonstop_kernel"); - case FAMILY_UNIX -> File.pathSeparatorChar == ':' - && !isFamily(FAMILY_OPENVMS, actualOsName) - && (!isFamily(FAMILY_MAC, actualOsName) || actualOsName.endsWith("x")); + case FAMILY_UNIX -> + File.pathSeparatorChar == ':' + && !isFamily(FAMILY_OPENVMS, actualOsName) + && (!isFamily(FAMILY_MAC, actualOsName) || actualOsName.endsWith("x")); case FAMILY_ZOS -> actualOsName.contains(FAMILY_ZOS) || actualOsName.contains(FAMILY_OS390); case FAMILY_OS400 -> actualOsName.contains(FAMILY_OS400); case FAMILY_OPENVMS -> actualOsName.contains(FAMILY_OPENVMS); diff --git a/compat/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorUtils.java b/compat/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorUtils.java index 821db5de1400..7771fb7646f8 100644 --- a/compat/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorUtils.java +++ b/compat/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorUtils.java @@ -86,8 +86,8 @@ public static String toRepositoryChecksumPolicy(final String artifactRepositoryP case RepositoryPolicy.CHECKSUM_POLICY_FAIL -> RepositoryPolicy.CHECKSUM_POLICY_FAIL; case RepositoryPolicy.CHECKSUM_POLICY_IGNORE -> RepositoryPolicy.CHECKSUM_POLICY_IGNORE; case RepositoryPolicy.CHECKSUM_POLICY_WARN -> RepositoryPolicy.CHECKSUM_POLICY_WARN; - default -> throw new IllegalArgumentException( - "unknown repository checksum policy: " + artifactRepositoryPolicy); + default -> + throw new IllegalArgumentException("unknown repository checksum policy: " + artifactRepositoryPolicy); }; } } diff --git a/compat/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/relocation/UserPropertiesArtifactRelocationSource.java b/compat/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/relocation/UserPropertiesArtifactRelocationSource.java index b469672b790d..ea0004223afb 100644 --- a/compat/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/relocation/UserPropertiesArtifactRelocationSource.java +++ b/compat/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/relocation/UserPropertiesArtifactRelocationSource.java @@ -202,8 +202,9 @@ private static Artifact parseArtifact(String coords) { case 3 -> new DefaultArtifact(parts[0], parts[1], "*", "*", parts[2]); case 4 -> new DefaultArtifact(parts[0], parts[1], "*", parts[2], parts[3]); case 5 -> new DefaultArtifact(parts[0], parts[1], parts[2], parts[3], parts[4]); - default -> throw new IllegalArgumentException("Bad artifact coordinates " + coords - + ", expected format is :[:[:]]:"); + default -> + throw new IllegalArgumentException("Bad artifact coordinates " + coords + + ", expected format is :[:[:]]:"); }; return s; } diff --git a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java index 9844cfb8d400..0d5e5caa6411 100644 --- a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java +++ b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java @@ -430,9 +430,10 @@ protected void activateLogging(C context) throws Exception { switch (logLevelThreshold.toLowerCase(Locale.ENGLISH)) { case "warn", "warning" -> LogLevelRecorder.Level.WARN; case "error" -> LogLevelRecorder.Level.ERROR; - default -> throw new IllegalArgumentException( - logLevelThreshold - + " is not a valid log severity threshold. Valid severities are WARN/WARNING and ERROR."); + default -> + throw new IllegalArgumentException( + logLevelThreshold + + " is not a valid log severity threshold. Valid severities are WARN/WARNING and ERROR."); }; recorder.setMaxLevelAllowed(level); context.logger.info("Enabled to break the build on log level " + logLevelThreshold + "."); diff --git a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnsh/ShellInvoker.java b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnsh/ShellInvoker.java index 01c22ed1eb75..6dbc69d654b7 100644 --- a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnsh/ShellInvoker.java +++ b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnsh/ShellInvoker.java @@ -89,8 +89,7 @@ protected int execute(LookupContext context) throws Exception { DefaultParser parser = new DefaultParser(); parser.setRegexCommand("[:]{0,1}[a-zA-Z!]{1,}\\S*"); // change default regex to support shell commands - String banner = - """ + String banner = """ ░▒▓██████████████▓▒░ ░▒▓█▓▒░░▒▓█▓▒░░▒▓███████▓▒░ ░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░\s ░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░\s diff --git a/impl/maven-cli/src/main/java/org/apache/maven/cling/transfer/TransferResourceIdentifier.java b/impl/maven-cli/src/main/java/org/apache/maven/cling/transfer/TransferResourceIdentifier.java index 04af5e51a72f..1efb6ba785e4 100644 --- a/impl/maven-cli/src/main/java/org/apache/maven/cling/transfer/TransferResourceIdentifier.java +++ b/impl/maven-cli/src/main/java/org/apache/maven/cling/transfer/TransferResourceIdentifier.java @@ -28,7 +28,11 @@ * The {@link TransferResource} is not immutable and does not implement {@code Objects#equals} and {@code Objects#hashCode} methods, * making it not very suitable for usage in collections. */ -record TransferResourceIdentifier(String repositoryId, String repositoryUrl, String resourceName, @Nullable Path file) { +record TransferResourceIdentifier( + String repositoryId, + String repositoryUrl, + String resourceName, + @Nullable Path file) { TransferResourceIdentifier(TransferResource resource) { this(resource.getRepositoryId(), resource.getRepositoryUrl(), resource.getResourceName(), resource.getPath()); } diff --git a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvn/MavenInvokerTest.java b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvn/MavenInvokerTest.java index 2a1d8ab3433a..539cf8331df4 100644 --- a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvn/MavenInvokerTest.java +++ b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvn/MavenInvokerTest.java @@ -74,8 +74,7 @@ void conflictingExtensionsFromSameSource( @TempDir(cleanup = CleanupMode.ON_SUCCESS) Path cwd, @TempDir(cleanup = CleanupMode.ON_SUCCESS) Path userHome) throws Exception { - String projectExtensionsXml = - """ + String projectExtensionsXml = """ @@ -95,8 +94,7 @@ void conflictingExtensionsFromSameSource( Path projectExtensions = dotMvn.resolve("extensions.xml"); Files.writeString(projectExtensions, projectExtensionsXml); - String userExtensionsXml = - """ + String userExtensionsXml = """ @@ -122,8 +120,7 @@ void conflictingExtensionsFromDifferentSource( @TempDir(cleanup = CleanupMode.ON_SUCCESS) Path cwd, @TempDir(cleanup = CleanupMode.ON_SUCCESS) Path userHome) throws Exception { - String extensionsXml = - """ + String extensionsXml = """ @@ -163,8 +160,7 @@ void conflictingSettings( @TempDir(cleanup = CleanupMode.ON_SUCCESS) Path cwd, @TempDir(cleanup = CleanupMode.ON_SUCCESS) Path userHome) throws Exception { - String settingsXml = - """ + String settingsXml = """ diff --git a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvn/MavenInvokerTestSupport.java b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvn/MavenInvokerTestSupport.java index 9778cda9c471..52cde3a2b6f1 100644 --- a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvn/MavenInvokerTestSupport.java +++ b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvn/MavenInvokerTestSupport.java @@ -44,8 +44,7 @@ public abstract class MavenInvokerTestSupport { Path.of("target/dependency/org/jline/nativ").toAbsolutePath().toString()); } - public static final String POM_STRING = - """ + public static final String POM_STRING = """ @@ -79,8 +78,7 @@ public abstract class MavenInvokerTestSupport { """; - public static final String APP_JAVA_STRING = - """ + public static final String APP_JAVA_STRING = """ package org.apache.maven.samples.sample; public class App { diff --git a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/CompatibilityFixStrategyTest.java b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/CompatibilityFixStrategyTest.java index 91e12498c230..0a269060129b 100644 --- a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/CompatibilityFixStrategyTest.java +++ b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/CompatibilityFixStrategyTest.java @@ -144,8 +144,7 @@ class DuplicateDependencyFixesTests { @Test @DisplayName("should remove duplicate dependencies in dependencyManagement") void shouldRemoveDuplicateDependenciesInDependencyManagement() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -191,8 +190,7 @@ void shouldRemoveDuplicateDependenciesInDependencyManagement() throws Exception @Test @DisplayName("should remove duplicate dependencies in regular dependencies") void shouldRemoveDuplicateDependenciesInRegularDependencies() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -242,8 +240,7 @@ class DuplicatePluginFixesTests { @Test @DisplayName("should remove duplicate plugins in pluginManagement") void shouldRemoveDuplicatePluginsInPluginManagement() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 diff --git a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/GAVUtilsTest.java b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/GAVUtilsTest.java index 5585616ec495..e74aff47eed3 100644 --- a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/GAVUtilsTest.java +++ b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/GAVUtilsTest.java @@ -87,8 +87,7 @@ void shouldExtractGAVFromCompletePOM() throws Exception { @Test @DisplayName("should extract GAV with parent inheritance") void shouldExtractGAVWithParentInheritance() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -116,8 +115,7 @@ void shouldExtractGAVWithParentInheritance() throws Exception { @Test @DisplayName("should handle partial parent inheritance") void shouldHandlePartialParentInheritance() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -182,8 +180,7 @@ class GAVComputationTests { @Test @DisplayName("should compute GAVs from multiple POMs") void shouldComputeGAVsFromMultiplePOMs() throws Exception { - String parentPomXml = - """ + String parentPomXml = """ 4.0.0 @@ -194,8 +191,7 @@ void shouldComputeGAVsFromMultiplePOMs() throws Exception { """; - String childPomXml = - """ + String childPomXml = """ 4.0.0 @@ -239,8 +235,7 @@ void shouldHandleEmptyPOMMap() { @Test @DisplayName("should deduplicate identical GAVs") void shouldDeduplicateIdenticalGAVs() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -268,8 +263,7 @@ void shouldDeduplicateIdenticalGAVs() throws Exception { @Test @DisplayName("should skip POMs with incomplete GAVs") void shouldSkipPOMsWithIncompleteGAVs() throws Exception { - String validPomXml = - """ + String validPomXml = """ 4.0.0 @@ -279,8 +273,7 @@ void shouldSkipPOMsWithIncompleteGAVs() throws Exception { """; - String invalidPomXml = - """ + String invalidPomXml = """ 4.0.0 @@ -330,8 +323,7 @@ void shouldHandlePOMWithWhitespaceElements() throws Exception { @Test @DisplayName("should handle POM with empty elements") void shouldHandlePOMWithEmptyElements() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -372,8 +364,7 @@ void shouldHandlePOMWithSpecialCharacters() throws Exception { @Test @DisplayName("should handle deeply nested parent inheritance") void shouldHandleDeeplyNestedParentInheritance() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 diff --git a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/InferenceStrategyTest.java b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/InferenceStrategyTest.java index 766c30be58b3..f2a84de3a855 100644 --- a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/InferenceStrategyTest.java +++ b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/InferenceStrategyTest.java @@ -146,8 +146,7 @@ void shouldRemoveDependencyVersionForProjectArtifact() throws Exception { .artifactId("module-a") .build(); - String moduleBPomXml = - """ + String moduleBPomXml = """ @@ -199,8 +198,7 @@ void shouldRemoveDependencyVersionForProjectArtifact() throws Exception { @Test @DisplayName("should keep dependency version for external artifact") void shouldKeepDependencyVersionForExternalArtifact() throws Exception { - String modulePomXml = - """ + String modulePomXml = """ com.example @@ -280,8 +278,7 @@ void shouldKeepDependencyVersionWhenVersionMismatch() throws Exception { @Test @DisplayName("should handle plugin dependencies") void shouldHandlePluginDependencies() throws Exception { - String moduleAPomXml = - """ + String moduleAPomXml = """ com.example @@ -290,8 +287,7 @@ void shouldHandlePluginDependencies() throws Exception { """; - String moduleBPomXml = - """ + String moduleBPomXml = """ com.example @@ -347,8 +343,7 @@ class ParentInferenceTests { @Test @DisplayName("should remove parent groupId when child doesn't have explicit groupId") void shouldRemoveParentGroupIdWhenChildDoesntHaveExplicitGroupId() throws Exception { - String parentPomXml = - """ + String parentPomXml = """ 4.1.0 @@ -358,8 +353,7 @@ void shouldRemoveParentGroupIdWhenChildDoesntHaveExplicitGroupId() throws Except """; - String childPomXml = - """ + String childPomXml = """ 4.1.0 @@ -404,8 +398,7 @@ void shouldRemoveParentGroupIdWhenChildDoesntHaveExplicitGroupId() throws Except @Test @DisplayName("should keep parent groupId when child has explicit groupId") void shouldKeepParentGroupIdWhenChildHasExplicitGroupId() throws Exception { - String parentPomXml = - """ + String parentPomXml = """ 4.1.0 @@ -415,8 +408,7 @@ void shouldKeepParentGroupIdWhenChildHasExplicitGroupId() throws Exception { """; - String childPomXml = - """ + String childPomXml = """ 4.1.0 @@ -456,8 +448,7 @@ void shouldKeepParentGroupIdWhenChildHasExplicitGroupId() throws Exception { @Test @DisplayName("should not trim parent elements when parent is external") void shouldNotTrimParentElementsWhenParentIsExternal() throws Exception { - String childPomXml = - """ + String childPomXml = """ 4.1.0 @@ -497,8 +488,7 @@ void shouldNotTrimParentElementsWhenParentIsExternal() throws Exception { @DisplayName("should trim parent elements when parent is in reactor") void shouldTrimParentElementsWhenParentIsInReactor() throws Exception { // Create parent POM - String parentPomXml = - """ + String parentPomXml = """ 4.1.0 @@ -510,8 +500,7 @@ void shouldTrimParentElementsWhenParentIsInReactor() throws Exception { """; // Create child POM that references the parent - String childPomXml = - """ + String childPomXml = """ 4.1.0 @@ -557,8 +546,7 @@ class Maven400LimitedInferenceTests { @Test @DisplayName("should remove child groupId and version when they match parent in 4.0.0") void shouldRemoveChildGroupIdAndVersionWhenTheyMatchParentIn400() throws Exception { - String parentPomXml = - """ + String parentPomXml = """ 4.0.0 @@ -569,8 +557,7 @@ void shouldRemoveChildGroupIdAndVersionWhenTheyMatchParentIn400() throws Excepti """; - String childPomXml = - """ + String childPomXml = """ 4.0.0 @@ -622,8 +609,7 @@ void shouldRemoveChildGroupIdAndVersionWhenTheyMatchParentIn400() throws Excepti @Test @DisplayName("should keep child groupId when it differs from parent in 4.0.0") void shouldKeepChildGroupIdWhenItDiffersFromParentIn400() throws Exception { - String parentPomXml = - """ + String parentPomXml = """ 4.0.0 @@ -634,8 +620,7 @@ void shouldKeepChildGroupIdWhenItDiffersFromParentIn400() throws Exception { """; - String childPomXml = - """ + String childPomXml = """ 4.0.0 @@ -678,8 +663,7 @@ void shouldKeepChildGroupIdWhenItDiffersFromParentIn400() throws Exception { @Test @DisplayName("should handle partial inheritance in 4.0.0") void shouldHandlePartialInheritanceIn400() throws Exception { - String parentPomXml = - """ + String parentPomXml = """ 4.0.0 @@ -690,8 +674,7 @@ void shouldHandlePartialInheritanceIn400() throws Exception { """; - String childPomXml = - """ + String childPomXml = """ 4.0.0 diff --git a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/JDomUtilsTest.java b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/JDomUtilsTest.java index 1ab9a9d7308f..412c9f63edf0 100644 --- a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/JDomUtilsTest.java +++ b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/JDomUtilsTest.java @@ -47,8 +47,7 @@ void setUp() { @Test void testDetectTwoSpaceIndentation() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -76,8 +75,7 @@ void testDetectTwoSpaceIndentation() throws Exception { @Test void testDetectFourSpaceIndentation() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -105,8 +103,7 @@ void testDetectFourSpaceIndentation() throws Exception { @Test void testDetectTabIndentation() throws Exception { - String pomXml = - """ + String pomXml = """ \t4.0.0 @@ -135,8 +132,7 @@ void testDetectTabIndentation() throws Exception { @Test void testDetectIndentationWithMixedContent() throws Exception { // POM with mostly 4-space indentation but some 2-space (should prefer 4-space) - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -173,8 +169,7 @@ void testDetectIndentationWithMixedContent() throws Exception { @Test void testDetectIndentationFromBuildElement() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -204,8 +199,7 @@ void testDetectIndentationFromBuildElement() throws Exception { @Test void testDetectIndentationFallbackToDefault() throws Exception { // Minimal POM with no clear indentation pattern - String pomXml = - """ + String pomXml = """ 4.0.0testtest1.0.0 """; @@ -219,8 +213,7 @@ void testDetectIndentationFallbackToDefault() throws Exception { @Test void testDetectIndentationConsistency() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -258,8 +251,7 @@ void testDetectIndentationConsistency() throws Exception { @Test void testAddElementWithCorrectIndentation() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -299,8 +291,7 @@ void testAddElementWithCorrectIndentation() throws Exception { @Test void testRealWorldScenarioWithPluginManagementAddition() throws Exception { // Real-world POM with 4-space indentation - String pomXml = - """ + String pomXml = """ 4.0.0 diff --git a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/ModelUpgradeStrategyTest.java b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/ModelUpgradeStrategyTest.java index ab20e4c13298..83e5c80a06c8 100644 --- a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/ModelUpgradeStrategyTest.java +++ b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/ModelUpgradeStrategyTest.java @@ -206,8 +206,7 @@ class NamespaceUpdateTests { @Test @DisplayName("should update namespace recursively") void shouldUpdateNamespaceRecursively() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -257,8 +256,7 @@ void shouldUpdateNamespaceRecursively() throws Exception { @Test @DisplayName("should convert modules to subprojects in 4.1.0") void shouldConvertModulesToSubprojectsIn410() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -354,8 +352,7 @@ void shouldUpgradeDeprecatedPhasesIn410() throws Exception { } private Document createDocumentWithDeprecatedPhases() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -633,8 +630,7 @@ private void verifyProfilePhases(Document document) { @Test @DisplayName("should not upgrade phases when upgrading to 4.0.0") void shouldNotUpgradePhasesWhenUpgradingTo400() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -691,8 +687,7 @@ void shouldNotUpgradePhasesWhenUpgradingTo400() throws Exception { @Test @DisplayName("should preserve non-deprecated phases") void shouldPreserveNonDeprecatedPhases() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -792,8 +787,7 @@ class DowngradeHandlingTests { @Test @DisplayName("should fail with error when attempting downgrade from 4.1.0 to 4.0.0") void shouldFailWhenAttemptingDowngrade() throws Exception { - String pomXml = - """ + String pomXml = """ 4.1.0 @@ -819,8 +813,7 @@ void shouldFailWhenAttemptingDowngrade() throws Exception { @Test @DisplayName("should succeed when upgrading from 4.0.0 to 4.1.0") void shouldSucceedWhenUpgrading() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 diff --git a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/ModelVersionUtilsTest.java b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/ModelVersionUtilsTest.java index 531c52c1ab20..b1c4dd599ba3 100644 --- a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/ModelVersionUtilsTest.java +++ b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/ModelVersionUtilsTest.java @@ -90,8 +90,7 @@ void shouldDetect410ModelVersion() throws Exception { @Test @DisplayName("should return default version when model version is missing") void shouldReturnDefaultVersionWhenModelVersionMissing() throws Exception { - String pomXml = - """ + String pomXml = """ test @@ -108,8 +107,7 @@ void shouldReturnDefaultVersionWhenModelVersionMissing() throws Exception { @Test @DisplayName("should detect version from namespace when model version is missing") void shouldDetectVersionFromNamespaceWhenModelVersionMissing() throws Exception { - String pomXml = - """ + String pomXml = """ test @@ -275,8 +273,7 @@ class ModelVersionUpdateTests { @Test @DisplayName("should update model version in document") void shouldUpdateModelVersionInDocument() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -296,8 +293,7 @@ void shouldUpdateModelVersionInDocument() throws Exception { @Test @DisplayName("should add model version when missing") void shouldAddModelVersionWhenMissing() throws Exception { - String pomXml = - """ + String pomXml = """ test @@ -317,8 +313,7 @@ void shouldAddModelVersionWhenMissing() throws Exception { @Test @DisplayName("should remove model version from document") void shouldRemoveModelVersionFromDocument() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -340,8 +335,7 @@ void shouldRemoveModelVersionFromDocument() throws Exception { @Test @DisplayName("should handle missing model version in removal") void shouldHandleMissingModelVersionInRemoval() throws Exception { - String pomXml = - """ + String pomXml = """ test @@ -396,8 +390,7 @@ class EdgeCases { @Test @DisplayName("should handle missing modelVersion element") void shouldHandleMissingModelVersion() throws Exception { - String pomXml = - """ + String pomXml = """ com.example @@ -457,8 +450,7 @@ void shouldHandleCustomModelVersionValues() throws Exception { @Test @DisplayName("should handle modelVersion with whitespace") void shouldHandleModelVersionWithWhitespace() throws Exception { - String pomXml = - """ + String pomXml = """ 4.1.0 diff --git a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/PluginUpgradeStrategyTest.java b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/PluginUpgradeStrategyTest.java index e84b4269842c..69cc3ec0fe91 100644 --- a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/PluginUpgradeStrategyTest.java +++ b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/PluginUpgradeStrategyTest.java @@ -163,8 +163,7 @@ void shouldUpgradePluginVersionWhenBelowMinimum() throws Exception { @Test @DisplayName("should not modify plugin when version is already sufficient") void shouldNotModifyPluginWhenVersionAlreadySufficient() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -196,8 +195,7 @@ void shouldNotModifyPluginWhenVersionAlreadySufficient() throws Exception { @Test @DisplayName("should upgrade plugin in pluginManagement") void shouldUpgradePluginInPluginManagement() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -241,8 +239,7 @@ void shouldUpgradePluginInPluginManagement() throws Exception { @Test @DisplayName("should upgrade plugin with property version") void shouldUpgradePluginWithPropertyVersion() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -284,8 +281,7 @@ void shouldUpgradePluginWithPropertyVersion() throws Exception { @Test @DisplayName("should not upgrade when version is already higher") void shouldNotUpgradeWhenVersionAlreadyHigher() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -325,8 +321,7 @@ void shouldNotUpgradeWhenVersionAlreadyHigher() throws Exception { @Test @DisplayName("should upgrade plugin without explicit groupId") void shouldUpgradePluginWithoutExplicitGroupId() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -368,8 +363,7 @@ void shouldUpgradePluginWithoutExplicitGroupId() throws Exception { @Test @DisplayName("should not upgrade plugin without version") void shouldNotUpgradePluginWithoutVersion() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -401,8 +395,7 @@ void shouldNotUpgradePluginWithoutVersion() throws Exception { @Test @DisplayName("should not upgrade when property is not found") void shouldNotUpgradeWhenPropertyNotFound() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -439,8 +432,7 @@ class PluginManagementTests { @Test @DisplayName("should add pluginManagement before existing plugins section") void shouldAddPluginManagementBeforeExistingPluginsSection() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -537,8 +529,7 @@ class ErrorHandlingTests { @Test @DisplayName("should handle malformed POM gracefully") void shouldHandleMalformedPOMGracefully() throws Exception { - String malformedPomXml = - """ + String malformedPomXml = """ 4.0.0 @@ -589,8 +580,7 @@ class XmlFormattingTests { @Test @DisplayName("should format pluginManagement with proper indentation") void shouldFormatPluginManagementWithProperIndentation() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -640,8 +630,7 @@ void shouldFormatPluginManagementWithProperIndentation() throws Exception { @DisplayName("should format pluginManagement with proper indentation when added") void shouldFormatPluginManagementWithProperIndentationWhenAdded() throws Exception { // Use a POM that will trigger pluginManagement addition by having a plugin without version - String pomXml = - """ + String pomXml = """ 4.0.0 diff --git a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/TestUtils.java b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/TestUtils.java index 40dff68c44ab..b7a5342f7b9e 100644 --- a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/TestUtils.java +++ b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/TestUtils.java @@ -194,8 +194,7 @@ public static UpgradeOptions createOptionsWithInfer(boolean infer) { * @return POM XML string */ public static String createSimplePom(String groupId, String artifactId, String version) { - return String.format( - """ + return String.format(""" 4.0.0 @@ -203,8 +202,7 @@ public static String createSimplePom(String groupId, String artifactId, String v %s %s - """, - groupId, artifactId, version); + """, groupId, artifactId, version); } /** @@ -218,8 +216,7 @@ public static String createSimplePom(String groupId, String artifactId, String v */ public static String createPomWithParent( String parentGroupId, String parentArtifactId, String parentVersion, String artifactId) { - return String.format( - """ + return String.format(""" 4.0.0 @@ -230,7 +227,6 @@ public static String createPomWithParent( %s - """, - parentGroupId, parentArtifactId, parentVersion, artifactId); + """, parentGroupId, parentArtifactId, parentVersion, artifactId); } } diff --git a/impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlanExecutor.java b/impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlanExecutor.java index 7e8428a6b168..3ed6c002d1bd 100644 --- a/impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlanExecutor.java +++ b/impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlanExecutor.java @@ -298,8 +298,7 @@ private void checkThreadSafety(BuildPlan buildPlan) { .filter(execution -> !execution.getMojoDescriptor().isV4Api()) .collect(Collectors.toSet()); if (!unsafeExecutions.isEmpty()) { - for (String s : MultilineMessageHelper.format( - """ + for (String s : MultilineMessageHelper.format(""" Your build is requesting concurrent execution, but this project contains the \ following plugin(s) that have goals not built with Maven 4 to support concurrent \ execution. While this /may/ work fine, please look for plugin updates and/or \ diff --git a/impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java b/impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java index 1de9eeccc559..08f3bd53b293 100644 --- a/impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java +++ b/impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java @@ -880,8 +880,9 @@ private void initParent(MavenProject project, ModelBuilderResult result) { reposes.addAll(project.getRemoteArtifactRepositories()); mergedRepositories = List.copyOf(reposes); } - default -> throw new IllegalArgumentException( - "Unsupported repository merging: " + request.getRepositoryMerging()); + default -> + throw new IllegalArgumentException( + "Unsupported repository merging: " + request.getRepositoryMerging()); } // Store the computed repositories for this project in BuildSession storage diff --git a/impl/maven-core/src/test/java/org/apache/maven/project/RepositoryLeakageTest.java b/impl/maven-core/src/test/java/org/apache/maven/project/RepositoryLeakageTest.java index b5ff18f8723d..8052e055274c 100644 --- a/impl/maven-core/src/test/java/org/apache/maven/project/RepositoryLeakageTest.java +++ b/impl/maven-core/src/test/java/org/apache/maven/project/RepositoryLeakageTest.java @@ -46,9 +46,7 @@ public void testRepositoryLeakageBetweenSiblings() throws Exception { try { // Create parent POM Path parentPom = tempDir.resolve("pom.xml"); - Files.writeString( - parentPom, - """ + Files.writeString(parentPom, """ @@ -327,8 +326,7 @@ void defaultFs3CaptureOutputWithForcedOffColor() throws Exception { """; - public static final String APP_JAVA_STRING = - """ + public static final String APP_JAVA_STRING = """ package org.apache.maven.samples.sample; public class App { diff --git a/impl/maven-impl/src/main/java/org/apache/maven/impl/cache/Cache.java b/impl/maven-impl/src/main/java/org/apache/maven/impl/cache/Cache.java index 440a0a860e5e..4838b36321b4 100644 --- a/impl/maven-impl/src/main/java/org/apache/maven/impl/cache/Cache.java +++ b/impl/maven-impl/src/main/java/org/apache/maven/impl/cache/Cache.java @@ -520,8 +520,9 @@ private ComputeReference getComputingReference(ReferenceType referenceType) { case SOFT -> SoftComputeReference.computing(valueQueue); case WEAK -> WeakComputeReference.computing(valueQueue); case HARD -> HardComputeReference.computing(valueQueue); - case NONE -> throw new IllegalArgumentException( - "NONE reference type should be handled before calling this method"); + case NONE -> + throw new IllegalArgumentException( + "NONE reference type should be handled before calling this method"); }; } @@ -535,8 +536,9 @@ private ComputeReference getValueReference(V value, ReferenceType referenceTy case SOFT -> new SoftComputeReference<>(value, valueQueue); case WEAK -> new WeakComputeReference<>(value, valueQueue); case HARD -> new HardComputeReference<>(value, valueQueue); - case NONE -> throw new IllegalArgumentException( - "NONE reference type should be handled before calling this method"); + case NONE -> + throw new IllegalArgumentException( + "NONE reference type should be handled before calling this method"); }; } @@ -550,8 +552,9 @@ private RefConcurrentReference getKeyReference(K key, ReferenceType reference case SOFT -> new SoftRefConcurrentReference<>(key, keyQueue); case WEAK -> new WeakRefConcurrentReference<>(key, keyQueue); case HARD -> new HardRefConcurrentReference<>(key, keyQueue); - case NONE -> throw new IllegalArgumentException( - "NONE reference type should be handled before calling this method"); + case NONE -> + throw new IllegalArgumentException( + "NONE reference type should be handled before calling this method"); }; } diff --git a/impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelValidator.java b/impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelValidator.java index c3bc8e7320b3..b97064f3117f 100644 --- a/impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelValidator.java +++ b/impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelValidator.java @@ -1791,9 +1791,9 @@ private boolean validateProfileId( private boolean isValidProfileId(String id) { return switch (id.charAt(0)) { // avoid first character that has special CLI meaning in "mvn -P xxx" - // +: activate - // -, !: deactivate - // ?: optional + // +: activate + // -, !: deactivate + // ?: optional case '+', '-', '!', '?' -> false; default -> true; }; diff --git a/impl/maven-impl/src/main/java/org/apache/maven/impl/resolver/ArtifactDescriptorUtils.java b/impl/maven-impl/src/main/java/org/apache/maven/impl/resolver/ArtifactDescriptorUtils.java index a7214d5b2904..a49bb2fde41f 100644 --- a/impl/maven-impl/src/main/java/org/apache/maven/impl/resolver/ArtifactDescriptorUtils.java +++ b/impl/maven-impl/src/main/java/org/apache/maven/impl/resolver/ArtifactDescriptorUtils.java @@ -84,8 +84,8 @@ public static String toRepositoryChecksumPolicy(final String artifactRepositoryP case RepositoryPolicy.CHECKSUM_POLICY_FAIL -> RepositoryPolicy.CHECKSUM_POLICY_FAIL; case RepositoryPolicy.CHECKSUM_POLICY_IGNORE -> RepositoryPolicy.CHECKSUM_POLICY_IGNORE; case RepositoryPolicy.CHECKSUM_POLICY_WARN -> RepositoryPolicy.CHECKSUM_POLICY_WARN; - default -> throw new IllegalArgumentException( - "unknown repository checksum policy: " + artifactRepositoryPolicy); + default -> + throw new IllegalArgumentException("unknown repository checksum policy: " + artifactRepositoryPolicy); }; } } diff --git a/impl/maven-impl/src/main/java/org/apache/maven/impl/resolver/relocation/UserPropertiesArtifactRelocationSource.java b/impl/maven-impl/src/main/java/org/apache/maven/impl/resolver/relocation/UserPropertiesArtifactRelocationSource.java index a6425adc658c..a667b2a2864d 100644 --- a/impl/maven-impl/src/main/java/org/apache/maven/impl/resolver/relocation/UserPropertiesArtifactRelocationSource.java +++ b/impl/maven-impl/src/main/java/org/apache/maven/impl/resolver/relocation/UserPropertiesArtifactRelocationSource.java @@ -198,8 +198,9 @@ private static Artifact parseArtifact(String coords) { case 3 -> new DefaultArtifact(parts[0], parts[1], "*", "*", parts[2]); case 4 -> new DefaultArtifact(parts[0], parts[1], "*", parts[2], parts[3]); case 5 -> new DefaultArtifact(parts[0], parts[1], parts[2], parts[3], parts[4]); - default -> throw new IllegalArgumentException("Bad artifact coordinates " + coords - + ", expected format is :[:[:]]:"); + default -> + throw new IllegalArgumentException("Bad artifact coordinates " + coords + + ", expected format is :[:[:]]:"); }; return s; } diff --git a/impl/maven-impl/src/main/java/org/apache/maven/impl/util/Os.java b/impl/maven-impl/src/main/java/org/apache/maven/impl/util/Os.java index 667f02ad8739..e95bc0a4d4b2 100644 --- a/impl/maven-impl/src/main/java/org/apache/maven/impl/util/Os.java +++ b/impl/maven-impl/src/main/java/org/apache/maven/impl/util/Os.java @@ -190,9 +190,10 @@ public static boolean isFamily(String family, String actualOsName) { case FAMILY_DOS -> PATH_SEP.equals(";") && !isFamily(FAMILY_NETWARE, actualOsName) && !isWindows; case FAMILY_MAC -> actualOsName.contains(FAMILY_MAC) || actualOsName.contains(DARWIN); case FAMILY_TANDEM -> actualOsName.contains("nonstop_kernel"); - case FAMILY_UNIX -> PATH_SEP.equals(":") - && !isFamily(FAMILY_OPENVMS, actualOsName) - && (!isFamily(FAMILY_MAC, actualOsName) || actualOsName.endsWith("x")); + case FAMILY_UNIX -> + PATH_SEP.equals(":") + && !isFamily(FAMILY_OPENVMS, actualOsName) + && (!isFamily(FAMILY_MAC, actualOsName) || actualOsName.endsWith("x")); case FAMILY_ZOS -> actualOsName.contains(FAMILY_ZOS) || actualOsName.contains(FAMILY_OS390); case FAMILY_OS400 -> actualOsName.contains(FAMILY_OS400); case FAMILY_OPENVMS -> actualOsName.contains(FAMILY_OPENVMS); diff --git a/impl/maven-impl/src/test/java/org/apache/maven/impl/DefaultModelXmlFactoryTest.java b/impl/maven-impl/src/test/java/org/apache/maven/impl/DefaultModelXmlFactoryTest.java index badb8612da3f..8a8b4b21b017 100644 --- a/impl/maven-impl/src/test/java/org/apache/maven/impl/DefaultModelXmlFactoryTest.java +++ b/impl/maven-impl/src/test/java/org/apache/maven/impl/DefaultModelXmlFactoryTest.java @@ -45,8 +45,7 @@ void setUp() { @Test void testValidNamespaceWithModelVersion400() throws Exception { - String xml = - """ + String xml = """ 4.0.0 """; @@ -61,8 +60,7 @@ void testValidNamespaceWithModelVersion400() throws Exception { @Test void testValidNamespaceWithModelVersion410() throws Exception { - String xml = - """ + String xml = """ 4.1.0 """; @@ -77,8 +75,7 @@ void testValidNamespaceWithModelVersion410() throws Exception { @Test void testInvalidNamespaceWithModelVersion410() { - String xml = - """ + String xml = """ 4.1.0 """; @@ -93,8 +90,7 @@ void testInvalidNamespaceWithModelVersion410() { @Test void testNoNamespaceWithModelVersion400() throws Exception { - String xml = - """ + String xml = """ 4.0.0 """; @@ -114,8 +110,7 @@ void testNullRequest() { @Test void testMalformedModelVersion() throws Exception { - String xml = - """ + String xml = """ invalid.version """; @@ -130,8 +125,7 @@ void testMalformedModelVersion() throws Exception { @Test void testWriteWithoutFormatterDisablesLocationTracking() throws Exception { // minimal valid model we can round-trip - String xml = - """ + String xml = """ 4.0.0 g @@ -157,8 +151,7 @@ void testWriteWithoutFormatterDisablesLocationTracking() throws Exception { @Test void testWriteWithFormatterEnablesLocationTracking() throws Exception { - String xml = - """ + String xml = """ 4.0.0 g diff --git a/impl/maven-impl/src/test/java/org/apache/maven/impl/DefaultPluginXmlFactoryTest.java b/impl/maven-impl/src/test/java/org/apache/maven/impl/DefaultPluginXmlFactoryTest.java index e566e4d9fcfb..bd4d3b7b22d1 100644 --- a/impl/maven-impl/src/test/java/org/apache/maven/impl/DefaultPluginXmlFactoryTest.java +++ b/impl/maven-impl/src/test/java/org/apache/maven/impl/DefaultPluginXmlFactoryTest.java @@ -52,8 +52,7 @@ class DefaultPluginXmlFactoryTest { private static final String NAME = "sample-plugin-" + randomUUID(); - private static final String SAMPLE_PLUGIN_XML = - """ + private static final String SAMPLE_PLUGIN_XML = """ %s @@ -61,8 +60,7 @@ class DefaultPluginXmlFactoryTest { sample-plugin 1.0.0 - """ - .formatted(NAME); + """.formatted(NAME); private final DefaultPluginXmlFactory defaultPluginXmlFactory = new DefaultPluginXmlFactory(); diff --git a/impl/maven-impl/src/test/java/org/apache/maven/impl/XmlFactoryTransformerTest.java b/impl/maven-impl/src/test/java/org/apache/maven/impl/XmlFactoryTransformerTest.java index aa1d3e152219..5ed05895be84 100644 --- a/impl/maven-impl/src/test/java/org/apache/maven/impl/XmlFactoryTransformerTest.java +++ b/impl/maven-impl/src/test/java/org/apache/maven/impl/XmlFactoryTransformerTest.java @@ -47,8 +47,7 @@ void testModelXmlFactoryUsesTransformer() throws Exception { return value; }; - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -90,8 +89,7 @@ void testSettingsXmlFactoryUsesTransformer() throws Exception { return value; }; - String settingsXml = - """ + String settingsXml = """ /path/to/local/repo @@ -137,8 +135,7 @@ void testToolchainsXmlFactoryUsesTransformer() throws Exception { return value; }; - String toolchainsXml = - """ + String toolchainsXml = """ @@ -195,8 +192,7 @@ void testPluginXmlFactoryUsesTransformer() throws Exception { return value; }; - String pluginXml = - """ + String pluginXml = """ test-plugin diff --git a/impl/maven-impl/src/test/java/org/apache/maven/impl/cache/CacheConfigurationTest.java b/impl/maven-impl/src/test/java/org/apache/maven/impl/cache/CacheConfigurationTest.java index 0edc19236d3e..5eb96fef19e2 100644 --- a/impl/maven-impl/src/test/java/org/apache/maven/impl/cache/CacheConfigurationTest.java +++ b/impl/maven-impl/src/test/java/org/apache/maven/impl/cache/CacheConfigurationTest.java @@ -116,8 +116,7 @@ void testParseWildcardSelector() { @Test void testParseMultipleSelectors() { - String configString = - """ + String configString = """ ModelBuilderRequest { scope: session, ref: soft } ArtifactResolutionRequest { scope: request, ref: hard } * VersionRangeRequest { ref: weak } @@ -271,9 +270,7 @@ void testEmptyConfiguration() { @Test void testPartialConfigurationMerging() { - userProperties.put( - Constants.MAVEN_CACHE_CONFIG_PROPERTY, - """ + userProperties.put(Constants.MAVEN_CACHE_CONFIG_PROPERTY, """ ModelBuilderRequest { scope: session } * ModelBuilderRequest { ref: hard } """); diff --git a/impl/maven-impl/src/test/java/org/apache/maven/impl/model/InterningTransformerTest.java b/impl/maven-impl/src/test/java/org/apache/maven/impl/model/InterningTransformerTest.java index 53163526583d..87c10d3e19c4 100644 --- a/impl/maven-impl/src/test/java/org/apache/maven/impl/model/InterningTransformerTest.java +++ b/impl/maven-impl/src/test/java/org/apache/maven/impl/model/InterningTransformerTest.java @@ -209,8 +209,7 @@ void testTransformerIsUsedDuringPomParsing() throws Exception { return value; }; - String pomXml = - """ + String pomXml = """ 4.0.0 @@ -262,8 +261,7 @@ void testTransformerIsUsedDuringPomParsing() throws Exception { @Test void testInterningTransformerWithRealPomParsing() throws Exception { - String pomXml = - """ + String pomXml = """ 4.0.0 diff --git a/impl/maven-impl/src/test/java/org/apache/maven/impl/model/ParentCycleDetectionTest.java b/impl/maven-impl/src/test/java/org/apache/maven/impl/model/ParentCycleDetectionTest.java index 3fa6eb88ceff..7fb271020539 100644 --- a/impl/maven-impl/src/test/java/org/apache/maven/impl/model/ParentCycleDetectionTest.java +++ b/impl/maven-impl/src/test/java/org/apache/maven/impl/model/ParentCycleDetectionTest.java @@ -59,9 +59,7 @@ void testParentResolutionCycleDetectionWithRelativePath(@TempDir Path tempDir) t // Create a parent resolution cycle using relativePath: child -> parent -> child // This reproduces the same issue as the integration test MavenITmng11009StackOverflowParentResolutionTest Path childPom = tempDir.resolve("pom.xml"); - Files.writeString( - childPom, - """ + Files.writeString(childPom, """ 4.0.0 @@ -78,9 +76,7 @@ void testParentResolutionCycleDetectionWithRelativePath(@TempDir Path tempDir) t Path parentPom = tempDir.resolve("parent").resolve("pom.xml"); Files.createDirectories(parentPom.getParent()); - Files.writeString( - parentPom, - """ + Files.writeString(parentPom, """ 4.0.0 @@ -132,9 +128,7 @@ void testDirectCycleDetection(@TempDir Path tempDir) throws IOException { // Create a direct cycle: A -> B -> A Path pomA = tempDir.resolve("a").resolve("pom.xml"); Files.createDirectories(pomA.getParent()); - Files.writeString( - pomA, - """ + Files.writeString(pomA, """ 4.0.0 @@ -152,9 +146,7 @@ void testDirectCycleDetection(@TempDir Path tempDir) throws IOException { Path pomB = tempDir.resolve("b").resolve("pom.xml"); Files.createDirectories(pomB.getParent()); - Files.writeString( - pomB, - """ + Files.writeString(pomB, """ 4.0.0 @@ -203,9 +195,7 @@ void testMultipleModulesWithSameParentDoNotCauseCycle(@TempDir Path tempDir) thr // Create a scenario like the failing test: multiple modules with the same parent Path parentPom = tempDir.resolve("parent").resolve("pom.xml"); Files.createDirectories(parentPom.getParent()); - Files.writeString( - parentPom, - """ + Files.writeString(parentPom, """ 4.1.0 @@ -218,9 +208,7 @@ void testMultipleModulesWithSameParentDoNotCauseCycle(@TempDir Path tempDir) thr Path moduleA = tempDir.resolve("module-a").resolve("pom.xml"); Files.createDirectories(moduleA.getParent()); - Files.writeString( - moduleA, - """ + Files.writeString(moduleA, """ 4.1.0 @@ -236,9 +224,7 @@ void testMultipleModulesWithSameParentDoNotCauseCycle(@TempDir Path tempDir) thr Path moduleB = tempDir.resolve("module-b").resolve("pom.xml"); Files.createDirectories(moduleB.getParent()); - Files.writeString( - moduleB, - """ + Files.writeString(moduleB, """ 4.1.0 diff --git a/impl/maven-xml/src/test/java/org/apache/maven/internal/xml/XmlNodeImplTest.java b/impl/maven-xml/src/test/java/org/apache/maven/internal/xml/XmlNodeImplTest.java index 541b99c45131..e9805171948d 100644 --- a/impl/maven-xml/src/test/java/org/apache/maven/internal/xml/XmlNodeImplTest.java +++ b/impl/maven-xml/src/test/java/org/apache/maven/internal/xml/XmlNodeImplTest.java @@ -153,8 +153,7 @@ void testCombineChildrenAppend() throws Exception { @Test void testAppend() throws Exception { - String lhs = - """ + String lhs = """ -Xmaxerrs @@ -163,8 +162,7 @@ void testAppend() throws Exception { 100 """; - String result = - """ + String result = """ -Xmaxerrs @@ -324,15 +322,13 @@ void testPreserveDominantEmptyNode2() throws XMLStreamException, IOException { */ @Test void testShouldPerformAppendAtFirstSubElementLevel() throws XMLStreamException { - String lhs = - """ + String lhs = """ t1s1Value t1s2Value """; - String rhs = - """ + String rhs = """ t2s1Value t2s2Value diff --git a/pom.xml b/pom.xml index f2601867d6c7..8aa774908112 100644 --- a/pom.xml +++ b/pom.xml @@ -172,6 +172,9 @@ under the License. 2.10.4 + 3.0.0 + 2.80.0 + 0.14.0 @@ -929,6 +932,10 @@ under the License. + + com.diffplug.spotless + spotless-maven-plugin +