aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/android
diff options
context:
space:
mode:
authorGravatar Andrew Pellegrini <apell@google.com>2015-08-04 16:21:38 +0000
committerGravatar John Field <jfield@google.com>2015-08-04 20:26:34 +0000
commit7d57154cda1c500d70ff5134e8ee2892ce60050d (patch)
treecb9c0c016b67c937ae6a911b1870a5f02d026a98 /src/main/java/com/google/devtools/build/lib/rules/android
parent95abc4d33a5bc185346fdea43bc9a0fd13ecd3e2 (diff)
Description redacted.
-- MOS_MIGRATED_REVID=99828091
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/android')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java24
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibraryAarProvider.java58
2 files changed, 11 insertions, 71 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java
index 66ed6796e7..010fa4830d 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java
@@ -30,7 +30,6 @@ import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.packages.Type;
import com.google.devtools.build.lib.rules.RuleConfiguredTargetFactory;
-import com.google.devtools.build.lib.rules.android.AndroidLibraryAarProvider.Aar;
import com.google.devtools.build.lib.rules.android.AndroidResourcesProvider.ResourceContainer;
import com.google.devtools.build.lib.rules.android.AndroidResourcesProvider.ResourceType;
import com.google.devtools.build.lib.rules.cpp.LinkerInput;
@@ -68,7 +67,6 @@ public abstract class AndroidLibrary implements RuleConfiguredTargetFactory {
checkIdlRootImport(ruleContext);
NestedSet<AndroidResourcesProvider.ResourceContainer> transitiveResources =
collectTransitiveResources(ruleContext);
- NestedSetBuilder<Aar> transitiveAars = collectTransitiveAars(ruleContext);
NestedSet<LinkerInput> transitiveNativeLibraries =
AndroidCommon.collectTransitiveNativeLibraries(deps);
NestedSet<Artifact> transitiveProguardConfigs =
@@ -124,8 +122,6 @@ public abstract class AndroidLibrary implements RuleConfiguredTargetFactory {
.setAAROut(aarOut)
.build(ruleContext);
- Aar aar = new Aar(aarOut, applicationManifest.getManifest());
-
RuleConfiguredTargetBuilder builder = new RuleConfiguredTargetBuilder(ruleContext);
androidCommon.addTransitiveInfoProviders(builder);
androidSemantics.addTransitiveInfoProviders(
@@ -143,8 +139,8 @@ public abstract class AndroidLibrary implements RuleConfiguredTargetFactory {
.add(AndroidCcLinkParamsProvider.class,
new AndroidCcLinkParamsProvider(androidCommon.getCcLinkParamsStore()))
.add(ProguardSpecProvider.class, new ProguardSpecProvider(transitiveProguardConfigs))
- .add(AndroidLibraryAarProvider.class, new AndroidLibraryAarProvider(aar,
- transitiveAars.add(aar).build()))
+ .add(AndroidLibraryAarProvider.class, new AndroidLibraryAarProvider(aarOut,
+ applicationManifest.getManifest()))
.addOutputGroup(OutputGroupProvider.HIDDEN_TOP_LEVEL, transitiveProguardConfigs)
.build();
} catch (RuleConfigurationException e) {
@@ -197,10 +193,8 @@ public abstract class AndroidLibrary implements RuleConfiguredTargetFactory {
if (AndroidCommon.getAndroidResources(ruleContext) != null) {
primaryResources = Iterables.getOnlyElement(
AndroidCommon.getAndroidResources(ruleContext).getTransitiveAndroidResources());
-
- Aar aar = new Aar(aarOut, primaryResources.getManifest());
targetBuilder.add(AndroidLibraryAarProvider.class, new AndroidLibraryAarProvider(
- aar, transitiveAars.add(aar).build()));
+ aarOut, primaryResources.getManifest()));
} else {
// there are no local resources and resources attribute was not specified either
ApplicationManifest applicationManifest =
@@ -241,9 +235,6 @@ public abstract class AndroidLibrary implements RuleConfiguredTargetFactory {
ruleContext.getConfiguration().getCompilationMode() != CompilationMode.OPT)
.setWorkingDirectory(ruleContext.getUniqueDirectory("_resources"))
.build(ruleContext);
-
- targetBuilder.add(AndroidLibraryAarProvider.class, new AndroidLibraryAarProvider(
- null, transitiveAars.build()));
}
new AarGeneratorBuilder(ruleContext)
@@ -348,15 +339,6 @@ public abstract class AndroidLibrary implements RuleConfiguredTargetFactory {
return builder.build();
}
- private NestedSetBuilder<Aar> collectTransitiveAars(RuleContext ruleContext) {
- NestedSetBuilder<Aar> builder = NestedSetBuilder.naiveLinkOrder();
- for (AndroidLibraryAarProvider library :
- ruleContext.getPrerequisites("deps", Mode.TARGET, AndroidLibraryAarProvider.class)) {
- builder.addTransitive(library.getTransitiveAars());
- }
- return builder;
- }
-
private boolean hasExplicitlySpecifiedIdlImportRoot(RuleContext ruleContext) {
return ruleContext.getRule().isAttributeValueExplicitlySpecified("idl_import_root");
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibraryAarProvider.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibraryAarProvider.java
index f4f16bd96f..59402defd8 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibraryAarProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibraryAarProvider.java
@@ -16,11 +16,8 @@ package com.google.devtools.build.lib.rules.android;
import com.google.common.base.Preconditions;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.TransitiveInfoProvider;
-import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
-import java.util.Objects;
-
/**
* A target that can provide the aar artifact of Android libraries and all the manifests that are
* merged into the main aar manifest.
@@ -28,58 +25,19 @@ import java.util.Objects;
@Immutable
public final class AndroidLibraryAarProvider implements TransitiveInfoProvider {
- private final Aar aar;
- private final NestedSet<Aar> transitiveAars;
+ private final Artifact aar;
+ private final Artifact manifest;
- public AndroidLibraryAarProvider(Aar aar, NestedSet<Aar> transitiveAars) {
- this.aar = aar;
- this.transitiveAars = transitiveAars;
+ public AndroidLibraryAarProvider(Artifact aar, Artifact manifest) {
+ this.aar = Preconditions.checkNotNull(aar);
+ this.manifest = Preconditions.checkNotNull(manifest);
}
- public Aar getAar() {
+ public Artifact getAar() {
return aar;
}
- public NestedSet<Aar> getTransitiveAars() {
- return transitiveAars;
- }
-
- /**
- * The .aar file and associated AndroidManifest.xml contributed by a single target.
- */
- @Immutable
- public static final class Aar {
- private final Artifact aar;
- private final Artifact manifest;
-
- public Aar(Artifact aar, Artifact manifest) {
- this.aar = Preconditions.checkNotNull(aar);
- this.manifest = Preconditions.checkNotNull(manifest);
- }
-
- public Artifact getAar() {
- return aar;
- }
-
- public Artifact getManifest() {
- return manifest;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(aar, manifest);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof Aar)) {
- return false;
- }
- Aar other = (Aar) obj;
- return aar.equals(other.aar) && manifest.equals(other.manifest);
- }
+ public Artifact getManifest() {
+ return manifest;
}
}