use of com.google.devtools.build.lib.rules.java.DeployArchiveBuilder in project bazel by bazelbuild.
the class AndroidBinary method createDeployJar.
/** Generates an uncompressed _deploy.jar of all the runtime jars. */
public static Artifact createDeployJar(RuleContext ruleContext, JavaSemantics javaSemantics, AndroidCommon common, JavaTargetAttributes attributes, Function<Artifact, Artifact> derivedJarFunction) throws InterruptedException {
Artifact deployJar = ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_BINARY_DEPLOY_JAR);
new DeployArchiveBuilder(javaSemantics, ruleContext).setOutputJar(deployJar).setAttributes(attributes).addRuntimeJars(common.getRuntimeJars()).setDerivedJarFunction(derivedJarFunction).build();
return deployJar;
}
use of com.google.devtools.build.lib.rules.java.DeployArchiveBuilder in project bazel by bazelbuild.
the class AndroidBinary method getStubDex.
private static Artifact getStubDex(RuleContext ruleContext, JavaSemantics javaSemantics, boolean split) throws InterruptedException {
String attribute = split ? "$incremental_split_stub_application" : "$incremental_stub_application";
TransitiveInfoCollection dep = ruleContext.getPrerequisite(attribute, Mode.TARGET);
if (dep == null) {
ruleContext.attributeError(attribute, "Stub application cannot be found");
return null;
}
JavaCompilationArgsProvider provider = dep.getProvider(JavaCompilationArgsProvider.class);
if (provider == null) {
ruleContext.attributeError(attribute, "'" + dep.getLabel() + "' should be a Java target");
return null;
}
JavaTargetAttributes attributes = new JavaTargetAttributes.Builder(javaSemantics).addRuntimeClassPathEntries(provider.getJavaCompilationArgs().getRuntimeJars()).build();
Function<Artifact, Artifact> desugaredJars = Functions.identity();
if (AndroidCommon.getAndroidConfig(ruleContext).desugarJava8()) {
desugaredJars = collectDesugaredJarsFromAttributes(ruleContext, ImmutableList.of(attribute)).build().collapseToFunction();
}
Artifact stubDeployJar = getDxArtifact(ruleContext, split ? "split_stub_deploy.jar" : "stub_deploy.jar");
new DeployArchiveBuilder(javaSemantics, ruleContext).setOutputJar(stubDeployJar).setAttributes(attributes).setDerivedJarFunction(desugaredJars).build();
Artifact stubDex = getDxArtifact(ruleContext, split ? "split_stub_application/classes.dex" : "stub_application/classes.dex");
AndroidCommon.createDexAction(ruleContext, stubDeployJar, stubDex, ImmutableList.<String>of(), false, null);
return stubDex;
}
Aggregations