diff options
author | 2017-07-20 10:32:01 +0200 | |
---|---|---|
committer | 2017-07-20 13:05:55 +0200 | |
commit | 374fd5fda539420bf6e98004cc24b3422ec760af (patch) | |
tree | 8ef7bf543446902b4eb85534b65c3f4c69ec0b83 /src/main/java/com/google/devtools | |
parent | e1d3b87302cb11a4a1bad72b22cbe4b998296314 (diff) |
Do not depend on the Java launcher if java_binary.create_executable=0 because it's not used anyway.
RELNOTES: None.
PiperOrigin-RevId: 162589013
Diffstat (limited to 'src/main/java/com/google/devtools')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java | 17 |
1 files changed, 14 insertions, 3 deletions
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 b7b127d4ea..e6f3b9b37e 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 @@ -43,6 +43,7 @@ import com.google.devtools.build.lib.rules.java.DeployArchiveBuilder.Compression import com.google.devtools.build.lib.rules.java.JavaCompilationArgs.ClasspathType; import com.google.devtools.build.lib.rules.java.JavaConfiguration.JavaOptimizationMode; import com.google.devtools.build.lib.rules.java.proto.GeneratedExtensionRegistryProvider; +import com.google.devtools.build.lib.syntax.Type; import com.google.devtools.build.lib.util.FileType; import com.google.devtools.build.lib.vfs.PathFragment; import java.util.Collection; @@ -167,9 +168,19 @@ public interface JavaSemantics { 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); + // This nullness check is purely for the sake of a test that doesn't bother to include an + // attribute map when calling this method. + if (attributes != null) { + // Don't depend on the launcher if we don't create an executable anyway + if (attributes.has("create_executable") + && !attributes.get("create_executable", Type.BOOLEAN)) { + return null; + } + + // don't read --java_launcher if this target overrides via a launcher attribute + if (attributes.isAttributeValueExplicitlySpecified("launcher")) { + return attributes.get("launcher", LABEL); + } } return configuration.getFragment(JavaConfiguration.class).getJavaLauncherLabel(); } |