Skip to content

Commit aa113ff

Browse files
authored
Updated SortPom from 3.2.1 to 3.4.0 with support for endWithNewline (#2049)
2 parents aceab65 + f7a6e63 commit aa113ff

File tree

9 files changed

+22
-11
lines changed

9 files changed

+22
-11
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
1515
* Respect `.editorconfig` settings for formatting shell via `shfmt` ([#2031](https://github.com/diffplug/spotless/pull/2031))
1616
### Changes
1717
* Bump default `ktfmt` version to latest `0.46` -> `0.47`. ([#2045](https://github.com/diffplug/spotless/pull/2045))
18+
* Bump default `sortpom` version to latest `3.2.1` -> `3.4.0`. ([#2049](https://github.com/diffplug/spotless/pull/2049))
1819
* Bump default `shfmt` version to latest `3.7.0` -> `3.8.0`. ([#2050](https://github.com/diffplug/spotless/pull/2050))
1920
### Removed
2021
* **BREAKING** Remove `JarState.getMavenCoordinate(String prefix)`. ([#1945](https://github.com/diffplug/spotless/pull/1945))

lib/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ dependencies {
128128
// scalafmt
129129
scalafmtCompileOnly "org.scalameta:scalafmt-core_2.13:3.7.3"
130130
// sortPom
131-
sortPomCompileOnly 'com.github.ekryd.sortpom:sortpom-sorter:3.2.1'
132-
sortPomCompileOnly 'org.slf4j:slf4j-api:2.0.0'
131+
sortPomCompileOnly 'com.github.ekryd.sortpom:sortpom-sorter:3.4.0'
132+
sortPomCompileOnly 'org.slf4j:slf4j-api:2.0.12'
133133
// zjsonPatch
134134
zjsonPatchCompileOnly 'com.flipkart.zjsonpatch:zjsonpatch:0.4.14'
135135
}

lib/src/main/java/com/diffplug/spotless/pom/SortPomCfg.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021-2023 DiffPlug
2+
* Copyright 2021-2024 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@
2121
public class SortPomCfg implements Serializable {
2222
private static final long serialVersionUID = 1L;
2323

24-
public String version = "3.2.1";
24+
public String version = "3.4.0";
2525

2626
public String encoding = "UTF-8";
2727

@@ -33,6 +33,8 @@ public class SortPomCfg implements Serializable {
3333

3434
public boolean keepBlankLines = true;
3535

36+
public boolean endWithNewline = true;
37+
3638
public int nrOfIndentSpace = 2;
3739

3840
public boolean indentBlankLines = false;

lib/src/sortPom/java/com/diffplug/spotless/glue/pom/SortPomFormatterFunc.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021-2023 DiffPlug
2+
* Copyright 2021-2024 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -50,7 +50,7 @@ public String apply(String input) throws Exception {
5050
.setPomFile(pom)
5151
.setFileOutput(false, null, null, false)
5252
.setEncoding(cfg.encoding)
53-
.setFormatting(cfg.lineSeparator, cfg.expandEmptyElements, cfg.spaceBeforeCloseEmptyElement, cfg.keepBlankLines)
53+
.setFormatting(cfg.lineSeparator, cfg.expandEmptyElements, cfg.spaceBeforeCloseEmptyElement, cfg.keepBlankLines, cfg.endWithNewline)
5454
.setIndent(cfg.nrOfIndentSpace, cfg.indentBlankLines, cfg.indentSchemaLocation)
5555
.setSortOrder(cfg.sortOrderFile, cfg.predefinedSortOrder)
5656
.setSortEntities(cfg.sortDependencies, cfg.sortDependencyExclusions, cfg.sortDependencyManagement,

plugin-gradle/CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
77
* Ignore system git config when running tests ([#1990](https://github.com/diffplug/spotless/issues/1990))
88
### Changes
99
* Bump default `ktfmt` version to latest `0.46` -> `0.47`. ([#2045](https://github.com/diffplug/spotless/pull/2045))
10+
* Bump default `sortpom` version to latest `3.2.1` -> `3.4.0`. ([#2049](https://github.com/diffplug/spotless/pull/2049))
1011
* Bump default `shfmt` version to latest `3.7.0` -> `3.8.0`. ([#2050](https://github.com/diffplug/spotless/pull/2050))
1112
### Added
1213
* Respect `.editorconfig` settings for formatting shell via `shfmt` ([#2031](https://github.com/diffplug/spotless/pull/2031))

plugin-maven/CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
77
* Ignore system git config when running tests ([#1990](https://github.com/diffplug/spotless/issues/1990))
88
### Changes
99
* Bump default `ktfmt` version to latest `0.46` -> `0.47`. ([#2045](https://github.com/diffplug/spotless/pull/2045))
10+
* Bump default `sortpom` version to latest `3.2.1` -> `3.4.0`. ([#2049](https://github.com/diffplug/spotless/pull/2049))
1011
* Bump default `shfmt` version to latest `3.7.0` -> `3.8.0`. ([#2050](https://github.com/diffplug/spotless/pull/2050))
1112
### Added
1213
* Respect `.editorconfig` settings for formatting shell via `shfmt` ([#2031](https://github.com/diffplug/spotless/pull/2031))

plugin-maven/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,8 @@ All configuration settings are optional, they are described in detail [here](htt
659659

660660
<keepBlankLines>true</keepBlankLines> <!-- Keep empty lines -->
661661

662+
<endWithNewline>true</endWithNewline> <!-- Whether sorted pom ends with a newline -->
663+
662664
<nrOfIndentSpace>2</nrOfIndentSpace> <!-- Indentation -->
663665

664666
<indentBlankLines>false</indentBlankLines> <!-- Should empty lines be indented -->

plugin-maven/src/main/java/com/diffplug/spotless/maven/pom/SortPom.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021-2023 DiffPlug
2+
* Copyright 2021-2024 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -44,6 +44,9 @@ public class SortPom implements FormatterStepFactory {
4444
@Parameter
4545
boolean keepBlankLines = defaultValues.keepBlankLines;
4646

47+
@Parameter
48+
boolean endWithNewline = defaultValues.endWithNewline;
49+
4750
@Parameter
4851
int nrOfIndentSpace = defaultValues.nrOfIndentSpace;
4952

@@ -89,6 +92,7 @@ public FormatterStep newFormatterStep(FormatterStepConfig stepConfig) {
8992
cfg.expandEmptyElements = expandEmptyElements;
9093
cfg.spaceBeforeCloseEmptyElement = spaceBeforeCloseEmptyElement;
9194
cfg.keepBlankLines = keepBlankLines;
95+
cfg.endWithNewline = endWithNewline;
9296
cfg.nrOfIndentSpace = nrOfIndentSpace;
9397
cfg.indentBlankLines = indentBlankLines;
9498
cfg.indentSchemaLocation = indentSchemaLocation;

testlib/src/test/java/com/diffplug/spotless/pom/SortPomTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021-2023 DiffPlug
2+
* Copyright 2021-2024 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,16 +21,16 @@
2121

2222
public class SortPomTest extends ResourceHarness {
2323
@Test
24-
public void testSortPomWithDefaultConfig() throws Exception {
24+
public void testSortPomWithDefaultConfig() {
2525
SortPomCfg cfg = new SortPomCfg();
2626
FormatterStep step = SortPomStep.create(cfg, TestProvisioner.mavenCentral());
2727
StepHarness.forStep(step).testResource("pom/pom_dirty.xml", "pom/pom_clean_default.xml");
2828
}
2929

3030
@Test
31-
public void testSortPomWithVersion() throws Exception {
31+
public void testSortPomWithVersion() {
3232
SortPomCfg cfg = new SortPomCfg();
33-
cfg.version = "3.2.1";
33+
cfg.version = "3.4.0";
3434
FormatterStep step = SortPomStep.create(cfg, TestProvisioner.mavenCentral());
3535
StepHarness.forStep(step).testResource("pom/pom_dirty.xml", "pom/pom_clean_default.xml");
3636
}

0 commit comments

Comments
 (0)