diff options
author | 2015-06-09 11:14:42 +0000 | |
---|---|---|
committer | 2015-06-09 11:16:29 +0000 | |
commit | c7d3bb2be55acbc65d7c28fd2ae74d51c3858430 (patch) | |
tree | bf8d017e0c49e739bb3423430e755eb1bf7d06a4 /src/main/java/com/google/devtools/build | |
parent | 7b93bbec4b356accac9f4421432993bb869b49a9 (diff) |
Make Java transitive runtime and compile time deps available to Skylark.
This is necessary to add support for Java-based languages like GWT, Groovy, and Scala. With this change, I can construct a classpath for GWT as follows:
all_deps = set(ctx.files.deps + ctx.files._implicitdeps)
for this_dep in ctx.attr.deps:
if hasattr(this_dep, 'java'):
all_deps += this_dep.java.transitive_runtime_deps
all_deps += this_dep.java.transitive_source_jars
classpath = ":".join([dep.path for dep in all_deps])
--
Change-Id: If58ffd19a4cc19f69d5f98814c11391683804234
Reviewed-on: https://bazel-review.googlesource.com/#/c/1480
MOS_MIGRATED_REVID=95523130
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/java/JavaSkylarkApiProvider.java | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaSkylarkApiProvider.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaSkylarkApiProvider.java index 4c2122314f..b13a128f2e 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaSkylarkApiProvider.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaSkylarkApiProvider.java @@ -14,9 +14,10 @@ package com.google.devtools.build.lib.rules.java; -import com.google.common.collect.ImmutableList; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.collect.nestedset.NestedSet; +import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; +import com.google.devtools.build.lib.collect.nestedset.Order; import com.google.devtools.build.lib.rules.SkylarkApiProvider; import com.google.devtools.build.lib.syntax.SkylarkCallable; import com.google.devtools.build.lib.syntax.SkylarkModule; @@ -35,9 +36,27 @@ public final class JavaSkylarkApiProvider extends SkylarkApiProvider { name = "source_jars", doc = "Returns the Jars containing Java source files for the target", structField = true) - public ImmutableList<Artifact> getSourceJars() { + public NestedSet<Artifact> getSourceJars() { JavaSourceJarsProvider sourceJars = getInfo().getProvider(JavaSourceJarsProvider.class); - return sourceJars.getSourceJars(); + return NestedSetBuilder.wrap(Order.STABLE_ORDER, sourceJars.getSourceJars()); + } + + @SkylarkCallable( + name = "transitive_deps", + doc = "Returns the transitive set of Jars required to build the target", + structField = true) + public NestedSet<Artifact> getTransitiveDeps() { + JavaCompilationArgsProvider args = getInfo().getProvider(JavaCompilationArgsProvider.class); + return args.getRecursiveJavaCompilationArgs().getCompileTimeJars(); + } + + @SkylarkCallable( + name = "transitive_runtime_deps", + doc = "Returns the transitive set of Jars required on the target's runtime classpath", + structField = true) + public NestedSet<Artifact> getTransitiveRuntimeDeps() { + JavaCompilationArgsProvider args = getInfo().getProvider(JavaCompilationArgsProvider.class); + return args.getRecursiveJavaCompilationArgs().getRuntimeJars(); } @SkylarkCallable( |