1
2
3
4
5
6
7
8 package au.com.acegi.xmlformat;
9
10 import static au.com.acegi.xmlformat.FormatUtil.formatInPlace;
11 import static org.apache.maven.plugins.annotations.LifecyclePhase.PREPARE_PACKAGE;
12
13 import java.io.File;
14 import java.io.IOException;
15
16 import org.apache.maven.plugins.annotations.Mojo;
17 import org.dom4j.DocumentException;
18
19
20
21
22 @Mojo(name = "xml-format", defaultPhase = PREPARE_PACKAGE, threadSafe = true)
23 public final class XmlFormatPlugin extends AbstractXmlPlugin {
24
25 @Override
26 protected boolean processFile(final File input, final XmlOutputFormat fmt) throws DocumentException, IOException {
27 final boolean changed = formatInPlace(input, fmt);
28 if (getLog().isDebugEnabled()) {
29 final String msg = changed ? "Formatted" : "Unchanged";
30 getLog().debug("[xml-format] " + msg + ": " + input);
31 }
32 return changed;
33 }
34
35 @Override
36 protected void afterAllProcessed(final boolean neededFormatting) {
37
38 }
39 }