[
https://issues.jboss.org/browse/FORGE-440?page=com.atlassian.jira.plugin....
]
Lennart Jörelid commented on FORGE-440:
---------------------------------------
Hello there, Lincoln.
First off, [
https://jira.codehaus.org/browse/MNG-5488#comment-327349] could likely use a
peek and a vote or 50000. (Go there, folks - and Vote!)
;)
WRT the Forge side of things, I believe we have likely 2 ways to proceed:
# Wait for a generally available comment property in all major maven model types. This
could possibly take quite some time - maybe even to imply a release of Maven's Model
version 5 if accepted by the Apache community. Thus ... impractical in the short term.
# Accept that the Maven model is fundamentally flawed WRT comments, and create a
datastructure and parser/joiner for it ourselves. This is also likely to be a non-trivial
endeavour, but certainly doable.
Therefore...
h3. Potential approach to preserve XML comments in POMs
The POM itself should hold all comments both before and after a Forge operation.
Therefore, we should not need to save comment texts persistently in other places.
Assuming that all POM comments occur *before* an XML element, we must:
# Slurp up all text (verbatim!) between the end tag of the preceding POM element and the
start of the current POM element. (We don't want to change developer's carefully
crafted/formatted comments, ASCII-art or whatever).
# We'll ignore patterns of the type [newline][whitespace][start XML element], since
this is not a comment or significant whitespace.
# For non-ignored patterns, find out the XPath + Element ID of the POM element immediately
following the text we just slurped up.
# Create a transient Map<String, String> relating XPath to Comment text.
# When the dust settles following a Forge operation, try to find all elements which had a
comment and re-insert the corresponding comment text before the start tag of the element
found.
Come to think of it, this is not a particularly over-complex task.
I'll go for a dive in MavenFacetImpl source code - need to get a feel for it before
voicing any recommendations or supplying a patch.
I take comfort in that unit tests should be a lifesaver in this particular case.
Attaching a screenshot to illustrate.
A pom.xml which contains comments loses all of them after Forge
operates on it.
-------------------------------------------------------------------------------
Key: FORGE-440
URL:
https://issues.jboss.org/browse/FORGE-440
Project: Forge
Issue Type: Bug
Components: Build Tools - Maven
Affects Versions: 1.0.6.Final
Environment: HEAD
Reporter: Pete Muir
Fix For: 2.x Future
Also looses formatting, but this is less of an issue.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:
http://www.atlassian.com/software/jira