aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/java/JavaHelper.java
diff options
context:
space:
mode:
authorGravatar lberki <lberki@google.com>2017-07-07 03:53:36 -0400
committerGravatar John Cater <jcater@google.com>2017-07-07 07:08:50 -0400
commitb7584447cbc7fbea3afb9ae42baf78f262be1041 (patch)
treee68084619db8e0a77fa4e8a2f47ded50b16a002b /src/main/java/com/google/devtools/build/lib/rules/java/JavaHelper.java
parent692f763fe7bfb36610a711a4ca05194db721a34b (diff)
Plumb some information about the location of the JVM through JavaRuntimeProvider instead of Jvm if a java_runtime rule is used.
There are a few things standing in the way of removing package loading from JvmConfigurationLoader: - The JAVABASE/JAVA Make variables, which are a function of the contents of the package with the JVM. The plan is to make JavaRuntime a MakeVariableProvider and add an attribute to rules that do Make variable evaluation to tell which Make variables they need - The path to the Java binary is exported to Skylark through the configuration fragment. We'll need to export an attribute to Skylark that can be used to depend on the JVM, then do the three-step dance to use that instead of the configuration and figure out what to do if --javabase is not a label. - Jvm#getJavaExecutable() has a bunch of call sites. They need to be adjusted individually. RELNOTES: None. PiperOrigin-RevId: 161176462
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/java/JavaHelper.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/java/JavaHelper.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaHelper.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaHelper.java
index 5984de833e..c6e16e1911 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaHelper.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaHelper.java
@@ -149,6 +149,19 @@ public abstract class JavaHelper {
ruleContext, ":host_jdk" + implicitAttributesSuffix, Mode.HOST);
}
+ public static JavaRuntimeProvider getJavaRuntime(RuleContext ruleContext) {
+ if (!ruleContext.attributes().has(":jvm", BuildType.LABEL)) {
+ return null;
+ }
+
+ TransitiveInfoCollection jvm = ruleContext.getPrerequisite(":jvm", Mode.TARGET);
+ if (jvm == null) {
+ return null;
+ }
+
+ return jvm.getProvider(JavaRuntimeProvider.class);
+ }
+
/**
* Returns true if the given Label is of the pseudo-cc_binary that tells Bazel a Java target's
* JAVABIN is never to be replaced by the contents of --java_launcher; only the JDK's launcher