18
18
19
19
import org .gradle .api .NonNullApi ;
20
20
import org .gradle .api .artifacts .component .ComponentIdentifier ;
21
+ import org .gradle .api .artifacts .component .ComponentSelector ;
21
22
import org .gradle .api .artifacts .component .ModuleComponentIdentifier ;
23
+ import org .gradle .api .artifacts .component .ModuleComponentSelector ;
22
24
import org .gradle .api .artifacts .result .DependencyResult ;
23
25
import org .gradle .api .artifacts .result .ResolvedArtifactResult ;
24
26
import org .gradle .api .artifacts .result .ResolvedDependencyResult ;
@@ -65,6 +67,7 @@ public Set<RenderableDependency> getChildren() {
65
67
66
68
@ Override
67
69
public String getName () {
70
+ ComponentSelector requested = getRequested ();
68
71
ComponentIdentifier selected = getActual ();
69
72
ResolvedArtifactResult artifact = resolvedJars .stream ().filter (a ->
70
73
a .getId ().getComponentIdentifier ().equals (selected )).findFirst ().orElse (null );
@@ -78,15 +81,30 @@ public String getName() {
78
81
return "[CLASSPATH] " + selected .getDisplayName ();
79
82
} else {
80
83
String version = "" ;
84
+ String coordinates = selected .getDisplayName ();
85
+ String jarName = artifact .getFile ().getName ();
81
86
if (selected instanceof ModuleComponentIdentifier ) {
82
- version = " (" + ((ModuleComponentIdentifier ) selected ).getVersion () + ")" ;
87
+ String selectedVersion = ((ModuleComponentIdentifier ) selected ).getVersion ();
88
+ version = " (" + selectedVersion + ")" ;
89
+ if (requested instanceof ModuleComponentSelector ) {
90
+ String requestedVersion = ((ModuleComponentSelector ) requested ).getVersion ();
91
+ if (!requestedVersion .isEmpty () && !selectedVersion .equals (requestedVersion )) {
92
+ version = " (" + requestedVersion + " -> " + selectedVersion + ")" ;
93
+ }
94
+ }
95
+ coordinates = ((ModuleComponentIdentifier ) selected ).getModuleIdentifier ().toString ();
83
96
}
84
97
String auto = isRealModule (artifact .getFile ()) ? "" : "[AUTO] " ;
85
- return auto + actualModuleName + version ;
98
+ return auto + actualModuleName + version + " | " + coordinates +
99
+ (isConstraint () ? "" : " | " + jarName );
86
100
}
87
101
}
88
102
} catch (IOException e ) {
89
103
throw new RuntimeException (e );
90
104
}
91
105
}
106
+
107
+ private boolean isConstraint () {
108
+ return getResolutionState () == ResolutionState .RESOLVED_CONSTRAINT ;
109
+ }
92
110
}
0 commit comments