-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MDEP-435] Added xml outputType to dependency tree #24
base: master
Are you sure you want to change the base?
Conversation
|
To improve this patch:
|
@rfscholte Thanks for the comment.
|
Yes, that xml is closer to what I would expect. The roottag could be |
@rfscholte Oukej, I'll update it and add tests |
|
@rfscholte Is this more to your liking? |
As for the tests.... I have an issue as all the tree dependency tests are disabled for the moment and not quite working. My skill in java is not good enough to make it work 😿 |
Looks quite good, just know that a project cannot have a |
Will update the root node then |
|
I don't really understand what you mean. On master branch, running
Could you please elaborate? |
As i understand it
|
So whats the next step? It would really help me in my project to have it in official release |
@rfscholte Hey, do you know anyone responsible for accepting merge requests? I would love to push it to next stage... |
Maven is maintained by a very small group of volunteers. |
@@ -107,7 +107,8 @@ | |||
|
|||
/** | |||
* If specified, this parameter will cause the dependency tree to be written using the specified format. Currently | |||
* supported format are: <code>text</code> (default), <code>dot</code>, <code>graphml</code> and <code>tgf</code>. | |||
* supported format are: | |||
* <code>text</code> (default), <code>dot</code>, <code>graphml</code>, <code>tgf</code> and <code>xml</code>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's reformat this to an unordered list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but i do not understand the request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like
<ul>
<li>text (default)</li>
<li>dot</li>
..
Or
<dd>
<dt>text</dt>
<dd>A textual tree (default)<dd/>
<dt>dot</dt>
<dd>Textual output based on the DOT graph description language</dd>
..
{ | ||
if ( node.getParent() == null || node.getParent() == node ) | ||
{ | ||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually using DocumentBuilder and Transformer look like quite some overhead for something simple like this. I think there are faster implementations that can directly write proper xml.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not code in java, so google is my main source and i haven't found any other way. As for the XXE. It is not parsing an XML byt creating it, so it should be ok right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @rfscholte that this is quite a heavy approach. The PrettyPrintXMLWriter
from maven-shared-utils looks promising to me. It looks promising (less code, simpler code) but I'm struggling to make the tests pass. Simply put, I don't know how verify if I did it correctly.
@S4n60w3n, if I created a pull request on your MDEP-435 branch, could you verify that the PrettyPrintXMLWriter-approach gives the same outcome as your DOM-based one? Alternatively, could you tell me how I can verify that your implementation and mine have the same outcome?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mthmulders I will try to make time for that, but basically if you run my implementation and yours on this repo and output it to the file. Then you can make diff. It should be the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is too heavyweight, but you should set namespace aware to true on the factory.
} | ||
catch ( ParserConfigurationException | TransformerException e ) | ||
{ | ||
e.printStackTrace(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think of a better solution: either log with Logger or rethrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
* @param doc Docuemnt to use | ||
* @param node Node to get data from | ||
*/ | ||
private Element getNode( Document doc, DependencyNode node, Boolean root ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to use Boolean Object, primitive is preferred here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@rfscholte Thanks for the review. It is much appreciated. I`ll fix your comments |
@@ -107,8 +107,14 @@ | |||
|
|||
/** | |||
* If specified, this parameter will cause the dependency tree to be written using the specified format. Currently | |||
* supported format are: <code>text</code> (default), <code>dot</code>, <code>graphml</code> and <code>tgf</code>. | |||
* These additional formats can be plotted to image files. | |||
* supported format are: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format --> formats
@@ -107,8 +107,14 @@ | |||
|
|||
/** | |||
* If specified, this parameter will cause the dependency tree to be written using the specified format. Currently |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will cause --> causes (tech writing lives in the eternal present)
/** | ||
* Render child with its children recursively | ||
* | ||
* @param doc Docuemnt to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
document
/** | ||
* Get element from node | ||
* | ||
* @param doc Docuemnt to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sp: document
* Get element from node | ||
* | ||
* @param doc Docuemnt to use | ||
* @param node Node to get data from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Node --> node (per sun javadoc conventions)
* @author <a href="mailto:[email protected]">Bogdan Sikora</a> | ||
* @since 3.1.2 | ||
*/ | ||
public class XMLDependencyNodeVisitor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this class have to be public?
{ | ||
if ( node.getParent() == null || node.getParent() == node ) | ||
{ | ||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is too heavyweight, but you should set namespace aware to true on the factory.
|
||
if ( root ) | ||
{ | ||
element = doc.createElement( "project" ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A separate method for the root rather than an if statement would reduce cyclomatic complexity
|
||
if ( root ) | ||
{ | ||
element = doc.createElement( "project" ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's weird that the syntax is sort of like a pom but not fully a POM. E.g. the namespaces are different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, seems like it should have an XSD as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs tests.
handleChild( doc, child, rootElement ); | ||
} | ||
|
||
TransformerFactory transformerFactory = TransformerFactory.newInstance(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The serialization could be split out into a separate method.
* | ||
* @param writer the writer to write to. | ||
*/ | ||
public XMLDependencyNodeVisitor( Writer writer ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Writers can't be guaranteed to handle encoding properly when the XML is serialized. This should be an output stream.
/** | ||
* Constructor. | ||
* | ||
* @param writer the writer to write to. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: no period at end of doc comment, per sun Javadoc style
Switching to https://maven.apache.org/shared/maven-shared-utils/apidocs/org/apache/maven/shared/utils/xml/PrettyPrintXMLWriter.html is my preferred lightweight solution |
I |
Following this checklist to help us incorporate your
contribution quickly and easily:
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.
[MDEP-XXX] - Fixes bug in ApproximateQuantiles
,where you replace
MDEP-XXX
with the appropriate JIRA issue. Best practiceis to use the JIRA issue title in the pull request title and in the first line of the
commit message.
mvn clean verify
to make sure basic checks pass. A more thorough check willbe performed on your pull request automatically.
mvn -Prun-its clean verify
).If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.
I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004
In any other case, please file an Apache Individual Contributor License Agreement.