You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2019/12/05 09:03:40 UTC

[GitHub] [maven-dependency-plugin] S4n60w3n commented on a change in pull request #24: [MDEP-435] Added xml outputType to dependency tree

S4n60w3n commented on a change in pull request #24: [MDEP-435] Added xml outputType to dependency tree
URL: https://github.com/apache/maven-dependency-plugin/pull/24#discussion_r354179787
 
 

 ##########
 File path: src/main/java/org/apache/maven/plugins/dependency/tree/XMLDependencyNodeVisitor.java
 ##########
 @@ -0,0 +1,186 @@
+package org.apache.maven.plugins.dependency.tree;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
+import org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import java.io.Writer;
+import java.util.List;
+
+/**
+ * A dependency node visitor that serializes visited nodes to
+ * <a href="https://en.wikipedia.org/wiki/XML">XML format</a>
+ *
+ * @author <a href="mailto:sikora.bogdan@webscope.io">Bogdan Sikora</a>
+ * @since 3.1.2
+ */
+public class XMLDependencyNodeVisitor
+    extends AbstractSerializingVisitor
+    implements DependencyNodeVisitor
+{
+    /**
+     * Constructor.
+     *
+     * @param writer the writer to write to.
+     */
+    public XMLDependencyNodeVisitor( Writer writer )
+    {
+        super( writer );
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean visit( DependencyNode node )
+    {
+        try
+        {
+            if ( node.getParent() == null || node.getParent() == node )
+            {
+                DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
 
 Review comment:
   @mthmulders I will try to make time for that, but basically if you run my implementation and yours on this repo and output it to the file. Then you can make diff. It should be the same

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services