Fix location expansion for jvm_flags_for_cds_image_creation
Use exec paths instead of runfiles paths, and add 'data' to the inputs
of the action that creates the CDS image.
@@ -24,6 +24,7 @@ import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.MutableActionGraph.ActionConflictException;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
import com.google.devtools.build.lib.analysis.OutputGroupInfo;
+import com.google.devtools.build.lib.analysis.PrerequisiteArtifacts;
import com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder;
import com.google.devtools.build.lib.analysis.RuleConfiguredTargetFactory;
import com.google.devtools.build.lib.analysis.RuleContext;
@@ -542,13 +543,17 @@ public class JavaBinary implements RuleConfiguredTargetFactory {
commandLine.addFormatted("-XX:SharedArchiveConfigFile=%s", configFile.getExecPath());
}
commandLine.add("-cp").addExecPath(merged);
+ SpawnAction.Builder spawnAction = new SpawnAction.Builder();
if (ruleContext.getRule().isAttrDefined("jvm_flags_for_cds_image_creation", Type.STRING_LIST)) {
commandLine.addAll(
- ruleContext.getExpander().withDataLocations().list("jvm_flags_for_cds_image_creation"));
- }
-
- SpawnAction.Builder spawnAction =
- new SpawnAction.Builder()
+ ruleContext
+ .getExpander()
+ .withDataExecLocations()
+ .list("jvm_flags_for_cds_image_creation"));
+ spawnAction.addTransitiveInputs(
+ PrerequisiteArtifacts.nestedSet(ruleContext, "data", TransitionMode.TARGET));
+ }
+ spawnAction
.setExecutable(javaRuntime.javaBinaryExecPathFragment())
.addCommandLine(commandLine.build())
.addOutput(jsa)
