aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar Alex Humesky <ahumesky@google.com>2016-07-27 22:44:16 +0000
committerGravatar Adam Michael <ajmichael@google.com>2016-07-28 18:36:30 -0400
commit94c86135d05a1844263c59f3ce6b1c1917e0f4c8 (patch)
tree61a459484b9b9d3ac5395a09c2f160cdf135d80c /src/main/java/com/google/devtools/build
parent8643954b818547339e8055d0aa4867c1286ebca1 (diff)
*** Reason for rollback *** Causes a dependency cycle for java targets: [] *** Original change description *** Enable the Java launcher by default -- MOS_MIGRATED_REVID=128638289
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaRuleClasses.java22
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaTestRule.java1
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java15
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java17
4 files changed, 25 insertions, 30 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaRuleClasses.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaRuleClasses.java
index 3206e034f8..e3d59df802 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaRuleClasses.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaRuleClasses.java
@@ -30,11 +30,8 @@ import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.analysis.BaseRuleClasses;
import com.google.devtools.build.lib.analysis.RuleDefinition;
import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment;
-import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.bazel.rules.cpp.BazelCppRuleClasses;
-import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.packages.Attribute;
-import com.google.devtools.build.lib.packages.Attribute.LateBoundLabel;
import com.google.devtools.build.lib.packages.AttributeMap;
import com.google.devtools.build.lib.packages.ImplicitOutputsFunction;
import com.google.devtools.build.lib.packages.PredicateWithMessage;
@@ -44,7 +41,6 @@ import com.google.devtools.build.lib.packages.RuleClass.Builder;
import com.google.devtools.build.lib.packages.RuleClass.Builder.RuleClassType;
import com.google.devtools.build.lib.packages.RuleClass.PackageNameConstraint;
import com.google.devtools.build.lib.packages.TriState;
-import com.google.devtools.build.lib.rules.java.JavaConfiguration;
import com.google.devtools.build.lib.rules.java.JavaSemantics;
import com.google.devtools.build.lib.rules.java.JavaToolchainProvider;
import com.google.devtools.build.lib.syntax.Type;
@@ -61,22 +57,6 @@ public class BazelJavaRuleClasses {
protected static final String JUNIT_TESTRUNNER = "//tools/jdk:TestRunner_deploy.jar";
- /**
- * Implementation for the :java_launcher attribute. Note that the Java launcher is disabled by
- * default, so it returns null for the configuration-independent default value.
- */
- public static final LateBoundLabel<BuildConfiguration> JAVA_LAUNCHER =
- new LateBoundLabel<BuildConfiguration>(JavaConfiguration.class) {
- @Override
- public Label resolve(Rule rule, AttributeMap attributes, BuildConfiguration configuration) {
- // don't read --java_launcher if this target overrides via a launcher attribute
- if (attributes != null && attributes.isAttributeValueExplicitlySpecified("launcher")) {
- return attributes.get("launcher", LABEL);
- }
- return configuration.getFragment(JavaConfiguration.class).getJavaLauncherLabel();
- }
- };
-
public static final ImplicitOutputsFunction JAVA_BINARY_IMPLICIT_OUTPUTS =
fromFunctions(
JavaSemantics.JAVA_BINARY_CLASS_JAR,
@@ -407,7 +387,7 @@ public class BazelJavaRuleClasses {
attr("launcher", LABEL)
.allowedFileTypes(FileTypeSet.NO_FILE)
.allowedRuleClasses("cc_binary"))
- .add(attr(":java_launcher", LABEL).value(JAVA_LAUNCHER)) // blaze flag
+ .add(attr(":java_launcher", LABEL).value(JavaSemantics.JAVA_LAUNCHER)) // blaze flag
.add(
attr("$no_launcher", NODEP_LABEL_LIST)
.value(
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaTestRule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaTestRule.java
index 833d76d808..0de34ae90c 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaTestRule.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaTestRule.java
@@ -59,6 +59,7 @@ public final class BazelJavaTestRule implements RuleDefinition {
.add(attr(":extra_proguard_specs", LABEL_LIST).value(JavaSemantics.EXTRA_PROGUARD_SPECS))
.override(attr("stamp", TRISTATE).value(TriState.NO))
.override(attr("use_testrunner", BOOLEAN).value(true))
+ .override(attr(":java_launcher", LABEL).value(JavaSemantics.JAVA_LAUNCHER))
// TODO(dmarting): remove once we drop the legacy bazel java_test behavior.
.override(attr("main_class", STRING).value(JUNIT4_RUNNER))
/* <!-- #BLAZE_RULE(java_test).ATTRIBUTE(test_class) -->
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java
index 65049fef5f..0c787bc713 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java
@@ -282,15 +282,12 @@ public class JavaOptions extends FragmentOptions {
)
public Label hostJavaLauncher;
- @Option(
- name = "java_launcher",
- defaultValue = "null",
- converter = LabelConverter.class,
- category = "semantics",
- help =
- "The Java launcher to use when building Java binaries. "
- + "The \"launcher\" attribute overrides this flag. "
- )
+ @Option(name = "java_launcher",
+ defaultValue = "null",
+ converter = LabelConverter.class,
+ category = "semantics",
+ help = "If enabled, a specific Java launcher is used. "
+ + "The \"launcher\" attribute overrides this flag. ")
public Label javaLauncher;
@Option(name = "proguard_top",
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java
index c2b5875f49..2e1435e0a1 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java
@@ -14,6 +14,7 @@
package com.google.devtools.build.lib.rules.java;
+import static com.google.devtools.build.lib.packages.BuildType.LABEL;
import static com.google.devtools.build.lib.packages.ImplicitOutputsFunction.fromTemplates;
import com.google.common.collect.ImmutableList;
@@ -142,6 +143,22 @@ public interface JavaSemantics {
}
};
+ /**
+ * Implementation for the :java_launcher attribute. Note that the Java launcher is disabled by
+ * default, so it returns null for the configuration-independent default value.
+ */
+ LateBoundLabel<BuildConfiguration> JAVA_LAUNCHER =
+ new LateBoundLabel<BuildConfiguration>(JavaConfiguration.class) {
+ @Override
+ public Label resolve(Rule rule, AttributeMap attributes, BuildConfiguration configuration) {
+ // don't read --java_launcher if this target overrides via a launcher attribute
+ if (attributes != null && attributes.isAttributeValueExplicitlySpecified("launcher")) {
+ return attributes.get("launcher", LABEL);
+ }
+ return configuration.getFragment(JavaConfiguration.class).getJavaLauncherLabel();
+ }
+ };
+
LateBoundLabelList<BuildConfiguration> JAVA_PLUGINS =
new LateBoundLabelList<BuildConfiguration>() {
@Override