aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main
diff options
context:
space:
mode:
authorGravatar Auke Schrijnen <auke@schrijnen.nl>2018-01-02 04:27:11 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-01-02 04:28:38 -0800
commit63a8e1a9c2eb887c45e4ec37c7a858b004acd979 (patch)
treeaeae05dce570f57755e53f0e1037342abcd31c28 /src/main
parent61dffca579074213e7489798601a9923973abd26 (diff)
Don't output duplicate srcs when jar and sourcejar are the same
When a source jar is used as maven_jar the filegroup in the generated BUILD.bazel contains duplicate entries. This results in an error when the jar is used as a dependency (... is duplicated in the 'srcs' attribute of rule 'file'). This change simply doesn't write the duplicate entry to the BUILD.bazel file when the filenames are equal. Closes #4333. PiperOrigin-RevId: 180534960
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/repository/JarDecompressor.java3
1 files changed, 2 insertions, 1 deletions
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 26286adef0..8772c7a86f 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
@@ -134,6 +134,7 @@ public class JarDecompressor implements Decompressor {
protected String createBuildFileWithSrcjar(String baseName, String srcjarBaseName) {
return Joiner.on("\n")
+ .skipNulls()
.join(
"java_import(",
" name = 'jar',",
@@ -146,7 +147,7 @@ public class JarDecompressor implements Decompressor {
" name = 'file',",
" srcs = [",
" '" + baseName + "',",
- " '" + srcjarBaseName + "',",
+ baseName.equals(srcjarBaseName) ? null : " '" + srcjarBaseName + "',",
" ],",
" visibility = ['//visibility:public']",
")");