From 73da6beb8e8162e73191f5af523b268c06a99d12 Mon Sep 17 00:00:00 2001 From: Erik Kuefler Date: Wed, 27 May 2015 17:17:48 -0700 Subject: [PATCH] Make source jars from java_library available to Skylark. This is necessary to implement GWT support in Bazel, which requires source jars on the classpath. With this change, I can build a GWT classpath as follows: all_deps = ctx.files.deps for this_dep in ctx.attr.deps: p = provider(this_dep, "rules.java.JavaSourceJarsProvider") if p: all_deps += p.source_jars classpath = ":".join([dep.path for dep in all_deps]) --- .../devtools/build/lib/rules/java/JavaSourceJarsProvider.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaSourceJarsProvider.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaSourceJarsProvider.java index 2bb35978ac01a7..5ab1870efc87bd 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaSourceJarsProvider.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaSourceJarsProvider.java @@ -19,11 +19,14 @@ 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 com.google.devtools.build.lib.syntax.SkylarkCallable; +import com.google.devtools.build.lib.syntax.SkylarkModule; /** * The collection of source jars from the transitive closure. */ @Immutable +@SkylarkModule(name = "JavaSourceJarsProvider", doc = "") public final class JavaSourceJarsProvider implements TransitiveInfoProvider { private final NestedSet transitiveSourceJars; @@ -46,6 +49,7 @@ public NestedSet getTransitiveSourceJars() { /** * Return the source jars that are to be built when the target is on the command line. */ + @SkylarkCallable(name = "source_jars", doc = "", structField = true) public ImmutableList getSourceJars() { return sourceJars; }