diff options
author | kmb <kmb@google.com> | 2018-05-25 11:50:30 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-05-25 11:51:39 -0700 |
commit | 0e6396c01754fb1f03c673a98083d4495ce4bd8d (patch) | |
tree | 367b40656bc9d40146cdaa342d0cb7baba1a4e95 /src/main/java/com | |
parent | c2cf1132a75d03cc37888fe8c2b9583c7ce198c5 (diff) |
support jdeps input in JavaInfo constructor
PiperOrigin-RevId: 198081030
Diffstat (limited to 'src/main/java/com')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/java/JavaInfo.java | 16 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/java/JavaInfoBuildHelper.java | 15 |
2 files changed, 29 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaInfo.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaInfo.java index ee42606122..04ad9d27c7 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaInfo.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaInfo.java @@ -611,6 +611,17 @@ public final class JavaInfo extends NativeInfo { + "<code>source_jar</code> are used. " + "<p>The host_javabase to be used for packing source files to Jar.</p>" ), + @Param( + name = "jdeps", + type = FileApi.class, + named = true, + defaultValue = "None", + noneable = true, + doc = "jdeps information for the rule output (if available). This should be a " + + "binary proto encoded using the deps.proto protobuf included with Bazel. " + + "If available this file is typically produced by a compiler. IDEs and other " + + "tools can use this information for more efficient processing." + ), }, selfCall = true, useLocation = true, @@ -635,6 +646,7 @@ public final class JavaInfo extends NativeInfo { Object useIjarApi, Object javaToolchainApi, Object hostJavabaseApi, + Object jdepsApi, Location loc, Environment env) throws EvalException { Artifact outputJar = (Artifact) outputJarApi; @@ -651,6 +663,7 @@ public final class JavaInfo extends NativeInfo { @Nullable Boolean useIjar = nullIfNone(useIjarApi, Boolean.class); @Nullable Object javaToolchain = nullIfNone(javaToolchainApi); @Nullable Object hostJavabase = nullIfNone(hostJavabaseApi); + @Nullable Artifact jdeps = nullIfNone(jdepsApi, Artifact.class); boolean hasLegacyArg = actions != null @@ -690,6 +703,7 @@ public final class JavaInfo extends NativeInfo { actions, javaToolchain, hostJavabase, + jdeps, loc); } if (compileJar == null) { @@ -700,7 +714,7 @@ public final class JavaInfo extends NativeInfo { outputJar, compileJar, sourceJar, neverlink, (SkylarkList<JavaInfo>) deps, (SkylarkList<JavaInfo>) runtimeDeps, - (SkylarkList<JavaInfo>) exports, loc); + (SkylarkList<JavaInfo>) exports, jdeps, loc); } } diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaInfoBuildHelper.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaInfoBuildHelper.java index a564df494c..e5c2cde4a3 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaInfoBuildHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaInfoBuildHelper.java @@ -75,6 +75,7 @@ final class JavaInfoBuildHelper { * target="_top">java_library.exports</a> * @param actions used to create the ijar and single jar actions * @param javaToolchain the toolchain to be used for retrieving the ijar tool + * @param jdeps optional jdeps information for outputJar * @return new created JavaInfo instance * @throws EvalException if some mandatory parameter are missing */ @@ -91,6 +92,7 @@ final class JavaInfoBuildHelper { Object actions, Object javaToolchain, Object hostJavabase, + @Nullable Artifact jdeps, Location location) throws EvalException { final Artifact sourceJar; @@ -137,7 +139,15 @@ final class JavaInfoBuildHelper { } return createJavaInfo( - outputJar, iJar, sourceJar, neverlink, compileTimeDeps, runtimeDeps, exports, location); + outputJar, + iJar, + sourceJar, + neverlink, + compileTimeDeps, + runtimeDeps, + exports, + jdeps, + location); } /** @@ -154,6 +164,7 @@ final class JavaInfoBuildHelper { * @param exports libraries to make available for users of this library. <a * href="https://docs.bazel.build/versions/master/be/java.html#java_library" * target="_top">java_library.exports</a> + * @param jdeps optional jdeps information for outputJar * @return new created JavaInfo instance */ JavaInfo createJavaInfo( @@ -164,6 +175,7 @@ final class JavaInfoBuildHelper { SkylarkList<JavaInfo> compileTimeDeps, SkylarkList<JavaInfo> runtimeDeps, SkylarkList<JavaInfo> exports, + @Nullable Artifact jdeps, Location location) { compileJar = compileJar != null ? compileJar : outputJar; ImmutableList<Artifact> sourceJars = @@ -183,6 +195,7 @@ final class JavaInfoBuildHelper { JavaRuleOutputJarsProvider javaRuleOutputJarsProvider = JavaRuleOutputJarsProvider.builder() .addOutputJar(outputJar, compileJar, sourceJars) + .setJdeps(jdeps) .build(); javaInfoBuilder.addProvider(JavaRuleOutputJarsProvider.class, javaRuleOutputJarsProvider); |