protected static String prettyFormat()

in src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java [104:126]


    protected static String prettyFormat(String effectiveModel, String encoding, boolean omitDeclaration) {
        SAXBuilder builder = new SAXBuilder();
        builder.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
        builder.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
        try {
            Document effectiveDocument = builder.build(new StringReader(effectiveModel));

            StringWriter w = new StringWriter();
            Format format = Format.getPrettyFormat();
            if (encoding != null) {
                // This is a design flaw in JDOM, no NPE on null arguments, but null is not prohibited
                format.setEncoding(encoding);
            }
            format.setLineSeparator(System.lineSeparator());
            format.setOmitDeclaration(omitDeclaration);
            XMLOutputter out = new XMLOutputter(format);
            out.output(effectiveDocument, w);

            return w.toString();
        } catch (JDOMException | IOException e) {
            return effectiveModel;
        }
    }