5151import org .gradle .api .artifacts .result .ResolvedComponentResult ;
5252import org .gradle .api .artifacts .result .ResolvedDependencyResult ;
5353import org .gradle .api .file .RegularFileProperty ;
54+ import org .gradle .api .provider .MapProperty ;
5455import org .gradle .api .provider .Property ;
5556import org .gradle .api .provider .SetProperty ;
57+ import org .gradle .api .tasks .Input ;
5658import org .gradle .api .tasks .Internal ;
5759import org .gradle .api .tasks .OutputFile ;
5860import org .gradle .api .tasks .TaskAction ;
@@ -82,14 +84,23 @@ public abstract class GenerateDynamicAccessMetadata extends DefaultTask {
8284
8385 public void setClasspath (Configuration classpath ) {
8486 getRuntimeClasspathGraph ().set (classpath .getIncoming ().getResolutionResult ().getRootComponent ());
85- getRuntimeClasspathArtifacts ().set (classpath .getIncoming ().getArtifacts ().getResolvedArtifacts ());
87+
88+ // Build coordinates -> path map
89+ Map <String , String > map = new HashMap <>();
90+ for (ResolvedArtifactResult artifact : classpath .getIncoming ().getArtifacts ().getResolvedArtifacts ().get ()) {
91+ if (artifact .getId ().getComponentIdentifier () instanceof ModuleComponentIdentifier mci ) {
92+ String coordinates = mci .getGroup () + ":" + mci .getModule ();
93+ map .put (coordinates , artifact .getFile ().getAbsolutePath ());
94+ }
95+ }
96+ getCoordinatesToPath ().set (map );
8697 }
8798
88- @ Internal
99+ @ Input
89100 public abstract Property <ResolvedComponentResult > getRuntimeClasspathGraph ();
90101
91- @ Internal
92- public abstract SetProperty < ResolvedArtifactResult > getRuntimeClasspathArtifacts ();
102+ @ Input
103+ public abstract MapProperty < String , String > getCoordinatesToPath ();
93104
94105 @ Internal
95106 public abstract Property <GraalVMReachabilityMetadataService > getMetadataService ();
@@ -115,17 +126,9 @@ public void generate() {
115126 try {
116127 Set <String > artifactsToInclude = DynamicAccessMetadataUtils .readArtifacts (jsonFile );
117128
118- Map <String , String > coordinatesToPath = new HashMap <>();
119- for (ResolvedArtifactResult artifact : getRuntimeClasspathArtifacts ().get ()) {
120- if (artifact .getId ().getComponentIdentifier () instanceof ModuleComponentIdentifier mci ) {
121- String coordinates = mci .getGroup () + ":" + mci .getModule ();
122- coordinatesToPath .put (coordinates , artifact .getFile ().getAbsolutePath ());
123- }
124- }
125-
126129 ResolvedComponentResult root = getRuntimeClasspathGraph ().get ();
127130
128- Map <String , Set <String >> exportMap = buildExportMap (root , artifactsToInclude , coordinatesToPath );
131+ Map <String , Set <String >> exportMap = buildExportMap (root , artifactsToInclude , getCoordinatesToPath (). get () );
129132
130133 serializeExportMap (getOutputJson ().getAsFile ().get (), exportMap );
131134 } catch (IOException e ) {
0 commit comments