diff options
author | Carmi Grushko <carmi@google.com> | 2016-06-17 02:41:54 +0000 |
---|---|---|
committer | Yue Gan <yueg@google.com> | 2016-06-17 09:27:17 +0000 |
commit | 6097ad0e2231f69081b52c6bb6dff5c2668ab328 (patch) | |
tree | 5ed21a5ec1364d2c472d0b2ec75797716b9a1fab | |
parent | 2f5ca7706f3d9a8a7e32e8bb2f689cf763374836 (diff) |
JavaLibraryHelper can return a JavaCompilationArgsProvider which fully describes the compilation, for use as is in another Java compilation.
--
MOS_MIGRATED_REVID=125128647
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/java/JavaLibraryHelper.java | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibraryHelper.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibraryHelper.java index 4d457674cf..4112128e65 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibraryHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibraryHelper.java @@ -15,6 +15,7 @@ package com.google.devtools.build.lib.rules.java; import static com.google.devtools.build.lib.analysis.config.BuildConfiguration.StrictDepsMode.OFF; +import static com.google.devtools.build.lib.rules.java.JavaCompilationArgs.ClasspathType.BOTH; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; @@ -119,7 +120,7 @@ public final class JavaLibraryHelper { } /** - * Creates the compile actions and providers. + * Creates the compile actions. */ public JavaCompilationArgs build(JavaSemantics semantics) { Preconditions.checkState(output != null, "must have an output file; use setOutput()"); @@ -152,6 +153,22 @@ public final class JavaLibraryHelper { return JavaCompilationArgs.builder().merge(artifactsBuilder.build()).build(); } + /** + * Returns a JavaCompilationArgsProvider that fully encapsulates this compilation, based on the + * result of a call to build(). + * (that is, it contains the compile-time and runtime jars, separated by direct vs transitive + * jars). + */ + public JavaCompilationArgsProvider buildCompilationArgsProvider(JavaCompilationArgs directArgs) { + JavaCompilationArgs transitiveArgs = JavaCompilationArgs.builder() + .addTransitiveArgs(directArgs, BOTH) + .addTransitiveDependencies(deps, true /* recursive */) + .build(); + + return new JavaCompilationArgsProvider( + isStrict() ? directArgs : transitiveArgs, transitiveArgs); + } + private void addDepsToAttributes(JavaTargetAttributes.Builder attributes) { NestedSet<Artifact> directJars; if (isStrict()) { |