From 549db25ada184fbaa9fdc2b2afc35c67c6f02e13 Mon Sep 17 00:00:00 2001 From: ilist Date: Mon, 23 Nov 2020 01:00:18 -0800 Subject: [PATCH] Removing javac attribute from java_toolchain rule. javac can be specified using tools attribute. It is not provided by JavaToolchain provider any more. LocationBuilder in JavaToolchain class can be removed, because alias resolution in $location function was fixed with b/117612331. RELNOTES[inc]: Removing javac attribute from java_toolchain. PiperOrigin-RevId: 343801252 --- .../build/lib/rules/java/JavaToolchain.java | 26 +++---------------- .../lib/rules/java/JavaToolchainRule.java | 9 ------- 2 files changed, 4 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchain.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchain.java index 680b2e1b2e669e..d5f4720054047d 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchain.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchain.java @@ -17,14 +17,12 @@ import static com.google.common.collect.Iterables.getOnlyElement; import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableCollection; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.MutableActionGraph.ActionConflictException; -import com.google.devtools.build.lib.analysis.AliasProvider; import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.FilesToRunProvider; import com.google.devtools.build.lib.analysis.PrerequisiteArtifacts; @@ -33,9 +31,7 @@ import com.google.devtools.build.lib.analysis.RuleContext; import com.google.devtools.build.lib.analysis.Runfiles; import com.google.devtools.build.lib.analysis.RunfilesProvider; -import com.google.devtools.build.lib.analysis.TransitiveInfoCollection; import com.google.devtools.build.lib.analysis.platform.ToolchainInfo; -import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.collect.nestedset.NestedSet; import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; import com.google.devtools.build.lib.collect.nestedset.Order; @@ -61,7 +57,6 @@ public ConfiguredTarget create(RuleContext ruleContext) ruleContext.attributes().get("javac_supports_workers", Type.BOOLEAN); boolean javacSupportsMultiplexWorkers = ruleContext.attributes().get("javac_supports_multiplex_workers", Type.BOOLEAN); - Artifact javac = ruleContext.getPrerequisiteArtifact("javac"); FilesToRunProvider javabuilder = ruleContext.getExecutablePrerequisite("javabuilder"); FilesToRunProvider headerCompiler = ruleContext.getExecutablePrerequisite("header_compiler"); FilesToRunProvider headerCompilerDirect = @@ -89,29 +84,17 @@ public ConfiguredTarget create(RuleContext ruleContext) getCompatibleJavacOptions(ruleContext); NestedSet tools = PrerequisiteArtifacts.nestedSet(ruleContext, "tools"); - if (javac != null) { - tools = NestedSetBuilder.fromNestedSet(tools).add(javac).build(); - } - - TransitiveInfoCollection javacDep = ruleContext.getPrerequisite("javac"); - - ImmutableMap.Builder> locationsBuilder = - ImmutableMap.builder(); - if (javacDep != null) { - locationsBuilder.put(AliasProvider.getDependencyLabel(javacDep), ImmutableList.of(javac)); - } - ImmutableMap> locations = locationsBuilder.build(); - ImmutableList jvmOpts = getJvmOpts(ruleContext, locations, "jvm_opts"); + ImmutableList jvmOpts = getJvmOpts(ruleContext, "jvm_opts"); ImmutableList javabuilderJvmOpts = ImmutableList.builder() .addAll(jvmOpts) - .addAll(getJvmOpts(ruleContext, locations, "javabuilder_jvm_opts")) + .addAll(getJvmOpts(ruleContext, "javabuilder_jvm_opts")) .build(); ImmutableList turbineJvmOpts = ImmutableList.builder() .addAll(jvmOpts) - .addAll(getJvmOpts(ruleContext, locations, "turbine_jvm_opts")) + .addAll(getJvmOpts(ruleContext, "turbine_jvm_opts")) .build(); ImmutableList packageConfiguration = @@ -196,9 +179,8 @@ private static ImmutableListMultimap getCompatibleJavacOptions( private static ImmutableList getJvmOpts( RuleContext ruleContext, - ImmutableMap> locations, String attribute) { - return ruleContext.getExpander().withExecLocations(locations).list(attribute); + return ruleContext.getExpander().withExecLocations(ImmutableMap.of()).list(attribute); } private static BootClassPathInfo getBootClassPathInfo(RuleContext ruleContext) { diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchainRule.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchainRule.java index 6127507b21c596..4e2f3d752898c5 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchainRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchainRule.java @@ -110,15 +110,6 @@ The Java target version (e.g., '6' or '7'). It specifies for which Java runtime True if JavaBuilder supports running as a multiplex persistent worker, false if it doesn't. */ .add(attr("javac_supports_multiplex_workers", BOOLEAN).value(true)) - /* - Label of the javac jar. - */ - .add( - attr("javac", LABEL_LIST) - // This needs to be in the execution configuration. - .cfg(ExecutionTransitionFactory.create()) - .singleArtifact() - .allowedFileTypes(FileTypeSet.ANY_FILE)) /* Labels of tools available for label-expansion in jvm_opts. */