1818
1919import org .gradle .api .NonNullApi ;
2020import org .gradle .api .artifacts .component .ComponentIdentifier ;
21+ import org .gradle .api .artifacts .component .ComponentSelector ;
2122import org .gradle .api .artifacts .component .ModuleComponentIdentifier ;
23+ import org .gradle .api .artifacts .component .ModuleComponentSelector ;
2224import org .gradle .api .artifacts .result .DependencyResult ;
2325import org .gradle .api .artifacts .result .ResolvedArtifactResult ;
2426import org .gradle .api .artifacts .result .ResolvedDependencyResult ;
@@ -65,6 +67,7 @@ public Set<RenderableDependency> getChildren() {
6567
6668 @ Override
6769 public String getName () {
70+ ComponentSelector requested = getRequested ();
6871 ComponentIdentifier selected = getActual ();
6972 ResolvedArtifactResult artifact = resolvedJars .stream ().filter (a ->
7073 a .getId ().getComponentIdentifier ().equals (selected )).findFirst ().orElse (null );
@@ -78,15 +81,30 @@ public String getName() {
7881 return "[CLASSPATH] " + selected .getDisplayName ();
7982 } else {
8083 String version = "" ;
84+ String coordinates = selected .getDisplayName ();
85+ String jarName = artifact .getFile ().getName ();
8186 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 ();
8396 }
8497 String auto = isRealModule (artifact .getFile ()) ? "" : "[AUTO] " ;
85- return auto + actualModuleName + version ;
98+ return auto + actualModuleName + version + " | " + coordinates +
99+ (isConstraint () ? "" : " | " + jarName );
86100 }
87101 }
88102 } catch (IOException e ) {
89103 throw new RuntimeException (e );
90104 }
91105 }
106+
107+ private boolean isConstraint () {
108+ return getResolutionState () == ResolutionState .RESOLVED_CONSTRAINT ;
109+ }
92110}
0 commit comments