-
Notifications
You must be signed in to change notification settings - Fork 27
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
[MSHARED-1454] Expose ConflictData on DependencyNode #50
base: master
Are you sure you want to change the base?
[MSHARED-1454] Expose ConflictData on DependencyNode #50
Conversation
Would this be a feasible change to enable verbose logging output in maven-dependency-plugin? If it is preferable I could create a PR to maven-dependency-plugin that is dependent on this one to have all code-changes in context. @elharo wdyt? |
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.
Needs tests.
At first read, I don't understand what this PR is doing or why
I would like to not use this library in dependency plugin .... https://issues.apache.org/jira/browse/MDEP-969 |
I will add tests 👍 This PR would be a prerequisite for https://issues.apache.org/jira/browse/MDEP-962. Currently if running
This includes dependencies which were omitted in parenthesis and information such as The corresponding JSON output ( --- dependency:3.7.0:tree (default-cli) @ attackvector ---
[INFO] {
[INFO] "groupId": "org.evil",
[INFO] "artifactId": "attackvector",
[INFO] "version": "1.2",
[INFO] "type": "jar",
[INFO] "scope": "",
[INFO] "classifier": "",
[INFO] "optional": "false",
[INFO] "children": [
[INFO] {
[INFO] "groupId": "junit",
[INFO] "artifactId": "junit",
[INFO] "version": "4.11",
[INFO] "type": "jar",
[INFO] "scope": "test",
[INFO] "classifier": "",
[INFO] "optional": "false",
[INFO] "children": [
[INFO] {
[INFO] "groupId": "org.hamcrest",
[INFO] "artifactId": "hamcrest-core",
[INFO] "version": "1.3",
[INFO] "type": "jar",
[INFO] "scope": "test",
[INFO] "classifier": "",
[INFO] "optional": "false"
[INFO] }
[INFO] ]
[INFO] },
[INFO] {
[INFO] "groupId": "org.postgresql",
[INFO] "artifactId": "postgresql",
[INFO] "version": "42.6.0",
[INFO] "type": "jar",
[INFO] "scope": "compile",
[INFO] "classifier": "",
[INFO] "optional": "false",
[INFO] "children": [
[INFO] {
[INFO] "groupId": "org.checkerframework",
[INFO] "artifactId": "checker-qual",
[INFO] "version": "3.31.0",
[INFO] "type": "jar",
[INFO] "scope": "runtime",
[INFO] "classifier": "",
[INFO] "optional": "false"
[INFO] }
[INFO] ]
[INFO] },
[INFO] {
[INFO] "groupId": "org.springframework",
[INFO] "artifactId": "spring-jdbc",
[INFO] "version": "5.3.27",
[INFO] "type": "jar",
[INFO] "scope": "compile",
[INFO] "classifier": "",
[INFO] "optional": "false",
[INFO] "children": [
[INFO] {
[INFO] "groupId": "org.springframework",
[INFO] "artifactId": "spring-beans",
[INFO] "version": "5.3.27",
[INFO] "type": "jar",
[INFO] "scope": "compile",
[INFO] "classifier": "",
[INFO] "optional": "false",
[INFO] "children": [
[INFO] {
[INFO] "groupId": "org.springframework",
[INFO] "artifactId": "spring-core",
[INFO] "version": "5.3.27",
[INFO] "type": "jar",
[INFO] "scope": "compile",
[INFO] "classifier": "",
[INFO] "optional": "false"
[INFO] }
[INFO] ]
[INFO] },
[INFO] {
[INFO] "groupId": "org.springframework",
[INFO] "artifactId": "spring-core",
[INFO] "version": "5.3.27",
[INFO] "type": "jar",
[INFO] "scope": "compile",
[INFO] "classifier": "",
[INFO] "optional": "false",
[INFO] "children": [
[INFO] {
[INFO] "groupId": "org.springframework",
[INFO] "artifactId": "spring-jcl",
[INFO] "version": "5.3.27",
[INFO] "type": "jar",
[INFO] "scope": "compile",
[INFO] "classifier": "",
[INFO] "optional": "false"
[INFO] }
[INFO] ]
[INFO] },
[INFO] {
[INFO] "groupId": "org.springframework",
[INFO] "artifactId": "spring-tx",
[INFO] "version": "5.3.27",
[INFO] "type": "jar",
[INFO] "scope": "compile",
[INFO] "classifier": "",
[INFO] "optional": "false",
[INFO] "children": [
[INFO] {
[INFO] "groupId": "org.springframework",
[INFO] "artifactId": "spring-beans",
[INFO] "version": "5.3.27",
[INFO] "type": "jar",
[INFO] "scope": "compile",
[INFO] "classifier": "",
[INFO] "optional": "false"
[INFO] },
[INFO] {
[INFO] "groupId": "org.springframework",
[INFO] "artifactId": "spring-core",
[INFO] "version": "5.3.27",
[INFO] "type": "jar",
[INFO] "scope": "compile",
[INFO] "classifier": "",
[INFO] "optional": "false"
[INFO] }
[INFO] ]
[INFO] }
[INFO] ]
[INFO] },
[...] The argument My goal with this change would be to construct more useful JSON programmatically, where more key-value pairs could be added: /**
* Appends the artifact values to the string builder.
*
* @param sb the string builder to append to
* @param indent the current indent level
* @param artifact the artifact to write
* @param hasChildren true if the artifact has children
*/
- private void appendNodeValues(StringBuilder sb, int indent, Artifact artifact, boolean hasChildren) {
+ private void appendNodeValues(StringBuilder sb, int indent, Artifact artifact, DependencyNode node, boolean hasChildren) {
appendKeyValue(sb, indent, "groupId", artifact.getGroupId());
appendKeyValue(sb, indent, "artifactId", artifact.getArtifactId());
appendKeyValue(sb, indent, "version", artifact.getVersion());
appendKeyValue(sb, indent, "type", artifact.getType());
appendKeyValue(sb, indent, "scope", artifact.getScope());
appendKeyValue(sb, indent, "classifier", artifact.getClassifier());
+ if (node.getGetConflictData() != null) {
+ ConflictData conflictData = node.getGetConflictData();
+ appendKeyValue(sb, indent, "included", conflictData.getWinnerVersion() == null);
+ if (conflictData.getOriginalVersion() != null) {
+ appendKeyValue(sb, indent, "version_updated_from", conflictData.getOriginalVersion());
+ }
+ if (conflictData.getIgnoredScope() != null) {
+ appendKeyValue(sb, indent, "scope_not_updated_to", conflictData.getIgnoredScope());
+ }
+ }
[...] Using the resolver API directly would be a nice way to solve this as well, as ConflictData is a subset of the Aether's DependencyNode.getData(), which seems to be what the resolver API works with. |
Happy new year! Have you had time to look at the comments above? Is it still unclear? |
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.
[MSHARED-XXX] - Fixes bug in ApproximateQuantiles
,where you replace
MSHARED-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.
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.
In maven-dependency-plugin there are multiple export formats for the dependency tree, these include Json, DOT, GraphML etc. When creating the normal tree all information is there to format it nicely as e.g. Json. However, when running
mvn dependency:tree -Dverbose
, all nodes are included (as they are VerboseDependencyNode) but since VerboseDependencyNode is internal in maven-dependency-tree there is no (clean) way to include information of which nodes are included or not (see https://issues.apache.org/jira/browse/MDEP-962).The only current way to include this information would be to parse the
toNodeString()
output (where excluded nodes are wrapped in parenthesis).I propose to expose ConflictData on the DependencyNode and make it null for DefaultDependencyNode to allow for more detailed information in the machine-readable formats.