effective-pom duplicate xml declaration and not pretty printed

Open
#421 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
java
Domain
build-system

Research direction

Start with AbstractEffectiveMojo.prettyFormat() and EffectivePomMojo.execute(), then reproduce the issue using the attached pom.xml and mvn help:effective-pom -Dverbose=true. Compare the output with maven-help-plugin.txt; done means the effective POM has one XML declaration, is pretty-printed, and the verbose comments are formatted correctly.

Written by the indexing model from the issue text.

Description

bug
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

Dominant language
Java
Stars
29
Forks
42
Avg merge
23h 15m
Merged PRs (30d)
6

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/maven-help-plugin

All issues in apache/maven-help-plugin

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.