[MDEP-799] tree: add optional output type json by LogFlames · Pull Request #391 · apache/maven-dependency-plugin (original) (raw)

Following this checklist to help us incorporate your
contribution quickly and easily:

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

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 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 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.