aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2015-10-16 19:42:29 +0000
committerGravatar Lukacs Berki <lberki@google.com>2015-10-19 08:20:35 +0000
commit7637f9cba731e1c93ad3be637f94612a581efe5e (patch)
tree897be12a38eef868af01a599f0cccc837a56d5ca /src
parent9ba692690e5900ac275cce953092973b5b826518 (diff)
Change the way sources are gathered for ASwB aspect.
This fixes android_resources being dropped on the ground because the source jar isn't included. Previously, the java compilation args were used. This includes a bunch of implicit and generated source, like idl sources. The source jars include output from resource processing the rule itself, so it wasn't possible to start including that. What we want are all explicit sources only. This CL does that. -- MOS_MIGRATED_REVID=105624870
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspect.java27
1 files changed, 7 insertions, 20 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspect.java b/src/main/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspect.java
index 4ac74cb790..ee6e12a279 100644
--- a/src/main/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspect.java
+++ b/src/main/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspect.java
@@ -232,7 +232,7 @@ public class AndroidStudioInfoAspect implements ConfiguredAspectFactory {
|| ruleKind == Kind.ANDROID_BINARY
|| ruleKind == Kind.ANDROID_TEST
|| ruleKind == Kind.ANDROID_ROBOELECTRIC_TEST) {
- outputBuilder.setJavaRuleIdeInfo(makeJavaRuleIdeInfo(base, ideResolveArtifacts));
+ outputBuilder.setJavaRuleIdeInfo(makeJavaRuleIdeInfo(base, ruleContext, ideResolveArtifacts));
}
if (ruleKind == Kind.ANDROID_LIBRARY
|| ruleKind == Kind.ANDROID_BINARY
@@ -375,6 +375,7 @@ public class AndroidStudioInfoAspect implements ConfiguredAspectFactory {
private static JavaRuleIdeInfo makeJavaRuleIdeInfo(
ConfiguredTarget base,
+ RuleContext ruleContext,
NestedSetBuilder<Artifact> ideResolveArtifacts) {
JavaRuleIdeInfo.Builder builder = JavaRuleIdeInfo.newBuilder();
JavaRuleOutputJarsProvider outputJarsProvider =
@@ -396,7 +397,7 @@ public class AndroidStudioInfoAspect implements ConfiguredAspectFactory {
collectGenJars(builder, ideResolveArtifacts, genJarsProvider);
}
- Collection<Artifact> sourceFiles = getSources(base);
+ Collection<Artifact> sourceFiles = getSources(ruleContext);
for (Artifact sourceFile : sourceFiles) {
builder.addSources(makeArtifactLocation(sourceFile));
@@ -494,24 +495,10 @@ public class AndroidStudioInfoAspect implements ConfiguredAspectFactory {
}
}
- private static Collection<Artifact> getSources(ConfiguredTarget base) {
- // Calculate source files.
- JavaSourceInfoProvider sourceInfoProvider = base.getProvider(JavaSourceInfoProvider.class);
- if (sourceInfoProvider == null) {
- return ImmutableList.of();
- }
- AndroidIdeInfoProvider androidIdeInfoProvider = base.getProvider(AndroidIdeInfoProvider.class);
- if (androidIdeInfoProvider == null) {
- return sourceInfoProvider.getSourceFiles();
- }
- ImmutableList.Builder<Artifact> builder = ImmutableList.builder();
- Collection<Artifact> idlGeneratedJavaFiles = androidIdeInfoProvider.getIdlGeneratedJavaFiles();
- for (Artifact artifact : sourceInfoProvider.getSourceFiles()) {
- if (!idlGeneratedJavaFiles.contains(artifact)) {
- builder.add(artifact);
- }
- }
- return builder.build();
+ private static Collection<Artifact> getSources(RuleContext ruleContext) {
+ return ruleContext.attributes().has("srcs", BuildType.LABEL_LIST)
+ ? ruleContext.getPrerequisiteArtifacts("srcs", Mode.TARGET).list()
+ : ImmutableList.<Artifact>of();
}
private static PathFragment getOutputFilePath(ConfiguredTarget base, RuleContext ruleContext,