Skip to content

effective-pom duplicate xml declaration and not pretty printed #421

Description

@maroschutte

Affected version

3.5.2

Bug description

The effective-pom goal will generate invalid XML output in some cases. Run 'mvn help:effective-pom -Dverbose=true' on the attached pom.xml and you will see output like that in maven-help-plugin.txt

This output shows the following problems:

  • There are two xml declarations, this is actually invalid
  • The xml has not been pretty-printed
  • Comments from the 'verbose' flag still start with <!--}

Of course this is triggered by the property org.mockito:mockito-core:jar. In a namespaced xml document this is illegal, but maven accepts it. I also didn't make this syntax up, it is what the dependency:properties goal generates.

I have traced these issues to the AbstractEffectiveMojo.prettyFormat() method. A JDOMexception is thrown, causing it to return the unmodified version of the pom. This explains the second xml declaration, whereas the first is written by the writeHeader() method.

Because the pretty printing isn't actually done, the regexp replacement of the <!--} syntax in EffectivePomMojo.execute() also fails as there is no whitespace between the tag and the comment.

maven-help-plugin.txt
pom.xml

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions