Skip to content

Commit d4b8af7

Browse files
committed
Refactor @internal properties to @input
1 parent e2d7aeb commit d4b8af7

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

native-gradle-plugin/src/main/java/org/graalvm/buildtools/gradle/tasks/GenerateDynamicAccessMetadata.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@
5151
import org.gradle.api.artifacts.result.ResolvedComponentResult;
5252
import org.gradle.api.artifacts.result.ResolvedDependencyResult;
5353
import org.gradle.api.file.RegularFileProperty;
54+
import org.gradle.api.provider.MapProperty;
5455
import org.gradle.api.provider.Property;
5556
import org.gradle.api.provider.SetProperty;
57+
import org.gradle.api.tasks.Input;
5658
import org.gradle.api.tasks.Internal;
5759
import org.gradle.api.tasks.OutputFile;
5860
import 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

Comments
 (0)