Skip to content

Commit

Permalink
Enable --incompatible_use_toolchain_providers_in_java_common
Browse files Browse the repository at this point in the history
Roll forward of 993c484.
See also f8be0ca.

Fixes #7186

RELNOTES: incompatible_use_toolchain_providers_in_java_common: pass JavaToolchainInfo and JavaRuntimeInfo providers to java_common APIs instead of configured targets (#7186.)
PiperOrigin-RevId: 241367923
  • Loading branch information
cushon authored and copybara-github committed Apr 1, 2019
1 parent bfd13b9 commit f1ae3dc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ public class StarlarkSemanticsOptions extends OptionsBase implements Serializabl

@Option(
name = "incompatible_use_toolchain_providers_in_java_common",
defaultValue = "false",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS},
metadataTags = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public static Builder builderWithDefaults() {
.experimentalPlatformsApi(false)
.experimentalRestrictNamedParams(false)
.experimentalStarlarkConfigTransitions(false)
.incompatibleUseToolchainProvidersInJavaCommon(false)
.incompatibleUseToolchainProvidersInJavaCommon(true)
.incompatibleBzlDisallowLoadAfterStatement(true)
.incompatibleDepsetIsNotIterable(false)
.incompatibleDepsetUnion(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public void testInvalidHostJavabase() throws Exception {

reporter.removeHandler(failFastHandler);
getConfiguredTarget("//a:r");
assertContainsEvent("must point to a Java runtime");
assertContainsEvent("pass a java_common.JavaRuntimeInfo instead of a configured target");
}

@Test
Expand Down Expand Up @@ -2245,7 +2245,6 @@ public void testDisallowLegacyJavaProvider() throws Exception {
@Test
public void testConfiguredTargetHostJavabase() throws Exception {
writeBuildFileForJavaToolchain();
setSkylarkSemanticsOptions("--incompatible_use_toolchain_providers_in_java_common=true");

scratch.file(
"a/BUILD",
Expand Down Expand Up @@ -2279,13 +2278,12 @@ public void testConfiguredTargetHostJavabase() throws Exception {

reporter.removeHandler(failFastHandler);
getConfiguredTarget("//a:r");
assertContainsEvent("java_common.JavaRuntimeInfo");
assertContainsEvent("pass a java_common.JavaRuntimeInfo instead of a configured target");
}

@Test
public void testConfiguredTargetToolchain() throws Exception {
writeBuildFileForJavaToolchain();
setSkylarkSemanticsOptions("--incompatible_use_toolchain_providers_in_java_common=true");

scratch.file(
"a/BUILD",
Expand Down Expand Up @@ -2319,7 +2317,7 @@ public void testConfiguredTargetToolchain() throws Exception {

reporter.removeHandler(failFastHandler);
getConfiguredTarget("//a:r");
assertContainsEvent("java_common.JavaToolchainInfo");
assertContainsEvent("pass a java_common.JavaToolchainInfo instead of a configured target");
}

@Test
Expand Down
28 changes: 14 additions & 14 deletions src/test/shell/bazel/bazel_java_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ def _impl(ctx):
exports = exports,
resources = ctx.files.resources,
strict_deps = "ERROR",
java_toolchain = ctx.attr._java_toolchain,
host_javabase = ctx.attr._host_javabase
java_toolchain = ctx.attr._java_toolchain[java_common.JavaToolchainInfo],
host_javabase = ctx.attr._host_javabase[java_common.JavaRuntimeInfo],
)
return struct(
files = depset([output_jar]),
Expand Down Expand Up @@ -371,8 +371,8 @@ def _impl(ctx):
deps = [],
sourcepath = ctx.files.sourcepath,
strict_deps = "ERROR",
java_toolchain = ctx.attr._java_toolchain,
host_javabase = ctx.attr._host_javabase
java_toolchain = ctx.attr._java_toolchain[java_common.JavaToolchainInfo],
host_javabase = ctx.attr._host_javabase[java_common.JavaRuntimeInfo],
)
return struct(
files = depset([output_jar]),
Expand Down Expand Up @@ -448,8 +448,8 @@ def _impl(ctx):
deps = [],
sourcepath = ctx.files.sourcepath,
strict_deps = "ERROR",
java_toolchain = ctx.attr._java_toolchain,
host_javabase = ctx.attr._host_javabase
java_toolchain = ctx.attr._java_toolchain[java_common.JavaToolchainInfo],
host_javabase = ctx.attr._host_javabase[java_common.JavaRuntimeInfo],
)
return struct(
files = depset([output_jar]),
Expand Down Expand Up @@ -1359,8 +1359,8 @@ def _impl(ctx):
ctx,
source_files = ctx.files.srcs,
output = compiled_jar,
java_toolchain = ctx.attr._java_toolchain,
host_javabase = ctx.attr._host_javabase
java_toolchain = ctx.attr._java_toolchain[java_common.JavaToolchainInfo],
host_javabase = ctx.attr._host_javabase[java_common.JavaRuntimeInfo],
)
imported_provider = JavaInfo(output_jar = imported_jar, use_ijar=False);
Expand Down Expand Up @@ -1411,7 +1411,7 @@ def _impl(ctx):
provider = java_common.create_provider(
ctx.actions,
compile_time_jars = ctx.files.compile_time_jars,
java_toolchain = ctx.attr._java_toolchain
java_toolchain = ctx.attr._java_toolchain[java_common.JavaToolchainInfo]
)
print(provider.compile_jars)
print(provider.full_compile_jars)
Expand Down Expand Up @@ -1486,7 +1486,7 @@ EOF
def _impl(ctx):
provider = java_common.create_provider(
compile_time_jars = ctx.files.compile_time_jars,
java_toolchain = ctx.attr._java_toolchain
java_toolchain = ctx.attr._java_toolchain[java_common.JavaToolchainInfo]
)
return DefaultInfo(files = provider.compile_jars)
Expand Down Expand Up @@ -1523,7 +1523,7 @@ def _impl(ctx):
output_jar = ctx.file.output_jar,
source_jars = ctx.files.source_jars,
use_ijar = True,
java_toolchain = ctx.attr._java_toolchain
java_toolchain = ctx.attr._java_toolchain[java_common.JavaToolchainInfo]
)
return [result(property = javaInfo)]
Expand Down Expand Up @@ -1744,14 +1744,14 @@ def _impl(ctx):
ctx.actions,
jar = ctx.file.output_jar,
target_label = ctx.label,
java_toolchain = ctx.attr._java_toolchain,
java_toolchain = ctx.attr._java_toolchain[java_common.JavaToolchainInfo],
)
source_jar = java_common.pack_sources(
ctx.actions,
output_jar = ctx.file.output_jar,
source_jars = ctx.files.source_jars,
java_toolchain = ctx.attr._java_toolchain,
host_javabase = ctx.attr._host_javabase,
java_toolchain = ctx.attr._java_toolchain[java_common.JavaToolchainInfo],
host_javabase = ctx.attr._host_javabase[java_common.JavaRuntimeInfo],
)
javaInfo = JavaInfo(
output_jar = ctx.file.output_jar,
Expand Down

0 comments on commit f1ae3dc

Please sign in to comment.