Skip to content

Commit

Permalink
Make Android data binding rules explicitly depend on the runtime libr…
Browse files Browse the repository at this point in the history
…ary.

Before this change Bazel was adding this implicitly. But that wasn't
working properly with --incremental_dexing. And that implementation is a
lot messier and bug-prone vs. just including it as a standard dependency.

Issue: #2694
PiperOrigin-RevId: 152956638
  • Loading branch information
gregestren authored and buchgr committed Apr 13, 2017
1 parent 2d5d17b commit 2765912
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -918,19 +918,13 @@ static JavaCommon createJavaCommonWithAndroidDataBinding(RuleContext ruleContext

if (isLibrary) {
compileDeps = JavaCommon.defaultDeps(ruleContext, semantics, ClasspathType.COMPILE_ONLY);
if (useDataBinding) {
compileDeps = DataBinding.addSupportLibs(ruleContext, compileDeps);
}
compileDeps = AndroidIdlHelper.maybeAddSupportLibs(ruleContext, compileDeps);
runtimeDeps = JavaCommon.defaultDeps(ruleContext, semantics, ClasspathType.RUNTIME_ONLY);
bothDeps = JavaCommon.defaultDeps(ruleContext, semantics, ClasspathType.BOTH);
} else {
// Binary:
List<? extends TransitiveInfoCollection> ruleDeps =
ruleContext.getPrerequisites("deps", RuleConfiguredTarget.Mode.TARGET);
compileDeps = useDataBinding
? DataBinding.addSupportLibs(ruleContext, ruleDeps)
: ImmutableList.<TransitiveInfoCollection>copyOf(ruleDeps);
compileDeps = ImmutableList.copyOf(
ruleContext.getPrerequisites("deps", RuleConfiguredTarget.Mode.TARGET));
runtimeDeps = compileDeps;
bothDeps = compileDeps;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.google.devtools.build.lib.analysis.RuleConfiguredTarget;
import com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
import com.google.devtools.build.lib.analysis.actions.FileWriteAction;
import com.google.devtools.build.lib.analysis.actions.SymlinkAction;
import com.google.devtools.build.lib.cmdline.Label;
Expand Down Expand Up @@ -61,11 +60,6 @@
*
*/
public final class DataBinding {
/**
* The rule attribute supplying the data binding runtime/compile-time support libraries.
*/
private static final String DATABINDING_RUNTIME_ATTR = "$databinding_runtime";

/**
* The rule attribute supplying the data binding annotation processor.
*/
Expand Down Expand Up @@ -161,21 +155,6 @@ static Artifact getLayoutInfoFile(RuleContext ruleContext) {
ruleContext.getBinOrGenfilesDirectory());
}

/**
* Adds the support libraries needed to compile/run Java code with data binding.
*
* <p>This excludes the annotation processor, which is injected separately as a Java plugin
* (see {@link #addAnnotationProcessor}).
*/
static ImmutableList<TransitiveInfoCollection> addSupportLibs(RuleContext ruleContext,
List<? extends TransitiveInfoCollection> deps) {
RuleConfiguredTarget.Mode mode = RuleConfiguredTarget.Mode.TARGET;
return ImmutableList.<TransitiveInfoCollection>builder()
.addAll(deps)
.addAll(ruleContext.getPrerequisites(DATABINDING_RUNTIME_ATTR, mode))
.build();
}

/**
* Adds data binding's annotation processor as a plugin to the given Java compilation context.
*
Expand Down

0 comments on commit 2765912

Please sign in to comment.