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 ;
55- import org .gradle .api .provider . SetProperty ;
56+ import org .gradle .api .tasks . Input ;
5657import org .gradle .api .tasks .Internal ;
5758import org .gradle .api .tasks .OutputFile ;
5859import org .gradle .api .tasks .TaskAction ;
@@ -82,14 +83,23 @@ public abstract class GenerateDynamicAccessMetadata extends DefaultTask {
8283
8384 public void setClasspath (Configuration classpath ) {
8485 getRuntimeClasspathGraph ().set (classpath .getIncoming ().getResolutionResult ().getRootComponent ());
85- getRuntimeClasspathArtifacts ().set (classpath .getIncoming ().getArtifacts ().getResolvedArtifacts ());
86+
87+ // Build coordinates -> path map
88+ Map <String , String > map = new HashMap <>();
89+ for (ResolvedArtifactResult artifact : classpath .getIncoming ().getArtifacts ().getResolvedArtifacts ().get ()) {
90+ if (artifact .getId ().getComponentIdentifier () instanceof ModuleComponentIdentifier mci ) {
91+ String coordinates = mci .getGroup () + ":" + mci .getModule ();
92+ map .put (coordinates , artifact .getFile ().getAbsolutePath ());
93+ }
94+ }
95+ getCoordinatesToPath ().set (map );
8696 }
8797
88- @ Internal
98+ @ Input
8999 public abstract Property <ResolvedComponentResult > getRuntimeClasspathGraph ();
90100
91- @ Internal
92- public abstract SetProperty < ResolvedArtifactResult > getRuntimeClasspathArtifacts ();
101+ @ Input
102+ public abstract MapProperty < String , String > getCoordinatesToPath ();
93103
94104 @ Internal
95105 public abstract Property <GraalVMReachabilityMetadataService > getMetadataService ();
@@ -115,17 +125,9 @@ public void generate() {
115125 try {
116126 Set <String > artifactsToInclude = DynamicAccessMetadataUtils .readArtifacts (jsonFile );
117127
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-
126128 ResolvedComponentResult root = getRuntimeClasspathGraph ().get ();
127129
128- Map <String , Set <String >> exportMap = buildExportMap (root , artifactsToInclude , coordinatesToPath );
130+ Map <String , Set <String >> exportMap = buildExportMap (root , artifactsToInclude , getCoordinatesToPath (). get () );
129131
130132 serializeExportMap (getOutputJson ().getAsFile ().get (), exportMap );
131133 } catch (IOException e ) {
0 commit comments