butterfly icon indicating copy to clipboard operation
butterfly copied to clipboard

Add a set of Maven POM file TOs that are able to preserve file formatting and comments

Open fabiocarvalho777 opened this issue 6 years ago • 0 comments

Butterfly has one limitation when performing certain modifications to Maven pom files. Depending on the modification, it ends up modifying reformatting the whole file, changing indentation and the order of the tags. That happens because Butterfly reads the file, parses it, builds a model in memory, applies the transformation, then writes it back to the same file.

When it writes the file with the transformation, it uses the model in memory as source, which means it looses entirely the original formatting and comments the file used to have. Some users don't like it because many times the transformation is very trivial, and would change just a few lines, but still the result is a file that looks entirely different.

The goal of this issue is to create a new set of Maven POM file Transformation Operations that are able to perform isolated modifications, preserving formatting, order and comments by using StAX.

In addition to that, also undo the changes in this commit, uncommenting all unit tests that assure formatting and comments are preserved.

A few TOs have already been implemented using StAX, such as #84 and #92.

StAX references

  • https://docs.oracle.com/javase/tutorial/jaxp/stax/index.html
  • https://en.wikipedia.org/wiki/StAX
  • http://tutorialspointexamples.com/stax-xml-parser-java-tutorial-examples/
  • http://www.xml.com/pub/a/2003/09/17/stax.html

fabiocarvalho777 avatar Nov 02 '17 21:11 fabiocarvalho777