Search in sources :

Example 1 with DeployArchiveBuilder

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;
}
Also used : DeployArchiveBuilder(com.google.devtools.build.lib.rules.java.DeployArchiveBuilder) Artifact(com.google.devtools.build.lib.actions.Artifact)

Example 2 with DeployArchiveBuilder

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;
}
Also used : JavaCompilationArgsProvider(com.google.devtools.build.lib.rules.java.JavaCompilationArgsProvider) MultimapBuilder(com.google.common.collect.MultimapBuilder) Builder(com.google.devtools.build.lib.analysis.actions.SpawnAction.Builder) NestedSetBuilder(com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder) RuleConfiguredTargetBuilder(com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder) DeployArchiveBuilder(com.google.devtools.build.lib.rules.java.DeployArchiveBuilder) DeployArchiveBuilder(com.google.devtools.build.lib.rules.java.DeployArchiveBuilder) TransitiveInfoCollection(com.google.devtools.build.lib.analysis.TransitiveInfoCollection) JavaTargetAttributes(com.google.devtools.build.lib.rules.java.JavaTargetAttributes) Artifact(com.google.devtools.build.lib.actions.Artifact)

Aggregations

Artifact (com.google.devtools.build.lib.actions.Artifact)2 DeployArchiveBuilder (com.google.devtools.build.lib.rules.java.DeployArchiveBuilder)2 MultimapBuilder (com.google.common.collect.MultimapBuilder)1 RuleConfiguredTargetBuilder (com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder)1 TransitiveInfoCollection (com.google.devtools.build.lib.analysis.TransitiveInfoCollection)1 Builder (com.google.devtools.build.lib.analysis.actions.SpawnAction.Builder)1 NestedSetBuilder (com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder)1 JavaCompilationArgsProvider (com.google.devtools.build.lib.rules.java.JavaCompilationArgsProvider)1 JavaTargetAttributes (com.google.devtools.build.lib.rules.java.JavaTargetAttributes)1