diff options
author | Googler <noreply@google.com> | 2018-07-30 07:48:47 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-07-30 07:51:07 -0700 |
commit | 008e5f8d80dcf2c1eb8c152684d222c95a402d19 (patch) | |
tree | d1725515b16318686bdaf1e667d4e06a7c28ec2d /src/test/java | |
parent | 3082654a566514b4f0535410cba6a51580471df8 (diff) |
Add manifestProtoOutput produced during Java compilation to the OutputJar so that it can be accessed in Skylark. One example where this is used is in Android IDL processing where the manifestProtoOutput is used to split out the Android IDL generated Java classes from the overarching outputJar produced by the android_library rule.
RELNOTES: none
PiperOrigin-RevId: 206580880
Diffstat (limited to 'src/test/java')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/rules/java/JavaSkylarkApiTest.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/rules/java/JavaSkylarkApiTest.java b/src/test/java/com/google/devtools/build/lib/rules/java/JavaSkylarkApiTest.java index c3f8413672..b6a47e3ee4 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/java/JavaSkylarkApiTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/java/JavaSkylarkApiTest.java @@ -1928,4 +1928,44 @@ public class JavaSkylarkApiTest extends BuildViewTestCase { assertThat(prettyArtifactNames(provider.getCompileTimeJavaDependencyArtifacts())) .containsExactly("java/test/amazing-hjar.jdeps", "java/test/libdep-hjar.jdeps"); } + + @Test + public void testCompileOutputJarHasManifestProto() throws Exception { + writeBuildFileForJavaToolchain(); + scratch.file( + "foo/java_custom_library.bzl", + "def _impl(ctx):", + " output_jar = ctx.actions.declare_file('lib%s.jar' % ctx.label.name)", + " compilation_provider = java_common.compile(", + " ctx,", + " source_files = ctx.files.srcs,", + " output = output_jar,", + " java_toolchain = ctx.attr._java_toolchain,", + " host_javabase = ctx.attr._host_javabase", + " )", + " return struct(", + " providers = [compilation_provider]", + " )", + "java_custom_library = rule(", + " implementation = _impl,", + " attrs = {", + " 'srcs': attr.label_list(allow_files=['.java']),", + " '_java_toolchain': attr.label(default = Label('//java/com/google/test:toolchain')),", + " '_host_javabase': attr.label(", + " default = Label('" + HOST_JAVA_RUNTIME_LABEL + "'))", + " },", + " fragments = ['java'],", + ")"); + scratch.file( + "foo/BUILD", + "load(':java_custom_library.bzl', 'java_custom_library')", + "java_custom_library(name = 'b', srcs = ['java/B.java'])"); + + ConfiguredTarget configuredTarget = getConfiguredTarget("//foo:b"); + JavaInfo info = configuredTarget.get(JavaInfo.PROVIDER); + JavaRuleOutputJarsProvider outputs = info.getOutputJars(); + assertThat(outputs.getOutputJars()).hasSize(1); + OutputJar output = outputs.getOutputJars().get(0); + assertThat(output.getManifestProto().getFilename()).isEqualTo("libb.jar_manifest_proto"); + } } |