diff --git a/CHANGES.md b/CHANGES.md index 7e4a8c53a8..e94f0c7446 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -15,6 +15,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( * Respect `.editorconfig` settings for formatting shell via `shfmt` ([#2031](https://github.com/diffplug/spotless/pull/2031)) ### Changes * Bump default `ktfmt` version to latest `0.46` -> `0.47`. ([#2045](https://github.com/diffplug/spotless/pull/2045)) +* Bump default `sortpom` version to latest `3.2.1` -> `3.4.0`. ([#2049](https://github.com/diffplug/spotless/pull/2049)) * Bump default `shfmt` version to latest `3.7.0` -> `3.8.0`. ([#2050](https://github.com/diffplug/spotless/pull/2050)) ### Removed * **BREAKING** Remove `JarState.getMavenCoordinate(String prefix)`. ([#1945](https://github.com/diffplug/spotless/pull/1945)) diff --git a/lib/build.gradle b/lib/build.gradle index 8d313f123a..7b52442f92 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -128,8 +128,8 @@ dependencies { // scalafmt scalafmtCompileOnly "org.scalameta:scalafmt-core_2.13:3.7.3" // sortPom - sortPomCompileOnly 'com.github.ekryd.sortpom:sortpom-sorter:3.2.1' - sortPomCompileOnly 'org.slf4j:slf4j-api:2.0.0' + sortPomCompileOnly 'com.github.ekryd.sortpom:sortpom-sorter:3.4.0' + sortPomCompileOnly 'org.slf4j:slf4j-api:2.0.12' // zjsonPatch zjsonPatchCompileOnly 'com.flipkart.zjsonpatch:zjsonpatch:0.4.14' } diff --git a/lib/src/main/java/com/diffplug/spotless/pom/SortPomCfg.java b/lib/src/main/java/com/diffplug/spotless/pom/SortPomCfg.java index 8315035dc7..c24e91cf80 100644 --- a/lib/src/main/java/com/diffplug/spotless/pom/SortPomCfg.java +++ b/lib/src/main/java/com/diffplug/spotless/pom/SortPomCfg.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2023 DiffPlug + * Copyright 2021-2024 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ public class SortPomCfg implements Serializable { private static final long serialVersionUID = 1L; - public String version = "3.2.1"; + public String version = "3.4.0"; public String encoding = "UTF-8"; @@ -33,6 +33,8 @@ public class SortPomCfg implements Serializable { public boolean keepBlankLines = true; + public boolean endWithNewline = true; + public int nrOfIndentSpace = 2; public boolean indentBlankLines = false; diff --git a/lib/src/sortPom/java/com/diffplug/spotless/glue/pom/SortPomFormatterFunc.java b/lib/src/sortPom/java/com/diffplug/spotless/glue/pom/SortPomFormatterFunc.java index 4dcde62bae..57b96d70c7 100644 --- a/lib/src/sortPom/java/com/diffplug/spotless/glue/pom/SortPomFormatterFunc.java +++ b/lib/src/sortPom/java/com/diffplug/spotless/glue/pom/SortPomFormatterFunc.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2023 DiffPlug + * Copyright 2021-2024 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ public String apply(String input) throws Exception { .setPomFile(pom) .setFileOutput(false, null, null, false) .setEncoding(cfg.encoding) - .setFormatting(cfg.lineSeparator, cfg.expandEmptyElements, cfg.spaceBeforeCloseEmptyElement, cfg.keepBlankLines) + .setFormatting(cfg.lineSeparator, cfg.expandEmptyElements, cfg.spaceBeforeCloseEmptyElement, cfg.keepBlankLines, cfg.endWithNewline) .setIndent(cfg.nrOfIndentSpace, cfg.indentBlankLines, cfg.indentSchemaLocation) .setSortOrder(cfg.sortOrderFile, cfg.predefinedSortOrder) .setSortEntities(cfg.sortDependencies, cfg.sortDependencyExclusions, cfg.sortDependencyManagement, diff --git a/plugin-gradle/CHANGES.md b/plugin-gradle/CHANGES.md index 20c78e8808..bac42cee6e 100644 --- a/plugin-gradle/CHANGES.md +++ b/plugin-gradle/CHANGES.md @@ -7,6 +7,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( * Ignore system git config when running tests ([#1990](https://github.com/diffplug/spotless/issues/1990)) ### Changes * Bump default `ktfmt` version to latest `0.46` -> `0.47`. ([#2045](https://github.com/diffplug/spotless/pull/2045)) +* Bump default `sortpom` version to latest `3.2.1` -> `3.4.0`. ([#2049](https://github.com/diffplug/spotless/pull/2049)) * Bump default `shfmt` version to latest `3.7.0` -> `3.8.0`. ([#2050](https://github.com/diffplug/spotless/pull/2050)) ### Added * Respect `.editorconfig` settings for formatting shell via `shfmt` ([#2031](https://github.com/diffplug/spotless/pull/2031)) diff --git a/plugin-maven/CHANGES.md b/plugin-maven/CHANGES.md index 1178b93603..35de3c18ac 100644 --- a/plugin-maven/CHANGES.md +++ b/plugin-maven/CHANGES.md @@ -7,6 +7,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( * Ignore system git config when running tests ([#1990](https://github.com/diffplug/spotless/issues/1990)) ### Changes * Bump default `ktfmt` version to latest `0.46` -> `0.47`. ([#2045](https://github.com/diffplug/spotless/pull/2045)) +* Bump default `sortpom` version to latest `3.2.1` -> `3.4.0`. ([#2049](https://github.com/diffplug/spotless/pull/2049)) * Bump default `shfmt` version to latest `3.7.0` -> `3.8.0`. ([#2050](https://github.com/diffplug/spotless/pull/2050)) ### Added * Respect `.editorconfig` settings for formatting shell via `shfmt` ([#2031](https://github.com/diffplug/spotless/pull/2031)) diff --git a/plugin-maven/README.md b/plugin-maven/README.md index 89dd9e66ec..9a17cd2be7 100644 --- a/plugin-maven/README.md +++ b/plugin-maven/README.md @@ -659,6 +659,8 @@ All configuration settings are optional, they are described in detail [here](htt true + true + 2 false diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/pom/SortPom.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/pom/SortPom.java index 8620427f79..efa2f533b8 100644 --- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/pom/SortPom.java +++ b/plugin-maven/src/main/java/com/diffplug/spotless/maven/pom/SortPom.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2023 DiffPlug + * Copyright 2021-2024 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,6 +44,9 @@ public class SortPom implements FormatterStepFactory { @Parameter boolean keepBlankLines = defaultValues.keepBlankLines; + @Parameter + boolean endWithNewline = defaultValues.endWithNewline; + @Parameter int nrOfIndentSpace = defaultValues.nrOfIndentSpace; @@ -89,6 +92,7 @@ public FormatterStep newFormatterStep(FormatterStepConfig stepConfig) { cfg.expandEmptyElements = expandEmptyElements; cfg.spaceBeforeCloseEmptyElement = spaceBeforeCloseEmptyElement; cfg.keepBlankLines = keepBlankLines; + cfg.endWithNewline = endWithNewline; cfg.nrOfIndentSpace = nrOfIndentSpace; cfg.indentBlankLines = indentBlankLines; cfg.indentSchemaLocation = indentSchemaLocation; diff --git a/testlib/src/test/java/com/diffplug/spotless/pom/SortPomTest.java b/testlib/src/test/java/com/diffplug/spotless/pom/SortPomTest.java index c88918f505..5a0ad297c5 100644 --- a/testlib/src/test/java/com/diffplug/spotless/pom/SortPomTest.java +++ b/testlib/src/test/java/com/diffplug/spotless/pom/SortPomTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2023 DiffPlug + * Copyright 2021-2024 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,16 +21,16 @@ public class SortPomTest extends ResourceHarness { @Test - public void testSortPomWithDefaultConfig() throws Exception { + public void testSortPomWithDefaultConfig() { SortPomCfg cfg = new SortPomCfg(); FormatterStep step = SortPomStep.create(cfg, TestProvisioner.mavenCentral()); StepHarness.forStep(step).testResource("pom/pom_dirty.xml", "pom/pom_clean_default.xml"); } @Test - public void testSortPomWithVersion() throws Exception { + public void testSortPomWithVersion() { SortPomCfg cfg = new SortPomCfg(); - cfg.version = "3.2.1"; + cfg.version = "3.4.0"; FormatterStep step = SortPomStep.create(cfg, TestProvisioner.mavenCentral()); StepHarness.forStep(step).testResource("pom/pom_dirty.xml", "pom/pom_clean_default.xml"); }