Skip to content

Commit 7d13364

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

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

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

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@
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;
55-
import org.gradle.api.provider.SetProperty;
56+
import org.gradle.api.tasks.Input;
5657
import org.gradle.api.tasks.Internal;
5758
import org.gradle.api.tasks.OutputFile;
5859
import 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

Comments
 (0)