Welcome! Please see the About page for a little more info on how this works.

+1 vote
in tools.deps by

Under Java 9, each invocation of clj -Spom to update an existing pom causes newlines to be added.

`
/private/tmp/pom-bug> head pom.xml
<?xml version="1.0" encoding="UTF-8"?>

4.0.0
pom-bug
pom-bug
0.1.0
pom-bug

<dependency>
  <groupId>org.clojure</groupId>

/private/tmp/pom-bug> clj -Spom 2>/dev/null
/private/tmp/pom-bug> head pom.xml
<?xml version="1.0" encoding="UTF-8"?>

4.0.0

pom-bug

pom-bug

0.1.0
/private/tmp/pom-bug> clj -Spom 2>/dev/null
/private/tmp/pom-bug> head pom.xml
<?xml version="1.0" encoding="UTF-8"?>

4.0.0

pom-bug

`

It's worth noting that this happens only under Java 9. Java 1.8.0_152 works as expected.

4 Answers

+1 vote
by
selected by
 
Best answer

A temporary workaround can be adding {:skip-whitespace :true} on parsing the pom file. With that option the final indentation is correct.

Meanwhile i'm using this code to generate/update pom file:

(require '[clojure.tools.deps.alpha.script.generate-manifest :as manifest]
         '[clojure.data.xml :as xml])
(alter-var-root #'xml/event-seq (fn [f]
                                  (fn [source opts]
                                    (f source (merge {:skip-whitespace true} opts)))))
(generate-manifest/-main "--gen" "pom" "--config-files" "deps.edn")
by
Fixed in clj 1.10.1.478 - thanks!
0 votes
by

Comment made by: alexmiller

-Spom uses data.xml, which uses javax.xml.transform.Transformer, which has had changes in Java 9, presumably due to the update to Xerces-J 2.11.0 (https://xerces.apache.org/xerces2-j/releases.html). Here's a blog outlining some of the effects: http://java9.wtf/xml-transformer/. Possibly also relevant: https://bugs.java.com/view_bug.do?bug_id=JDK-8087303

0 votes
by

Comment made by: alexmiller

Filed an issue at DXML-53 for this as that's really where it would ideally be fixed.

0 votes
by
Reference: https://clojure.atlassian.net/browse/TDEPS-29 (reported by potetm)
...