Do not run imported jars through ijar when --nouse_ijars is on the command line.
RELNOTES: None.
@@ -73,7 +73,7 @@ public class JavaImport implements RuleConfiguredTargetFactory {
ImmutableBiMap.Builder<Artifact, Artifact> compilationToRuntimeJarMapBuilder =
ImmutableBiMap.builder();
ImmutableList<Artifact> interfaceJars =
- processWithIjar(jars, ruleContext, compilationToRuntimeJarMapBuilder);
+ processWithIjarIfNeeded(jars, ruleContext, compilationToRuntimeJarMapBuilder);
JavaCompilationArtifacts javaArtifacts = collectJavaArtifacts(jars, interfaceJars);
common.setJavaCompilationArtifacts(javaArtifacts);
@@ -234,17 +234,21 @@ public class JavaImport implements RuleConfiguredTargetFactory {
return ImmutableList.copyOf(jars);
}
- private ImmutableList<Artifact> processWithIjar(ImmutableList<Artifact> jars,
+ private ImmutableList<Artifact> processWithIjarIfNeeded(ImmutableList<Artifact> jars,
RuleContext ruleContext,
ImmutableMap.Builder<Artifact, Artifact> compilationToRuntimeJarMap) {
ImmutableList.Builder<Artifact> interfaceJarsBuilder = ImmutableList.builder();
+ boolean useIjar = ruleContext.getFragment(JavaConfiguration.class).getUseIjars();
for (Artifact jar : jars) {
- Artifact ijar = JavaCompilationHelper.createIjarAction(
+ Artifact interfaceJar = useIjar
+ ? JavaCompilationHelper.createIjarAction(
ruleContext,
JavaCompilationHelper.getJavaToolchainProvider(ruleContext),
- jar, true);
- interfaceJarsBuilder.add(ijar);
- compilationToRuntimeJarMap.put(ijar, jar);
+ jar,
+ true)
+ : jar;
+ interfaceJarsBuilder.add(interfaceJar);
+ compilationToRuntimeJarMap.put(interfaceJar, jar);
}
return interfaceJarsBuilder.build();
}
