use of com.google.devtools.build.lib.rules.java.JavaCompileAction in project bazel by bazelbuild.
the class SkylarkJavaLiteProtoLibraryTest method testJavacOpts.
/** Protobufs should always be compiled with the default and proto javacopts. */
@Test
public void testJavacOpts() throws Exception {
ConfiguredTarget rule = scratchConfiguredTarget("x", "lite_pb2", "load('//tools/build_rules/java_lite_proto_library:java_lite_proto_library.bzl',", " 'java_lite_proto_library')", "java_lite_proto_library(name = 'lite_pb2', deps = [':proto_lib'])", "proto_library(name = 'proto_lib',", " srcs = ['input1.proto', 'input2.proto'])");
JavaCompilationArgs compilationArgs = getProvider(JavaCompilationArgsProvider.class, rule).getJavaCompilationArgs();
assertThat(compilationArgs.getInstrumentationMetadata()).isEmpty();
JavaSourceJarsProvider sourceJarsProvider = getProvider(JavaSourceJarsProvider.class, rule);
assertThat(sourceJarsProvider).isNotNull();
assertThat(prettyJarNames(sourceJarsProvider.getSourceJars())).containsExactly("x/proto_lib-lite-src.jar");
ImmutableListMultimap<String, Artifact> runtimeJars = Multimaps.index(compilationArgs.getRuntimeJars(), ROOT_RELATIVE_PATH_STRING);
Artifact jar = Iterables.getOnlyElement(runtimeJars.get("x/libproto_lib-lite.jar"));
JavaCompileAction action = (JavaCompileAction) getGeneratingAction(jar);
List<String> commandLine = ImmutableList.copyOf(action.buildCommandLine());
assertThat(commandLine).contains("-protoMarkerForTest");
}
use of com.google.devtools.build.lib.rules.java.JavaCompileAction in project bazel by bazelbuild.
the class SkylarkJavaLiteProtoLibraryTest method testCommandLineContainsTargetLabelAndRuleKind.
@Test
public void testCommandLineContainsTargetLabelAndRuleKind() throws Exception {
scratch.file("java/lib/BUILD", "load('//tools/build_rules/java_lite_proto_library:java_lite_proto_library.bzl',", " 'java_lite_proto_library')", "java_lite_proto_library(name = 'lite_pb2', deps = [':proto'])", "proto_library(name = 'proto', srcs = ['dummy.proto'])");
JavaCompileAction javacAction = (JavaCompileAction) getGeneratingAction(getConfiguredTarget("//java/lib:lite_pb2"), "java/lib/libproto-lite.jar");
List<String> commandLine = ImmutableList.copyOf(javacAction.buildCommandLine());
MoreAsserts.assertContainsSublist(commandLine, "--rule_kind", "proto_library");
MoreAsserts.assertContainsSublist(commandLine, "--target_label", "//java/lib:proto");
}
Aggregations