Allow proguard whitelister to be a deploy jar
@@ -73,7 +73,7 @@ public final class ProguardLibrary {
return specsBuilder.build();
}
for (Artifact specToValidate : localSpecs) {
- specsBuilder.add(validateProguardSpec(proguardAllowlister, specToValidate));
+ specsBuilder.add(validateProguardSpec(ruleContext, proguardAllowlister, specToValidate));
}
}
@@ -109,7 +109,7 @@ public final class ProguardLibrary {
* validated Proguard spec, ready to be exported.
*/
private Artifact validateProguardSpec(
- FilesToRunProvider proguardAllowlister, Artifact specToValidate) {
+ RuleContext ruleContext, FilesToRunProvider proguardAllowlister, Artifact specToValidate) {
// If we're validating j/a/b/testapp/proguard.cfg, the output will be:
// j/a/b/testapp/proguard.cfg_valid
Artifact output =
@@ -119,19 +119,29 @@ public final class ProguardLibrary {
.getRootRelativePath()
.replaceName(specToValidate.getFilename() + "_valid"),
ruleContext.getBinOrGenfilesDirectory());
- ruleContext.registerAction(
- new SpawnAction.Builder()
- .addInput(specToValidate)
- .addOutput(output)
- .setExecutable(proguardAllowlister)
+ SpawnAction.Builder builder =
+ new SpawnAction.Builder().addInput(specToValidate).addOutput(output);
+ if (proguardAllowlister.getExecutable().getExtension().equals("jar")) {
+ builder
+ .setJarExecutable(
+ JavaCommon.getHostJavaExecutable(ruleContext),
+ proguardAllowlister.getExecutable(),
+ JavaToolchainProvider.from(ruleContext).getJvmOptions())
+ .addTransitiveInputs(JavaRuntimeInfo.forHost(ruleContext).javaBaseInputsMiddleman());
+ } else {
+ // TODO(b/170769708): remove this branch and require java_toolchain.proguard_allowlister to
+ // always be a _deploy.jar
+ builder.setExecutable(proguardAllowlister);
+ }
+ builder
.setProgressMessage("Validating proguard configuration")
.setMnemonic("ValidateProguard")
.addCommandLine(
CustomCommandLine.builder()
.addExecPath("--path", specToValidate)
.addExecPath("--output", output)
- .build())
- .build(ruleContext));
+ .build());
+ ruleContext.registerAction(builder.build(ruleContext));
return output;
}
}
