Skip to content

Commit

Permalink
Standardize on 2 * indent as the continuation indent (#414)
Browse files Browse the repository at this point in the history
* Standardize on 2 * indent as the continuation indent

* Fix integration test
  • Loading branch information
mches authored Apr 19, 2024
1 parent cd9b103 commit 1bbe4f4
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion maven-plugin/src/it/four-spaces-indent/expected_pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

Expand Down
4 changes: 2 additions & 2 deletions maven-plugin/src/it/mojo-description/expected_description.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ sortpom:sort
User property: sort.indentSchemaLocation
Should the schema location attribute of project (top level xml element)
be placed on a new line. The attribute will be indented (2 *
nrOfIndentSpace + 1 space) characters.
nrOfIndentSpace) characters.

keepBlankLines (Default: true)
User property: sort.keepBlankLines
Expand Down Expand Up @@ -203,7 +203,7 @@ sortpom:verify
User property: sort.indentSchemaLocation
Should the schema location attribute of project (top level xml element)
be placed on a new line. The attribute will be indented (2 *
nrOfIndentSpace + 1 space) characters.
nrOfIndentSpace) characters.

keepBlankLines (Default: true)
User property: sort.keepBlankLines
Expand Down
2 changes: 1 addition & 1 deletion maven-plugin/src/main/java/sortpom/AbstractParentMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ abstract class AbstractParentMojo extends AbstractMojo {

/**
* Should the schema location attribute of project (top level xml element) be placed on a new
* line. The attribute will be indented (2 * nrOfIndentSpace + 1 space) characters.
* line. The attribute will be indented (2 * nrOfIndentSpace) characters.
*/
@Parameter(property = "sort.indentSchemaLocation", defaultValue = "false")
boolean indentSchemaLocation;
Expand Down
3 changes: 2 additions & 1 deletion sorter/src/main/java/sortpom/output/PatchedXMLWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ protected void writeAttribute(Attribute attribute) throws IOException {
writePrintln();
writeString(format.getIndent());
writeString(format.getIndent());
} else {
writer.write(" ");
}
writer.write(" ");
writer.write(qualifiedName);
writer.write("=");

Expand Down
4 changes: 2 additions & 2 deletions sorter/src/test/java/sortpom/sort/IndentationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void indentSchemaLocationShouldAddNewlineAndIndentation(int indent) {
+ lineSeparator
+ indentChars
+ indentChars
+ " xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd\">"
+ "xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd\">"
+ lineSeparator
+ indentChars
+ "<Gurka xmlns=\"\"></Gurka>"
Expand Down Expand Up @@ -106,7 +106,7 @@ void otherAttributeShouldNotBeIndented() {
+ lineSeparator
+ indentChars
+ indentChars
+ " xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd\">"
+ "xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd\">"
+ lineSeparator
+ indentChars
+ "<Gurka xmlns=\"\" key=\"value\"></Gurka>"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>sortpom</groupId>
<artifactId>sortpom</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>sortpom</groupId>
<artifactId>sortpom</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>sortpom</groupId>
<artifactId>sortpom</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>sortpom</groupId>
<artifactId>sortpom</artifactId>
Expand Down

0 comments on commit 1bbe4f4

Please sign in to comment.