diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/JarDecompressor.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/JarDecompressor.java index cfd7aefed88f74..b8c54a673e544a 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/JarDecompressor.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/JarDecompressor.java @@ -93,6 +93,12 @@ protected String createBuildFile(String baseName) { " name = 'jar',", " jars = ['" + baseName + "'],", " visibility = ['//visibility:public']", + ")", + "", + "filegroup(", + " name = 'file',", + " srcs = ['" + baseName + "'],", + " visibility = ['//visibility:public']", ")"); } } diff --git a/src/test/java/com/google/devtools/build/lib/rules/repository/JarDecompressorTest.java b/src/test/java/com/google/devtools/build/lib/rules/repository/JarDecompressorTest.java index 852640287b9e81..76ee90d5595dc9 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/repository/JarDecompressorTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/repository/JarDecompressorTest.java @@ -49,6 +49,16 @@ public void setUpFs() throws Exception { .setArchivePath(jar); } + @Test + public void testTargets() throws Exception { + Path outputDir = DecompressorValue.decompress(descriptorBuilder.build()); + assertThat(outputDir.exists()).isTrue(); + String buildContent = + new String(FileSystemUtils.readContentAsLatin1(outputDir.getRelative("jar/BUILD"))); + assertThat(buildContent).contains("java_import"); + assertThat(buildContent).contains("filegroup"); + } + @Test public void testWorkspaceGen() throws Exception { Path outputDir = DecompressorValue.decompress(descriptorBuilder.build());