[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-30 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17850711#comment-17850711
 ] 

ASF GitHub Bot commented on MDEP-799:
-

slawekjaranowski commented on code in PR #398:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/398#discussion_r1620690851


##
src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java:
##
@@ -86,30 +84,6 @@ public class TreeMojo extends AbstractMojo {
 @Parameter(property = "outputEncoding", defaultValue = 
"${project.reporting.outputEncoding}")
 private String outputEncoding;
 
-/**
- * Contains the full list of projects in the reactor.
- */
-@Parameter(defaultValue = "${reactorProjects}", readonly = true, required 
= true)

Review Comment:
   no problem ... like unused variables are





> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Assignee: Elliotte Rusty Harold
>Priority: Major
> Fix For: 3.7.0
>
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-30 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17850701#comment-17850701
 ] 

ASF GitHub Bot commented on MDEP-799:
-

elharo commented on code in PR #398:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/398#discussion_r1620629551


##
src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java:
##
@@ -86,30 +84,6 @@ public class TreeMojo extends AbstractMojo {
 @Parameter(property = "outputEncoding", defaultValue = 
"${project.reporting.outputEncoding}")
 private String outputEncoding;
 
-/**
- * Contains the full list of projects in the reactor.
- */
-@Parameter(defaultValue = "${reactorProjects}", readonly = true, required 
= true)

Review Comment:
   does this cause problems for existing projects that set these?



##
src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java:
##
@@ -133,7 +107,8 @@ public class TreeMojo extends AbstractMojo {
 
 /**
  * If specified, this parameter will cause the dependency tree to be 
written using the specified format. Currently
- * supported format are: text (default), dot, 
graphml and tgf.
+ * supported format are: text (default), dot, 
graphml, tgf

Review Comment:
   format --> formats





> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Assignee: Elliotte Rusty Harold
>Priority: Major
> Fix For: 3.7.0
>
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-30 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17850680#comment-17850680
 ] 

ASF GitHub Bot commented on MDEP-799:
-

slawekjaranowski opened a new pull request, #398:
URL: https://github.com/apache/maven-dependency-plugin/pull/398

   (no comment)




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Assignee: Elliotte Rusty Harold
>Priority: Major
> Fix For: 3.7.0
>
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-24 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17849293#comment-17849293
 ] 

ASF GitHub Bot commented on MDEP-799:
-

monperrus commented on PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#issuecomment-2129493157

   > @LogFlames @monperrus I guess you plan to use it in 
[chains-project/maven-lockfile](https://github.com/chains-project/maven-lockfile)
 ?
   
   @pombredanne yes and in other [Chains](https://chains.proj.kth.se/) 
experiments 
   
   > Demo for it is here [cstamas/tc-demo](https://github.com/cstamas/tc-demo)
   
   @cstamas interesting, this is related to how we store checksums in lockfiles 
in https://github.com/chains-project/maven-lockfile




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Assignee: Elliotte Rusty Harold
>Priority: Major
> Fix For: 3.7.0
>
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-24 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17849292#comment-17849292
 ] 

ASF GitHub Bot commented on MDEP-799:
-

slawekjaranowski commented on PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#issuecomment-2129491870

   > @slawekjaranowski re: doc, I was about to post a comment here too!
   > 
   > 
https://github.com/apache/maven-dependency-plugin/blob/09775b3c0effa7d102b4e71ce8c3688caa6dee71/src/site/apt/usage.apt.vm#L603
   > 
   > ... thank for catching this.
   
   We can add in mentioned place a new format, but I think that we should 
publish structure of generated json somewhere a new page will be the best for 
it in my opinion




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Assignee: Elliotte Rusty Harold
>Priority: Major
> Fix For: 3.7.0
>
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-24 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17849234#comment-17849234
 ] 

ASF GitHub Bot commented on MDEP-799:
-

pombredanne commented on PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#issuecomment-2129090873

   @slawekjaranowski re: doc, I was about to post a comment here too! 
https://github.com/apache/maven-dependency-plugin/blob/09775b3c0effa7d102b4e71ce8c3688caa6dee71/src/site/apt/usage.apt.vm#L603
 ... thank for catching this.




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Assignee: Elliotte Rusty Harold
>Priority: Major
> Fix For: 3.7.0
>
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-23 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17849153#comment-17849153
 ] 

ASF GitHub Bot commented on MDEP-799:
-

slawekjaranowski commented on PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#issuecomment-2128524291

   Thanks again everybody for contribution ... but we are lack of 
documentation, so I created issue:
   https://issues.apache.org/jira/browse/MDEP-933
   
   @LogFlames @elharo or someone else can you look.
   




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Assignee: Elliotte Rusty Harold
>Priority: Major
> Fix For: 3.7.0
>
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-23 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17849124#comment-17849124
 ] 

ASF GitHub Bot commented on MDEP-799:
-

pombredanne commented on PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#issuecomment-2128158079

   Everyone thank you ++ and @LogFlames :bow: :heart: 
   
   You have rendered obsolete about 22K files on GitHub that try to parse the 
output of tree!
   See https://github.com/search?q=mvn+"dependency%3Atree"&type=code 
   
   @LogFlames @monperrus I guess you plan to use it in 
https://github.com/chains-project/maven-lockfile ?
   
   FWIW, on my side this is going to be used in a front end to the 
https://github.com/nexB/scancode.io/ code scanner and matcher:
   - created for Maven in in 
https://github.com/nexB/dependency-inspector/issues/6
   - otherwise,  part of a general purpose solution to 
https://github.com/nexB/dependency-inspector/issues/2
   - and the companion to ecosystem-specific dependency resolvers such as 
https://github.com/nexB/python-inspector or 
https://github.com/nexB/nuget-inspector 




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Assignee: Elliotte Rusty Harold
>Priority: Major
> Fix For: 3.7.0
>
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-23 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17849038#comment-17849038
 ] 

ASF GitHub Bot commented on MDEP-799:
-

elharo commented on PR #325:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/325#issuecomment-2127618794

   feature complete under another PR




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Assignee: Elliotte Rusty Harold
>Priority: Major
> Fix For: 3.7.0
>
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-23 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17849037#comment-17849037
 ] 

ASF GitHub Bot commented on MDEP-799:
-

elharo closed pull request #325: [MDEP-799] tree: add optional output type json
URL: https://github.com/apache/maven-dependency-plugin/pull/325




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Assignee: Elliotte Rusty Harold
>Priority: Major
> Fix For: 3.7.0
>
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-23 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17849035#comment-17849035
 ] 

ASF GitHub Bot commented on MDEP-799:
-

elharo closed pull request #207: [MDEP-799] - improve dependency:tree to add 
optional JSON output of the results
URL: https://github.com/apache/maven-dependency-plugin/pull/207




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Assignee: Elliotte Rusty Harold
>Priority: Major
> Fix For: 3.7.0
>
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-23 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17849036#comment-17849036
 ] 

ASF GitHub Bot commented on MDEP-799:
-

elharo commented on PR #207:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/207#issuecomment-2127618346

   feature complete under another PR




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Assignee: Elliotte Rusty Harold
>Priority: Major
> Fix For: 3.7.0
>
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-23 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17849027#comment-17849027
 ] 

ASF GitHub Bot commented on MDEP-799:
-

monperrus commented on PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#issuecomment-2127542024

   > There is on my list ... I hope do next release 3.7.0 it at next week or two
   
   excellent, thanks!




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Assignee: Elliotte Rusty Harold
>Priority: Major
> Fix For: 3.7.0
>
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-23 Thread Slawomir Jaranowski (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17849012#comment-17849012
 ] 

Slawomir Jaranowski commented on MDEP-799:
--

[~elharo]  - thanks for take care about it. 

I assign you to issue.

Thera are a two more PR with the same ... please comments and close those

> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Assignee: Elliotte Rusty Harold
>Priority: Major
> Fix For: 3.7.0
>
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17848739#comment-17848739
 ] 

ASF GitHub Bot commented on MDEP-799:
-

LogFlames commented on code in PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#discussion_r1610578562


##
src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java:
##
@@ -137,6 +147,74 @@ public void testTreeTGFSerializing() throws Exception {
 assertTrue(findString(contents, 
"testGroupId:release:jar:1.0:compile"));
 }
 
+/**
+ * Test the JSON format serialization on DependencyNodes with circular 
dependence
+ */
+public void testTreeJsonCircularDependency() throws Exception {
+String outputFileName = testDir.getAbsolutePath() + "tree1.json";
+File outputFile = new File(outputFileName);
+Files.createDirectories(outputFile.getParentFile().toPath());
+outputFile.createNewFile();
+
+Artifact artifact1 = this.stubFactory.createArtifact("testGroupId", 
"project1", "1.0");
+Artifact artifact2 = this.stubFactory.createArtifact("testGroupId", 
"project2", "1.0");
+DefaultDependencyNode node1 = new DefaultDependencyNode(artifact1);
+DefaultDependencyNode node2 = new DefaultDependencyNode(artifact2);
+
+node1.setChildren(new ArrayList());
+node2.setChildren(new ArrayList());
+
+node1.getChildren().add(node2);
+node2.getChildren().add(node1);
+
+JsonDependencyNodeVisitor jsonDependencyNodeVisitor =
+new JsonDependencyNodeVisitor(new OutputStreamWriter(new 
FileOutputStream(outputFile)));
+
+jsonDependencyNodeVisitor.visit(node1);
+}
+
+/*
+ * Test parsing of Json output and verify all key-value pairs
+ */
+public void testTreeJsonParsing() throws Exception {
+List contents = runTreeMojo("tree2.json", "json");
+
+JsonReader reader = Json.createReader(new 
StringReader(String.join("\n", contents)));
+JsonObject root = reader.readObject();
+reader.close();

Review Comment:
   Cool feature, thanks! This has been updated to use try-with-resource





> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17848735#comment-17848735
 ] 

ASF GitHub Bot commented on MDEP-799:
-

LogFlames commented on code in PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#discussion_r1610577280


##
src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java:
##
@@ -137,6 +147,74 @@ public void testTreeTGFSerializing() throws Exception {
 assertTrue(findString(contents, 
"testGroupId:release:jar:1.0:compile"));
 }
 
+/**
+ * Test the JSON format serialization on DependencyNodes with circular 
dependence
+ */
+public void testTreeJsonCircularDependency() throws Exception {
+String outputFileName = testDir.getAbsolutePath() + "tree1.json";
+File outputFile = new File(outputFileName);
+Files.createDirectories(outputFile.getParentFile().toPath());
+outputFile.createNewFile();
+
+Artifact artifact1 = this.stubFactory.createArtifact("testGroupId", 
"project1", "1.0");
+Artifact artifact2 = this.stubFactory.createArtifact("testGroupId", 
"project2", "1.0");
+DefaultDependencyNode node1 = new DefaultDependencyNode(artifact1);
+DefaultDependencyNode node2 = new DefaultDependencyNode(artifact2);
+
+node1.setChildren(new ArrayList());
+node2.setChildren(new ArrayList());
+
+node1.getChildren().add(node2);
+node2.getChildren().add(node1);
+
+JsonDependencyNodeVisitor jsonDependencyNodeVisitor =
+new JsonDependencyNodeVisitor(new OutputStreamWriter(new 
FileOutputStream(outputFile)));
+
+jsonDependencyNodeVisitor.visit(node1);
+}
+
+/*
+ * Test parsing of Json output and verify all key-value pairs
+ */
+public void testTreeJsonParsing() throws Exception {

Review Comment:
   This uses the prebuilt function `runTreeMojo` that is also used by most 
other tests in the file, which throws an Exception. I don't think this can be 
more specific without changing `runTreeMojo`. Within `runTreeMojo` there are 
function that throws the following exceptions:
   `lookupMojo`: `Exception`
   `setVariableValueToObject`: `IllegalAccessException`
   `this.stubFactory.createArtifact`: `IOException`
   `mojo.execute()`: `MojoFailureException` and `MojoExecutionException`
   





> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17848736#comment-17848736
 ] 

ASF GitHub Bot commented on MDEP-799:
-

LogFlames commented on code in PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#discussion_r1610577280


##
src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java:
##
@@ -137,6 +147,74 @@ public void testTreeTGFSerializing() throws Exception {
 assertTrue(findString(contents, 
"testGroupId:release:jar:1.0:compile"));
 }
 
+/**
+ * Test the JSON format serialization on DependencyNodes with circular 
dependence
+ */
+public void testTreeJsonCircularDependency() throws Exception {
+String outputFileName = testDir.getAbsolutePath() + "tree1.json";
+File outputFile = new File(outputFileName);
+Files.createDirectories(outputFile.getParentFile().toPath());
+outputFile.createNewFile();
+
+Artifact artifact1 = this.stubFactory.createArtifact("testGroupId", 
"project1", "1.0");
+Artifact artifact2 = this.stubFactory.createArtifact("testGroupId", 
"project2", "1.0");
+DefaultDependencyNode node1 = new DefaultDependencyNode(artifact1);
+DefaultDependencyNode node2 = new DefaultDependencyNode(artifact2);
+
+node1.setChildren(new ArrayList());
+node2.setChildren(new ArrayList());
+
+node1.getChildren().add(node2);
+node2.getChildren().add(node1);
+
+JsonDependencyNodeVisitor jsonDependencyNodeVisitor =
+new JsonDependencyNodeVisitor(new OutputStreamWriter(new 
FileOutputStream(outputFile)));
+
+jsonDependencyNodeVisitor.visit(node1);
+}
+
+/*
+ * Test parsing of Json output and verify all key-value pairs
+ */
+public void testTreeJsonParsing() throws Exception {

Review Comment:
   This uses the prebuilt function `runTreeMojo` that is also used by most 
other tests in the file, which throws an Exception. I don't think this can be 
more specific without major changes to `runTreeMojo`.
   Within `runTreeMojo` there are function that throws the following exceptions:
   `lookupMojo`: `Exception`
   `setVariableValueToObject`: `IllegalAccessException`
   `this.stubFactory.createArtifact`: `IOException`
   `mojo.execute()`: `MojoFailureException` and `MojoExecutionException`
   





> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17848734#comment-17848734
 ] 

ASF GitHub Bot commented on MDEP-799:
-

LogFlames commented on code in PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#discussion_r1610575858


##
src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java:
##
@@ -137,6 +147,74 @@ public void testTreeTGFSerializing() throws Exception {
 assertTrue(findString(contents, 
"testGroupId:release:jar:1.0:compile"));
 }
 
+/**
+ * Test the JSON format serialization on DependencyNodes with circular 
dependence
+ */
+public void testTreeJsonCircularDependency() throws Exception {

Review Comment:
   This has been updated to `IOException`.





> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17848728#comment-17848728
 ] 

ASF GitHub Bot commented on MDEP-799:
-

elharo commented on code in PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#discussion_r1610551901


##
src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java:
##
@@ -137,6 +147,74 @@ public void testTreeTGFSerializing() throws Exception {
 assertTrue(findString(contents, 
"testGroupId:release:jar:1.0:compile"));
 }
 
+/**
+ * Test the JSON format serialization on DependencyNodes with circular 
dependence
+ */
+public void testTreeJsonCircularDependency() throws Exception {

Review Comment:
   can you declare a more specific exception?



##
src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java:
##
@@ -137,6 +147,74 @@ public void testTreeTGFSerializing() throws Exception {
 assertTrue(findString(contents, 
"testGroupId:release:jar:1.0:compile"));
 }
 
+/**
+ * Test the JSON format serialization on DependencyNodes with circular 
dependence
+ */
+public void testTreeJsonCircularDependency() throws Exception {
+String outputFileName = testDir.getAbsolutePath() + "tree1.json";
+File outputFile = new File(outputFileName);
+Files.createDirectories(outputFile.getParentFile().toPath());
+outputFile.createNewFile();
+
+Artifact artifact1 = this.stubFactory.createArtifact("testGroupId", 
"project1", "1.0");
+Artifact artifact2 = this.stubFactory.createArtifact("testGroupId", 
"project2", "1.0");
+DefaultDependencyNode node1 = new DefaultDependencyNode(artifact1);
+DefaultDependencyNode node2 = new DefaultDependencyNode(artifact2);
+
+node1.setChildren(new ArrayList());
+node2.setChildren(new ArrayList());
+
+node1.getChildren().add(node2);
+node2.getChildren().add(node1);
+
+JsonDependencyNodeVisitor jsonDependencyNodeVisitor =
+new JsonDependencyNodeVisitor(new OutputStreamWriter(new 
FileOutputStream(outputFile)));
+
+jsonDependencyNodeVisitor.visit(node1);
+}
+
+/*
+ * Test parsing of Json output and verify all key-value pairs
+ */
+public void testTreeJsonParsing() throws Exception {
+List contents = runTreeMojo("tree2.json", "json");
+
+JsonReader reader = Json.createReader(new 
StringReader(String.join("\n", contents)));
+JsonObject root = reader.readObject();
+reader.close();

Review Comment:
   I think you can use try with resources to autoclose this.



##
src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java:
##
@@ -137,6 +147,74 @@ public void testTreeTGFSerializing() throws Exception {
 assertTrue(findString(contents, 
"testGroupId:release:jar:1.0:compile"));
 }
 
+/**
+ * Test the JSON format serialization on DependencyNodes with circular 
dependence
+ */
+public void testTreeJsonCircularDependency() throws Exception {
+String outputFileName = testDir.getAbsolutePath() + "tree1.json";
+File outputFile = new File(outputFileName);
+Files.createDirectories(outputFile.getParentFile().toPath());
+outputFile.createNewFile();
+
+Artifact artifact1 = this.stubFactory.createArtifact("testGroupId", 
"project1", "1.0");
+Artifact artifact2 = this.stubFactory.createArtifact("testGroupId", 
"project2", "1.0");
+DefaultDependencyNode node1 = new DefaultDependencyNode(artifact1);
+DefaultDependencyNode node2 = new DefaultDependencyNode(artifact2);
+
+node1.setChildren(new ArrayList());
+node2.setChildren(new ArrayList());
+
+node1.getChildren().add(node2);
+node2.getChildren().add(node1);
+
+JsonDependencyNodeVisitor jsonDependencyNodeVisitor =
+new JsonDependencyNodeVisitor(new OutputStreamWriter(new 
FileOutputStream(outputFile)));
+
+jsonDependencyNodeVisitor.visit(node1);
+}
+
+/*
+ * Test parsing of Json output and verify all key-value pairs
+ */
+public void testTreeJsonParsing() throws Exception {

Review Comment:
   can you declare a more specific exception?





> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17848715#comment-17848715
 ] 

ASF GitHub Bot commented on MDEP-799:
-

LogFlames commented on code in PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#discussion_r1610513186


##
src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java:
##
@@ -137,6 +146,93 @@ public void testTreeTGFSerializing() throws Exception {
 assertTrue(findString(contents, 
"testGroupId:release:jar:1.0:compile"));
 }
 
+/**
+ * Test the JSON format serialization
+ */
+public void testTreeJsonSerializing() throws Exception {
+List contents = runTreeMojo("tree1.json", "json");
+assertTrue(findString(contents, "\"groupId\": \"testGroupId\""));
+
+assertTrue(findString(contents, "\"artifactId\": \"project\""));
+assertTrue(findString(contents, "\"artifactId\": \"release\""));
+assertTrue(findString(contents, "\"artifactId\": \"snapshot\""));
+
+assertTrue(findString(contents, "\"version\": \"1.0\""));
+assertTrue(findString(contents, "\"version\": \"2.0-SNAPSHOT\""));
+
+assertTrue(findString(contents, "\"type\": \"jar\""));
+
+assertTrue(findString(contents, "\"scope\": \"compile\""));
+}
+
+/**
+ * Test the JSON format serialization on DependencyNodes with circular 
dependence
+ */
+public void testTreeJsonCircularDependency() throws Exception {
+String outputFileName = testDir.getAbsolutePath() + "tree2.json";
+File outputFile = new File(outputFileName);
+Files.createDirectories(outputFile.getParentFile().toPath());
+outputFile.createNewFile();
+
+Artifact artifact1 = this.stubFactory.createArtifact("testGroupId", 
"project1", "1.0");
+Artifact artifact2 = this.stubFactory.createArtifact("testGroupId", 
"project2", "1.0");
+DefaultDependencyNode node1 = new DefaultDependencyNode(artifact1);
+DefaultDependencyNode node2 = new DefaultDependencyNode(artifact2);
+
+node1.setChildren(new ArrayList());
+node2.setChildren(new ArrayList());
+
+node1.getChildren().add(node2);
+node2.getChildren().add(node1);
+
+JsonDependencyNodeVisitor jsonDependencyNodeVisitor =
+new JsonDependencyNodeVisitor(new PrintWriter(outputFile));

Review Comment:
   It now uses an OutputStreamWriter instead.



##
src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java:
##
@@ -137,6 +146,93 @@ public void testTreeTGFSerializing() throws Exception {
 assertTrue(findString(contents, 
"testGroupId:release:jar:1.0:compile"));
 }
 
+/**
+ * Test the JSON format serialization
+ */
+public void testTreeJsonSerializing() throws Exception {
+List contents = runTreeMojo("tree1.json", "json");
+assertTrue(findString(contents, "\"groupId\": \"testGroupId\""));
+
+assertTrue(findString(contents, "\"artifactId\": \"project\""));
+assertTrue(findString(contents, "\"artifactId\": \"release\""));
+assertTrue(findString(contents, "\"artifactId\": \"snapshot\""));
+
+assertTrue(findString(contents, "\"version\": \"1.0\""));
+assertTrue(findString(contents, "\"version\": \"2.0-SNAPSHOT\""));
+
+assertTrue(findString(contents, "\"type\": \"jar\""));
+
+assertTrue(findString(contents, "\"scope\": \"compile\""));
+}
+
+/**
+ * Test the JSON format serialization on DependencyNodes with circular 
dependence
+ */
+public void testTreeJsonCircularDependency() throws Exception {
+String outputFileName = testDir.getAbsolutePath() + "tree2.json";
+File outputFile = new File(outputFileName);
+Files.createDirectories(outputFile.getParentFile().toPath());
+outputFile.createNewFile();
+
+Artifact artifact1 = this.stubFactory.createArtifact("testGroupId", 
"project1", "1.0");
+Artifact artifact2 = this.stubFactory.createArtifact("testGroupId", 
"project2", "1.0");
+DefaultDependencyNode node1 = new DefaultDependencyNode(artifact1);
+DefaultDependencyNode node2 = new DefaultDependencyNode(artifact2);
+
+node1.setChildren(new ArrayList());
+node2.setChildren(new ArrayList());
+
+node1.getChildren().add(node2);
+node2.getChildren().add(node1);
+
+JsonDependencyNodeVisitor jsonDependencyNodeVisitor =
+new JsonDependencyNodeVisitor(new PrintWriter(outputFile));

Review Comment:
   :+1:  It now uses an OutputStreamWriter instead.





> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse

[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17848639#comment-17848639
 ] 

ASF GitHub Bot commented on MDEP-799:
-

elharo commented on code in PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#discussion_r1610078602


##
src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java:
##
@@ -137,6 +146,93 @@ public void testTreeTGFSerializing() throws Exception {
 assertTrue(findString(contents, 
"testGroupId:release:jar:1.0:compile"));
 }
 
+/**
+ * Test the JSON format serialization
+ */
+public void testTreeJsonSerializing() throws Exception {
+List contents = runTreeMojo("tree1.json", "json");
+assertTrue(findString(contents, "\"groupId\": \"testGroupId\""));
+
+assertTrue(findString(contents, "\"artifactId\": \"project\""));
+assertTrue(findString(contents, "\"artifactId\": \"release\""));
+assertTrue(findString(contents, "\"artifactId\": \"snapshot\""));
+
+assertTrue(findString(contents, "\"version\": \"1.0\""));
+assertTrue(findString(contents, "\"version\": \"2.0-SNAPSHOT\""));
+
+assertTrue(findString(contents, "\"type\": \"jar\""));
+
+assertTrue(findString(contents, "\"scope\": \"compile\""));
+}
+
+/**
+ * Test the JSON format serialization on DependencyNodes with circular 
dependence
+ */
+public void testTreeJsonCircularDependency() throws Exception {
+String outputFileName = testDir.getAbsolutePath() + "tree2.json";
+File outputFile = new File(outputFileName);
+Files.createDirectories(outputFile.getParentFile().toPath());
+outputFile.createNewFile();
+
+Artifact artifact1 = this.stubFactory.createArtifact("testGroupId", 
"project1", "1.0");
+Artifact artifact2 = this.stubFactory.createArtifact("testGroupId", 
"project2", "1.0");
+DefaultDependencyNode node1 = new DefaultDependencyNode(artifact1);
+DefaultDependencyNode node2 = new DefaultDependencyNode(artifact2);
+
+node1.setChildren(new ArrayList());
+node2.setChildren(new ArrayList());
+
+node1.getChildren().add(node2);
+node2.getChildren().add(node1);
+
+JsonDependencyNodeVisitor jsonDependencyNodeVisitor =
+new JsonDependencyNodeVisitor(new PrintWriter(outputFile));

Review Comment:
   Ick. That is bad. Let me file a bug on that. Meanwhile we might as well not 
use a PrintWriter here if we don't have to so we don't have extra changes to 
makes after the superclass is fixed. 





> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17848596#comment-17848596
 ] 

ASF GitHub Bot commented on MDEP-799:
-

LogFlames commented on code in PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#discussion_r1609858060


##
src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java:
##
@@ -137,6 +146,93 @@ public void testTreeTGFSerializing() throws Exception {
 assertTrue(findString(contents, 
"testGroupId:release:jar:1.0:compile"));
 }
 
+/**
+ * Test the JSON format serialization
+ */
+public void testTreeJsonSerializing() throws Exception {
+List contents = runTreeMojo("tree1.json", "json");
+assertTrue(findString(contents, "\"groupId\": \"testGroupId\""));
+
+assertTrue(findString(contents, "\"artifactId\": \"project\""));
+assertTrue(findString(contents, "\"artifactId\": \"release\""));
+assertTrue(findString(contents, "\"artifactId\": \"snapshot\""));
+
+assertTrue(findString(contents, "\"version\": \"1.0\""));
+assertTrue(findString(contents, "\"version\": \"2.0-SNAPSHOT\""));
+
+assertTrue(findString(contents, "\"type\": \"jar\""));
+
+assertTrue(findString(contents, "\"scope\": \"compile\""));
+}
+
+/**
+ * Test the JSON format serialization on DependencyNodes with circular 
dependence
+ */
+public void testTreeJsonCircularDependency() throws Exception {
+String outputFileName = testDir.getAbsolutePath() + "tree2.json";
+File outputFile = new File(outputFileName);
+Files.createDirectories(outputFile.getParentFile().toPath());
+outputFile.createNewFile();
+
+Artifact artifact1 = this.stubFactory.createArtifact("testGroupId", 
"project1", "1.0");
+Artifact artifact2 = this.stubFactory.createArtifact("testGroupId", 
"project2", "1.0");
+DefaultDependencyNode node1 = new DefaultDependencyNode(artifact1);
+DefaultDependencyNode node2 = new DefaultDependencyNode(artifact2);
+
+node1.setChildren(new ArrayList());
+node2.setChildren(new ArrayList());
+
+node1.getChildren().add(node2);
+node2.getChildren().add(node1);
+
+JsonDependencyNodeVisitor jsonDependencyNodeVisitor =
+new JsonDependencyNodeVisitor(new PrintWriter(outputFile));

Review Comment:
   The JsonDependencyNodeVisitor extends `AbstractSerializingVisitor` and 
passes the writer to `super(writer)` which in turn casts in to a `PrintWriter` 
if it isn't one. 
   ```java
   public AbstractSerializingVisitor(Writer writer) {
   if (writer instanceof PrintWriter) {
   this.writer = (PrintWriter) writer;
   } else {
   this.writer = new PrintWriter(writer, true);
   }
   }
   ```
   
   Do you prefer an OutputStreamWriter now, even though it is converted? Maybe 
it will make a future PR which removes the use of PrintWriter easier, but might 
also add confusion since it is converted and IOExceptions would be swallowed.





> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17848588#comment-17848588
 ] 

ASF GitHub Bot commented on MDEP-799:
-

LogFlames commented on code in PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#discussion_r1609835924


##
src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java:
##
@@ -137,6 +146,93 @@ public void testTreeTGFSerializing() throws Exception {
 assertTrue(findString(contents, 
"testGroupId:release:jar:1.0:compile"));
 }
 
+/**
+ * Test the JSON format serialization
+ */
+public void testTreeJsonSerializing() throws Exception {

Review Comment:
   good idea, its removed





> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17848585#comment-17848585
 ] 

ASF GitHub Bot commented on MDEP-799:
-

elharo commented on code in PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#discussion_r1609815080


##
src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java:
##
@@ -137,6 +146,93 @@ public void testTreeTGFSerializing() throws Exception {
 assertTrue(findString(contents, 
"testGroupId:release:jar:1.0:compile"));
 }
 
+/**
+ * Test the JSON format serialization
+ */
+public void testTreeJsonSerializing() throws Exception {
+List contents = runTreeMojo("tree1.json", "json");
+assertTrue(findString(contents, "\"groupId\": \"testGroupId\""));
+
+assertTrue(findString(contents, "\"artifactId\": \"project\""));
+assertTrue(findString(contents, "\"artifactId\": \"release\""));
+assertTrue(findString(contents, "\"artifactId\": \"snapshot\""));
+
+assertTrue(findString(contents, "\"version\": \"1.0\""));
+assertTrue(findString(contents, "\"version\": \"2.0-SNAPSHOT\""));
+
+assertTrue(findString(contents, "\"type\": \"jar\""));
+
+assertTrue(findString(contents, "\"scope\": \"compile\""));
+}
+
+/**
+ * Test the JSON format serialization on DependencyNodes with circular 
dependence
+ */
+public void testTreeJsonCircularDependency() throws Exception {
+String outputFileName = testDir.getAbsolutePath() + "tree2.json";
+File outputFile = new File(outputFileName);
+Files.createDirectories(outputFile.getParentFile().toPath());
+outputFile.createNewFile();
+
+Artifact artifact1 = this.stubFactory.createArtifact("testGroupId", 
"project1", "1.0");
+Artifact artifact2 = this.stubFactory.createArtifact("testGroupId", 
"project2", "1.0");
+DefaultDependencyNode node1 = new DefaultDependencyNode(artifact1);
+DefaultDependencyNode node2 = new DefaultDependencyNode(artifact2);
+
+node1.setChildren(new ArrayList());
+node2.setChildren(new ArrayList());
+
+node1.getChildren().add(node2);
+node2.getChildren().add(node1);
+
+JsonDependencyNodeVisitor jsonDependencyNodeVisitor =
+new JsonDependencyNodeVisitor(new PrintWriter(outputFile));

Review Comment:
   PrintWriter swallows exceptions. Just use an OutputStreamWriter



##
src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java:
##
@@ -137,6 +146,93 @@ public void testTreeTGFSerializing() throws Exception {
 assertTrue(findString(contents, 
"testGroupId:release:jar:1.0:compile"));
 }
 
+/**
+ * Test the JSON format serialization
+ */
+public void testTreeJsonSerializing() throws Exception {

Review Comment:
   Now that you have more robust JSON based tests I'd delete this test unless 
you care about JSON insignificant details like whether it's
   
   "artifactId": "snapshot"
   
   or
   
   "artifactId" :"snapshot"





> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17848582#comment-17848582
 ] 

ASF GitHub Bot commented on MDEP-799:
-

elharo commented on PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#issuecomment-2124602432

   don't worry about history; it's all just squashed anyway




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17848575#comment-17848575
 ] 

ASF GitHub Bot commented on MDEP-799:
-

LogFlames commented on PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#issuecomment-2124578566

   I apolagize for the ugly history, had some trouble with my previous merge 
when trying to rebase. 
   It should now be rebased and build on top of the latest master.




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17848548#comment-17848548
 ] 

ASF GitHub Bot commented on MDEP-799:
-

LogFlames commented on PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#issuecomment-2124488620

   The verify checks should now pass (verified in my fork), MacOS as well.
   
   A new test has been added that parses and verifies Json output.




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17848525#comment-17848525
 ] 

ASF GitHub Bot commented on MDEP-799:
-

LogFlames commented on PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#issuecomment-2124311589

   I'll add a test parsing the JSON using javax.json as suggested.
   Having some trouble with the workflow on MacOS, I'll try to debug it using a 
local workflow run, will write once it's resolved.




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-21 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17848362#comment-17848362
 ] 

ASF GitHub Bot commented on MDEP-799:
-

slawekjaranowski commented on PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#issuecomment-2123298765

   - PR should be rebased
   - a unit test or integration test will be appreciated
   




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-21 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17848356#comment-17848356
 ] 

ASF GitHub Bot commented on MDEP-799:
-

slawekjaranowski commented on PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#issuecomment-2123294364

   > Apparently not. I'm not sure who has permissions to do that.
   
   @elharo you can simply click `Approve and run`




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-20 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17847940#comment-17847940
 ] 

ASF GitHub Bot commented on MDEP-799:
-

LogFlames commented on code in PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#discussion_r1607033643


##
src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java:
##
@@ -0,0 +1,181 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugins.dependency.tree;
+
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.lang3.StringUtils;

Review Comment:
   I removed it and added manual checks for null and string repetition, wasn't 
able to get `str.repeat(conut)` to work, guessing it also build to jdk8?



##
src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java:
##
@@ -0,0 +1,181 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugins.dependency.tree;
+
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.lang3.StringUtils;

Review Comment:
   Thanks!
   I removed it and added manual checks for null and string repetition, wasn't 
able to get `str.repeat(conut)` to work, guessing it also build to jdk8?





> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-20 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17847938#comment-17847938
 ] 

ASF GitHub Bot commented on MDEP-799:
-

LogFlames commented on code in PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#discussion_r1607031255


##
src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java:
##
@@ -0,0 +1,181 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugins.dependency.tree;
+
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
+import 
org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor;
+
+/**
+ * A dependency node visitor that serializes visited nodes to a writer using 
the JSON format.
+ */
+public class JsonDependencyNodeVisitor extends AbstractSerializingVisitor 
implements DependencyNodeVisitor {
+
+private String indentChar = " ";
+
+/**
+ * Creates a new instance of {@link JsonDependencyNodeVisitor}. The writer 
will be used to write the output.
+ * @param writer  the writer to write to
+ */
+public JsonDependencyNodeVisitor(Writer writer) {
+super(writer);
+}
+
+@Override
+public boolean visit(DependencyNode node) {
+if (node.getParent() == null || node.getParent() == node) {
+writeRootNode(node);
+}
+return true;
+}
+
+/**
+ * Writes the node to the writer. This method is recursive and will write 
all children nodes.
+ * @param node  the node to write

Review Comment:
   This has been updated.



##
src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java:
##
@@ -0,0 +1,181 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugins.dependency.tree;
+
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
+import 
org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor;
+
+/**
+ * A dependency node visitor that serializes visited nodes to a writer using 
the JSON format.
+ */
+public class JsonDependencyNodeVisitor extends AbstractSerializingVisitor 
implements DependencyNodeVisitor {
+
+private String indentChar = " ";
+
+/**
+ * Creates a new instance of {@link JsonDependencyNodeVisitor}. The writer 
will be used to write the output.
+ * @param writer  the writer to write to
+ */
+public JsonDependencyNodeVisitor(Writer writer) {
+super(writer);
+}
+
+@Override
+public boolean visit(DependencyNode node) {
+if (node.getParent() == null || node.getParent() == node) {
+writeRootNode(node);
+}
+return true;
+}
+
+/**
+ * Writes the node to the writer. This method is recursive and will write 
all children nodes.
+ * @param node  the node to write
+ */
+private void writeRootNode(DependencyNode node) {
+Set visited = new HashSet();
+int indent = 2;
+StringBuilder sb = new Str

[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-20 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17847939#comment-17847939
 ] 

ASF GitHub Bot commented on MDEP-799:
-

LogFlames commented on code in PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#discussion_r1607031492


##
src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java:
##
@@ -0,0 +1,181 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugins.dependency.tree;
+
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
+import 
org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor;
+
+/**
+ * A dependency node visitor that serializes visited nodes to a writer using 
the JSON format.
+ */
+public class JsonDependencyNodeVisitor extends AbstractSerializingVisitor 
implements DependencyNodeVisitor {
+
+private String indentChar = " ";
+
+/**
+ * Creates a new instance of {@link JsonDependencyNodeVisitor}. The writer 
will be used to write the output.
+ * @param writer  the writer to write to
+ */
+public JsonDependencyNodeVisitor(Writer writer) {
+super(writer);
+}
+
+@Override
+public boolean visit(DependencyNode node) {
+if (node.getParent() == null || node.getParent() == node) {
+writeRootNode(node);
+}
+return true;
+}
+
+/**
+ * Writes the node to the writer. This method is recursive and will write 
all children nodes.
+ * @param node  the node to write
+ */
+private void writeRootNode(DependencyNode node) {
+Set visited = new HashSet();
+int indent = 2;
+StringBuilder sb = new StringBuilder();
+sb.append("{").append("\n");
+writeNode(indent, node, sb, visited);
+sb.append("}").append("\n");
+writer.write(sb.toString());
+}
+/**
+ * Appends the node and its children to the string builder.
+ * @param indent  the current indent level
+ * @param node  the node to write
+ * @param sb  the string builder to append to
+ */
+private void writeNode(int indent, DependencyNode node, StringBuilder sb, 
Set visited) {
+if (visited.contains(node)) {
+// Circular dependency detected
+// Should an exception be thrown?
+return;
+}
+visited.add(node);
+appendNodeValues(sb, indent, node.getArtifact(), 
!node.getChildren().isEmpty());
+if (!node.getChildren().isEmpty()) {
+writeChildren(indent, node, sb, visited);
+}
+}
+/**
+ * Writes the children of the node to the string builder. And each 
children of each node will be written recursively.
+ * @param indent  the current indent level
+ * @param node  the node to write
+ * @param sb  the string builder to append to
+ */
+private void writeChildren(int indent, DependencyNode node, StringBuilder 
sb, Set visited) {
+sb.append(indent(indent)).append("\"children\": [").append("\n");
+indent += 2;
+for (int i = 0; i < node.getChildren().size(); i++) {
+DependencyNode child = node.getChildren().get(i);
+sb.append(indent(indent));
+sb.append("{").append("\n");
+writeNode(indent + 2, child, sb, visited);
+sb.append(indent(indent)).append("}");
+// we skip the comma for the last child
+if (i != node.getChildren().size() - 1) {
+sb.append(",");
+}
+sb.append("\n");
+}
+sb.append(indent(indent)).append("]").append("\n");
+}
+
+@Override
+public boolean endVisit(DependencyNode node) {
+return true;
+}
+/**
+ * Appends the artifact values to the string builder.
+ * @param sb  the string builder to append to

Review Comment:
   updated





> improve mvn dependency:tree - add optional 

[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-20 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17847859#comment-17847859
 ] 

ASF GitHub Bot commented on MDEP-799:
-

elharo commented on code in PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#discussion_r1606669878


##
src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java:
##
@@ -0,0 +1,181 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugins.dependency.tree;
+
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
+import 
org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor;
+
+/**
+ * A dependency node visitor that serializes visited nodes to a writer using 
the JSON format.
+ */
+public class JsonDependencyNodeVisitor extends AbstractSerializingVisitor 
implements DependencyNodeVisitor {
+
+private String indentChar = " ";
+
+/**
+ * Creates a new instance of {@link JsonDependencyNodeVisitor}. The writer 
will be used to write the output.
+ * @param writer  the writer to write to
+ */
+public JsonDependencyNodeVisitor(Writer writer) {
+super(writer);
+}
+
+@Override
+public boolean visit(DependencyNode node) {
+if (node.getParent() == null || node.getParent() == node) {
+writeRootNode(node);
+}
+return true;
+}
+
+/**
+ * Writes the node to the writer. This method is recursive and will write 
all children nodes.
+ * @param node  the node to write
+ */
+private void writeRootNode(DependencyNode node) {
+Set visited = new HashSet();
+int indent = 2;
+StringBuilder sb = new StringBuilder();
+sb.append("{").append("\n");
+writeNode(indent, node, sb, visited);
+sb.append("}").append("\n");
+writer.write(sb.toString());
+}
+/**
+ * Appends the node and its children to the string builder.
+ * @param indent  the current indent level
+ * @param node  the node to write
+ * @param sb  the string builder to append to
+ */
+private void writeNode(int indent, DependencyNode node, StringBuilder sb, 
Set visited) {
+if (visited.contains(node)) {
+// Circular dependency detected
+// Should an exception be thrown?
+return;
+}
+visited.add(node);
+appendNodeValues(sb, indent, node.getArtifact(), 
!node.getChildren().isEmpty());
+if (!node.getChildren().isEmpty()) {
+writeChildren(indent, node, sb, visited);
+}
+}
+/**
+ * Writes the children of the node to the string builder. And each 
children of each node will be written recursively.
+ * @param indent  the current indent level
+ * @param node  the node to write
+ * @param sb  the string builder to append to
+ */
+private void writeChildren(int indent, DependencyNode node, StringBuilder 
sb, Set visited) {
+sb.append(indent(indent)).append("\"children\": [").append("\n");
+indent += 2;
+for (int i = 0; i < node.getChildren().size(); i++) {
+DependencyNode child = node.getChildren().get(i);
+sb.append(indent(indent));
+sb.append("{").append("\n");
+writeNode(indent + 2, child, sb, visited);
+sb.append(indent(indent)).append("}");
+// we skip the comma for the last child
+if (i != node.getChildren().size() - 1) {
+sb.append(",");
+}
+sb.append("\n");
+}
+sb.append(indent(indent)).append("]").append("\n");
+}
+
+@Override
+public boolean endVisit(DependencyNode node) {
+return true;
+}
+/**
+ * Appends the artifact values to the string builder.
+ * @param sb  the string builder to append to

Review Comment:
   blank line



##
src/main/java/org/apache/maven/plugi

[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-20 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17847860#comment-17847860
 ] 

ASF GitHub Bot commented on MDEP-799:
-

elharo commented on PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#issuecomment-2120296622

   Error:  Errors: 
   Error:TestTreeMojo.testTreeJsonCircularDependency:179 » FileNotFound 
/Users/runner/work/maven-dependency-plugin/maven-dependency-plugin/target/unit-tests/treetree2.json
 (No such file or directory)




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-20 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17847858#comment-17847858
 ] 

ASF GitHub Bot commented on MDEP-799:
-

elharo commented on PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#issuecomment-2120283730

   Apparently not. I'm not sure who has permissions to do that.




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-20 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17847857#comment-17847857
 ] 

ASF GitHub Bot commented on MDEP-799:
-

LogFlames commented on PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#issuecomment-2120278775

   The workflow must be approved by a maintainer. @elharo can you help?




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-17 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17847326#comment-17847326
 ] 

ASF GitHub Bot commented on MDEP-799:
-

LogFlames commented on PR #391:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/391#issuecomment-2117679372

   CLA is now registered.




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-16 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17847107#comment-17847107
 ] 

ASF GitHub Bot commented on MDEP-799:
-

LogFlames opened a new pull request, #391:
URL: https://github.com/apache/maven-dependency-plugin/pull/391

   Following this checklist to help us incorporate your 
   contribution quickly and easily:
   
- [x] Make sure there is a [JIRA 
issue](https://issues.apache.org/jira/browse/MDEP) filed 
  for the change (usually before you start working on it).  Trivial 
changes like typos do not 
  require a JIRA issue.  Your pull request should address just this 
issue, without 
  pulling in other changes.
- [x] Each commit in the pull request should have a meaningful subject line 
and body.

   Same as #325, will squash and update commit in the end, once everything is 
fixed.

- [x] Format the pull request title like `[MDEP-XXX] - Fixes bug in 
ApproximateQuantiles`,
  where you replace `MDEP-XXX` with the appropriate JIRA issue. Best 
practice
  is to use the JIRA issue title in the pull request title and in the 
first line of the 
  commit message.
- [x] Write a pull request description that is detailed enough to 
understand what the pull request does, how, and why.
- [x] Run `mvn clean verify` to make sure basic checks pass. A more 
thorough check will 
  be performed on your pull request automatically.
- [x] You have run the integration tests successfully (`mvn -Prun-its clean 
verify`).
   
- [x] I hereby declare this contribution to be licensed under the [Apache 
License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   
- [x] In any other case, please file an [Apache Individual Contributor 
License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   This is a continuation of #325, which adds JSON output type to the 
maven-depdenceny-plugin with the goal tree.
   
   The tests were disabled in the previous fork, to enable the tests (in a 
working state) this is rebased to the current master (2024-05-16), if the 
history looks weird (have some 'double' commits, unsure how to solve it). Two 
tests exists.
   
   [Discussion: 
IOException](https://github.com/apache/maven-dependency-plugin/pull/325#discussion_r1590864832)
 The JsonDependencyNodeVisitor now uses the PrintWriter which swallows 
IOExceptions, as the other Node Visitors do. Could not get it to throw an 
IOException due to the function being defined in the interface without throwing 
an Exception, unsure if this can be solved without a larger rework?
   
   [Discussion: Circular 
Dependency](https://github.com/apache/maven-dependency-plugin/pull/325#discussion_r1590867632)
 I have added a test for circular dependency, as well as a visited set to stop 
infinite recursion. This currently exists silently, but I feel there should be 
some sort of Exception or warning. Due to the same reason as above (interface 
not throwing exception) I could not find a way to do this nicely. Guessing 
RuntimeException("Detected Circular Dependency") is not an option? Happy to 
receive help with ideas/suggestions/opinions!
   
   I think all other requested changes from #325 are addressed.




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-16 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17846986#comment-17846986
 ] 

ASF GitHub Bot commented on MDEP-799:
-

elharo commented on code in PR #325:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/325#discussion_r1603507976


##
src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java:
##
@@ -127,6 +127,24 @@ public void _testTreeTGFSerializing() throws Exception {
 assertTrue(findString(contents, 
"testGroupId:release:jar:1.0:compile"));
 }
 
+/**
+ * Test the JSON format serialization
+ */
+public void _testTreeJsonSerialzing() throws Exception {
+List contents = runTreeMojo("tree1.json", "json");
+assertTrue(findString(contents, "\"testGroupId\": \"project\""));

Review Comment:
   That makes sense.





> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-16 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17846973#comment-17846973
 ] 

ASF GitHub Bot commented on MDEP-799:
-

LogFlames commented on code in PR #325:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/325#discussion_r1603482791


##
src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java:
##
@@ -127,6 +127,24 @@ public void _testTreeTGFSerializing() throws Exception {
 assertTrue(findString(contents, 
"testGroupId:release:jar:1.0:compile"));
 }
 
+/**
+ * Test the JSON format serialization
+ */
+public void _testTreeJsonSerialzing() throws Exception {
+List contents = runTreeMojo("tree1.json", "json");
+assertTrue(findString(contents, "\"testGroupId\": \"project\""));

Review Comment:
   I want to double check: do you mean `contents.contains("...")`? 
   Due to indentation the string might not be in the list of strings, but a 
substring of an element, which the `findString`-method seems to be created for 
in the same file.





> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-16 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17846974#comment-17846974
 ] 

ASF GitHub Bot commented on MDEP-799:
-

LogFlames commented on PR #325:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/325#issuecomment-2115406368

   Hi, 
   I'm working on getting this merged and incorporating the requested changes. 
Unfortunately I don't have access to Martin's fork and will need to create a 
new PR. Will build on Martin's branch and try to update all changes beforehand 
to make the transition as smooth as possible.




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-06 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17843710#comment-17843710
 ] 

ASF GitHub Bot commented on MDEP-799:
-

elharo commented on code in PR #325:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/325#discussion_r1590867632


##
src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java:
##
@@ -0,0 +1,180 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugins.dependency.tree;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
+import 
org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor;
+
+/**
+ * A dependency node visitor that serializes visited nodes to a writer using 
the JSON format.
+ */
+public class JsonDependencyNodeVisitor extends AbstractSerializingVisitor 
implements DependencyNodeVisitor {
+
+private static final String LINE_SEPARATOR = "\n";
+private String indentChar = " ";
+
+/**
+ * Creates a new instance of {@link JsonDependencyNodeVisitor}. The writer 
will be used to write the output.
+ * @param writer  the writer to write to
+ */
+public JsonDependencyNodeVisitor(Writer writer) {
+super(writer);
+}
+
+@Override
+public boolean visit(DependencyNode node) {

Review Comment:
   add a test for this case, see what works



##
src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java:
##
@@ -127,6 +127,24 @@ public void _testTreeTGFSerializing() throws Exception {
 assertTrue(findString(contents, 
"testGroupId:release:jar:1.0:compile"));
 }
 
+/**
+ * Test the JSON format serialization
+ */
+public void _testTreeJsonSerialzing() throws Exception {
+List contents = runTreeMojo("tree1.json", "json");
+assertTrue(findString(contents, "\"testGroupId\": \"project\""));

Review Comment:
   contains is clearer



##
src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java:
##
@@ -0,0 +1,179 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugins.dependency.tree;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
+import 
org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor;
+
+/**
+ * A dependency node visitor that serializes visited nodes to a writer using 
the JSON format.
+ */
+public class JsonDependencyNodeVisitor extends AbstractSerializingVisitor 
implements DependencyNodeVisitor {
+
+private String indentChar = " ";
+
+/**
+ * Creates a new instance of {@link JsonDependencyNodeVisitor}. The writer 
will be used to write the output.
+ * @param writer  the writer to write to
+ */
+public JsonDependencyNodeVisitor(Writer writer) {
+super(writer);
+}
+
+@Override
+public boolean visit(DependencyNode node) {
+if (node.getParent() == null || node.getParent() == node) {
+writeRootNode(node, writer);
+}
+return true;
+}
+

[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-05-05 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17843631#comment-17843631
 ] 

ASF GitHub Bot commented on MDEP-799:
-

monperrus commented on PR #325:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/325#issuecomment-209537

   @pombredanne @elharo if we are able to drive to merge, we can put more 
effort on this PR.




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-03-01 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17822462#comment-17822462
 ] 

ASF GitHub Bot commented on MDEP-799:
-

yahavi commented on PR #325:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/325#issuecomment-1972780341

   If it's useful to anyone, we've developed a Maven dependency tree plugin 
that generates a JSON dependency tree. Check it out at: 
https://github.com/jfrog/maven-dep-tree.




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-02-12 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17816548#comment-17816548
 ] 

ASF GitHub Bot commented on MDEP-799:
-

pombredanne commented on PR #325:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/325#issuecomment-1938280244

   Looking at the details of this PR, it feels to me that crafting the JSON by 
hand as done here feels like problems in the making with encoding or else. 
Should not this use a proper JSON library of sorts? Is not there one bundled in 
the standard Maven or Java and this plugin may therefore always have have one 
on hand? 
   
   (Sorry for these likely dumb questions: my Java skills need to brushing off)




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-02-12 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17816546#comment-17816546
 ] 

ASF GitHub Bot commented on MDEP-799:
-

pombredanne commented on code in PR #325:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/325#discussion_r1485889948


##
src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java:
##
@@ -0,0 +1,179 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugins.dependency.tree;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
+import 
org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor;
+
+/**
+ * A dependency node visitor that serializes visited nodes to a writer using 
the JSON format.
+ */
+public class JsonDependencyNodeVisitor extends AbstractSerializingVisitor 
implements DependencyNodeVisitor {
+
+private String indentChar = " ";
+
+/**
+ * Creates a new instance of {@link JsonDependencyNodeVisitor}. The writer 
will be used to write the output.
+ * @param writer  the writer to write to
+ */
+public JsonDependencyNodeVisitor(Writer writer) {
+super(writer);
+}
+
+@Override
+public boolean visit(DependencyNode node) {
+if (node.getParent() == null || node.getParent() == node) {
+writeRootNode(node, writer);
+}
+return true;
+}
+
+/**
+ * Writes the node to the writer. This method is recursive and will write 
all children nodes.
+ * @param node  the node to write
+ * @param writer  the writer to write to
+ */
+private void writeRootNode(DependencyNode node, Writer writer) {
+int indent = 2;
+StringBuilder sb = new StringBuilder();
+sb.append("{").append("\n");
+writeNode(indent, node, sb);
+sb.append("}").append("\n");
+try {
+writer.write(sb.toString());
+} catch (IOException e) {
+throw new RuntimeException("Error while writing json output", e);

Review Comment:
   What about just not catch an exception here and leaving this business to the 
callers fixing the PrintWriter could then be done in another patch and not 
here.





> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-02-12 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17816545#comment-17816545
 ] 

ASF GitHub Bot commented on MDEP-799:
-

pombredanne commented on code in PR #325:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/325#discussion_r1485887930


##
src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java:
##
@@ -0,0 +1,180 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugins.dependency.tree;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
+import 
org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor;
+
+/**
+ * A dependency node visitor that serializes visited nodes to a writer using 
the JSON format.
+ */
+public class JsonDependencyNodeVisitor extends AbstractSerializingVisitor 
implements DependencyNodeVisitor {
+
+private static final String LINE_SEPARATOR = "\n";
+private String indentChar = " ";
+
+/**
+ * Creates a new instance of {@link JsonDependencyNodeVisitor}. The writer 
will be used to write the output.
+ * @param writer  the writer to write to
+ */
+public JsonDependencyNodeVisitor(Writer writer) {
+super(writer);
+}
+
+@Override
+public boolean visit(DependencyNode node) {

Review Comment:
   @elharo the cure may be to keep track of already visited nodes and either 
fail or keep trucking?





> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-02-09 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17816039#comment-17816039
 ] 

ASF GitHub Bot commented on MDEP-799:
-

elharo commented on code in PR #325:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/325#discussion_r1484260841


##
src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java:
##
@@ -0,0 +1,179 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugins.dependency.tree;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
+import 
org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor;
+
+/**
+ * A dependency node visitor that serializes visited nodes to a writer using 
the JSON format.
+ */
+public class JsonDependencyNodeVisitor extends AbstractSerializingVisitor 
implements DependencyNodeVisitor {

Review Comment:
   Does this need to be public? It's easier to evolve and iterate on if it's 
not.



##
src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java:
##
@@ -0,0 +1,179 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugins.dependency.tree;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
+import 
org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor;
+
+/**
+ * A dependency node visitor that serializes visited nodes to a writer using 
the JSON format.
+ */
+public class JsonDependencyNodeVisitor extends AbstractSerializingVisitor 
implements DependencyNodeVisitor {
+
+private String indentChar = " ";
+
+/**
+ * Creates a new instance of {@link JsonDependencyNodeVisitor}. The writer 
will be used to write the output.
+ * @param writer  the writer to write to
+ */
+public JsonDependencyNodeVisitor(Writer writer) {
+super(writer);
+}
+
+@Override
+public boolean visit(DependencyNode node) {
+if (node.getParent() == null || node.getParent() == node) {
+writeRootNode(node, writer);
+}
+return true;
+}
+
+/**
+ * Writes the node to the writer. This method is recursive and will write 
all children nodes.
+ * @param node  the node to write
+ * @param writer  the writer to write to
+ */
+private void writeRootNode(DependencyNode node, Writer writer) {
+int indent = 2;
+StringBuilder sb = new StringBuilder();
+sb.append("{").append("\n");
+writeNode(indent, node, sb);
+sb.append("}").append("\n");
+try {
+writer.write(sb.toString());
+} catch (IOException e) {
+throw new RuntimeException("Error while writing json output", e);

Review Comment:
   needs a more specific exception. Looking at this now I notice that the 
superclass and interface are badly designed. They use a PrintWriter which 
swallows exceptions. That might need to be fixed. 





> improve mvn dependency:tree - add optional JSON output of the results
> ---

[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2024-02-09 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17816017#comment-17816017
 ] 

ASF GitHub Bot commented on MDEP-799:
-

pombredanne commented on PR #325:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/325#issuecomment-1935725046

   @MartinWitt what's left to do to get this through?
   FWIW, there is a cottage industry of smalls tools and scripts that are 
parsing this plugin output  it would be awesome to have a structure JSON 
output! 
   Anything to help you need move this forward?




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2023-06-18 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17733929#comment-17733929
 ] 

ASF GitHub Bot commented on MDEP-799:
-

MartinWitt commented on code in PR #325:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/325#discussion_r128155


##
src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java:
##
@@ -127,6 +127,24 @@ public void _testTreeTGFSerializing() throws Exception {
 assertTrue(findString(contents, 
"testGroupId:release:jar:1.0:compile"));
 }
 
+/**
+ * Test the JSON format serialization
+ */
+public void _testTreeJsonSerialzing() throws Exception {
+List contents = runTreeMojo("tree1.json", "json");
+assertTrue(findString(contents, "\"testGroupId\": \"project\""));

Review Comment:
   I tried to keep the test case in the same style as the rest of the class. 
But I can change it. 





> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2023-06-14 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17732800#comment-17732800
 ] 

ASF GitHub Bot commented on MDEP-799:
-

elharo commented on code in PR #325:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/325#discussion_r1230261635


##
src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java:
##
@@ -0,0 +1,180 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugins.dependency.tree;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
+import 
org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor;
+
+/**
+ * A dependency node visitor that serializes visited nodes to a writer using 
the JSON format.
+ */
+public class JsonDependencyNodeVisitor extends AbstractSerializingVisitor 
implements DependencyNodeVisitor {
+
+private static final String LINE_SEPARATOR = "\n";
+private String indentChar = " ";
+
+/**
+ * Creates a new instance of {@link JsonDependencyNodeVisitor}. The writer 
will be used to write the output.
+ * @param writer  the writer to write to
+ */
+public JsonDependencyNodeVisitor(Writer writer) {
+super(writer);
+}
+
+@Override
+public boolean visit(DependencyNode node) {

Review Comment:
   Is it possible for this to et stuck in an infinite recursion with a 
maliciously hand-crafted dependency node? Or for that matter, with a 
non-maliciious but buggy circular dependency tree (which does happen)?



##
src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java:
##
@@ -0,0 +1,180 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugins.dependency.tree;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
+import 
org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor;
+
+/**
+ * A dependency node visitor that serializes visited nodes to a writer using 
the JSON format.
+ */
+public class JsonDependencyNodeVisitor extends AbstractSerializingVisitor 
implements DependencyNodeVisitor {
+
+private static final String LINE_SEPARATOR = "\n";

Review Comment:
   inline this, a simple "\n" is clearer



##
src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java:
##
@@ -0,0 +1,180 @@
+/*
+ * 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
+

[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2023-06-14 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17732781#comment-17732781
 ] 

ASF GitHub Bot commented on MDEP-799:
-

MartinWitt commented on PR #325:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/325#issuecomment-1592077654

   @elharo could you approve the worflow run?




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2023-05-29 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17727076#comment-17727076
 ] 

ASF GitHub Bot commented on MDEP-799:
-

MartinWitt commented on PR #325:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/325#issuecomment-1567008233

   As I am a first-time contributor, someone has to approve the workflow run 
before we see CI results.




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2023-05-29 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17727075#comment-17727075
 ] 

ASF GitHub Bot commented on MDEP-799:
-

MartinWitt commented on code in PR #325:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/325#discussion_r1209218850


##
src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java:
##
@@ -380,6 +380,8 @@ public DependencyNodeVisitor 
getSerializingDependencyNodeVisitor(Writer writer)
 return new TGFDependencyNodeVisitor(writer);
 } else if ("dot".equals(outputType)) {
 return new DOTDependencyNodeVisitor(writer);
+} else if ("json".equals(outputType)) {
+return new JsonDependencyNodeVisitor(writer);
 } else {
 return new SerializingDependencyNodeVisitor(writer, 
toGraphTokens(tokens));

Review Comment:
   In the other PR someone asked for a switch case instead. Shall I convert 
this to a switch statement?





> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2023-05-23 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17725549#comment-17725549
 ] 

ASF GitHub Bot commented on MDEP-799:
-

elharo commented on PR #207:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/207#issuecomment-1560010041

   While I was at Google, I did successfully lobby to get GSON adopted and 
officially supported by the Java core libraries team. That was a couple of 
years ago. Things might have changed since, but anything you heard about the 
project pre-2021 is certainly out of date. 




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2023-05-23 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17725515#comment-17725515
 ] 

ASF GitHub Bot commented on MDEP-799:
-

cstamas commented on PR #207:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/207#issuecomment-1559880647

   Where?




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2023-05-23 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17725514#comment-17725514
 ] 

ASF GitHub Bot commented on MDEP-799:
-

michael-o commented on PR #207:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/207#issuecomment-1559879134

   > What makes you think that "gson is superseded"?
   
   There is a while post about it.




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2023-05-23 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17725513#comment-17725513
 ] 

ASF GitHub Bot commented on MDEP-799:
-

cstamas commented on PR #207:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/207#issuecomment-1559876445

   What makes you think that "gson is superseded"?




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2023-05-23 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17725508#comment-17725508
 ] 

ASF GitHub Bot commented on MDEP-799:
-

MartinWitt commented on PR #325:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/325#issuecomment-1559869241

   CLA is now signed and accepted. 




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2023-05-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17725116#comment-17725116
 ] 

ASF GitHub Bot commented on MDEP-799:
-

MartinWitt opened a new pull request, #325:
URL: https://github.com/apache/maven-dependency-plugin/pull/325

   Following this checklist to help us incorporate your 
   contribution quickly and easily:
   
- [X] Make sure there is a [JIRA 
issue](https://issues.apache.org/jira/browse/MDEP) filed 
  for the change (usually before you start working on it).  Trivial 
changes like typos do not 
  require a JIRA issue.  Your pull request should address just this 
issue, without 
  pulling in other changes.
- [ ] Each commit in the pull request should have a meaningful subject line 
and body.
   I will squash and update the commit in the end. There is still open 
discussion. 
   
- [X] Format the pull request title like `[MDEP-XXX] - Fixes bug in 
ApproximateQuantiles`,
  where you replace `MDEP-XXX` with the appropriate JIRA issue. Best 
practice
  is to use the JIRA issue title in the pull request title and in the 
first line of the 
  commit message.
- [ ] Write a pull request description that is detailed enough to 
understand what the pull request does, how, and why.
- [X] Run `mvn clean verify` to make sure basic checks pass. A more 
thorough check will 
  be performed on your pull request automatically.
- [ ] You have run the integration tests successfully (`mvn -Prun-its clean 
verify`).
   
   
   
   
   
- [X] I hereby declare this contribution to be licensed under the [Apache 
License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   
- [X] In any other case, please file an [Apache Individual Contributor 
License Agreement](https://www.apache.org/licenses/icla.pdf).
   I sent the mail for this a few minutes ago so it should be signed soon.
   
   
   I tried to understand the way you write unit/integration tests but it looks 
a bit complicated. What is the correct way to add a testcase? Best case, I can 
add a pom and check if the model written as json -> read by any JSON parser is 
equal to the model before.
   
   




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2023-05-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17725064#comment-17725064
 ] 

ASF GitHub Bot commented on MDEP-799:
-

michael-o commented on PR #207:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/207#issuecomment-1557684971

   > I strongly prefer no extra dependencies for this. JSON libraries in 
particular are a world of security bugs, unmaintained code, violations of Java 
conventions, and overall poor design. For JSON output, writing strings is 
straight-forward. A library shouldn't be necessary to implement this.
   > 
   > Possibly tests (and only tests) might want to parse the JSON, and for that 
a library would be helpful. Do not use Jackson. javax.json or perhaps GSON 
might be OK.
   
   GSON is superseded already.




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2023-05-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17725061#comment-17725061
 ] 

ASF GitHub Bot commented on MDEP-799:
-

elharo commented on PR #207:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/207#issuecomment-1557681374

   I strongly prefer no extra dependencies for this. JSON libraries in 
particular are a world of security bugs, unmaintained code, violations of Java 
conventions, and overall poor design. For JSON output, writing strings is 
straight-forward. A library shouldn't be necessary to implement this.
   
   Possibly tests (and only tests) might want to parse the JSON, and for that a 
library would be helpful. Do not use Jackson. javax.json or perhaps GSON might 
be OK. 
   




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2023-05-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17725048#comment-17725048
 ] 

ASF GitHub Bot commented on MDEP-799:
-

MartinWitt commented on PR #207:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/207#issuecomment-1557614971

   Hey, as this PR seems stale, and I want this feature, I would implement this 
in a new PR. Do you prefer to use a JSON library, which one do you like, or 
shall I write a JSON printer myself?




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MDEP-799) improve mvn dependency:tree - add optional JSON output of the results

2023-05-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MDEP-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17724960#comment-17724960
 ] 

ASF GitHub Bot commented on MDEP-799:
-

monperrus commented on PR #207:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/207#issuecomment-1557266817

   super cool feature, hope we can get it merged!




> improve mvn dependency:tree - add optional JSON output of the results
> -
>
> Key: MDEP-799
> URL: https://issues.apache.org/jira/browse/MDEP-799
> Project: Maven Dependency Plugin
>  Issue Type: New Feature
>  Components: tree
>Reporter: Zhenxu Ke
>Priority: Major
>
> I'd like to add an output type JSON, will open a pull request soon



--
This message was sent by Atlassian Jira
(v8.20.10#820010)