Skip to content

Commit 61c0575

Browse files
olim7tadutra
authored andcommitted
JAVA-2107: Add XML formatting plugin (apache#1363)
1 parent 411a76a commit 61c0575

File tree

3 files changed

+39
-4
lines changed

3 files changed

+39
-4
lines changed

CONTRIBUTING.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Code formatting
44

5+
### Java
6+
57
We follow the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html). See
68
https://github.com/google/google-java-format for IDE plugins. The rules are not configurable.
79

@@ -11,11 +13,20 @@ The build will fail if the code is not formatted. To format all files from the c
1113
mvn fmt:format
1214
```
1315

14-
Some aspects are not covered by the formatter:
16+
Some aspects are not covered by the formatter: braces must be used with `if`, `else`, `for`, `do`
17+
and `while` statements, even when the body is empty or contains only a single statement.
18+
19+
### XML
20+
21+
The build will fail if XML files are not formatted correctly. Run the following command before you
22+
commit:
23+
24+
```java
25+
mvn xml-format:xml-format
26+
```
1527

16-
* braces must be used with `if`, `else`, `for`, `do` and `while` statements, even when the body is
17-
empty or contains only a single statement.
18-
* XML files: indent with two spaces and wrap to respect the column limit of 100 characters.
28+
The formatter does not enforce a maximum line length, but please try to keep it below 100 characters
29+
to keep files readable across all mediums (IDE, terminal, Github...).
1930

2031
## Coding style -- production code
2132

changelog/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### 4.4.0 (in progress)
66

7+
- [improvement] JAVA-2107: Add XML formatting plugin
78
- [bug] JAVA-2527: Allow AllNodesFailedException to accept more than one error per node
89
- [improvement] JAVA-2546: Abort schema refresh if a query fails
910

pom.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,11 @@
291291
<artifactId>fmt-maven-plugin</artifactId>
292292
<version>2.9</version>
293293
</plugin>
294+
<plugin>
295+
<groupId>au.com.acegi</groupId>
296+
<artifactId>xml-format-maven-plugin</artifactId>
297+
<version>3.1.1</version>
298+
</plugin>
294299
<plugin>
295300
<groupId>com.mycila</groupId>
296301
<artifactId>license-maven-plugin</artifactId>
@@ -439,6 +444,24 @@
439444
</execution>
440445
</executions>
441446
</plugin>
447+
<plugin>
448+
<groupId>au.com.acegi</groupId>
449+
<artifactId>xml-format-maven-plugin</artifactId>
450+
<executions>
451+
<execution>
452+
<goals>
453+
<goal>xml-check</goal>
454+
</goals>
455+
</execution>
456+
</executions>
457+
<configuration>
458+
<excludes>
459+
<exclude>.idea/**</exclude>
460+
<exclude>**/target/**</exclude>
461+
<exclude>**/dependency-reduced-pom.xml</exclude>
462+
</excludes>
463+
</configuration>
464+
</plugin>
442465
<plugin>
443466
<groupId>com.mycila</groupId>
444467
<artifactId>license-maven-plugin</artifactId>

0 commit comments

Comments
 (0)