More fixes for WARN_ON_TRANSITIVE.
Summary: Suggesting importing a export_dep first was broken.
Test Plan: Unit tests.
diff --git a/src/com/facebook/buck/java/DefaultJavaLibraryRule.java b/src/com/facebook/buck/java/DefaultJavaLibraryRule.java
index ab560be..da8c2ee 100644
--- a/src/com/facebook/buck/java/DefaultJavaLibraryRule.java
+++ b/src/com/facebook/buck/java/DefaultJavaLibraryRule.java
@@ -632,8 +632,9 @@
return false;
}
- ImmutableSet<String> classPaths = getTransitiveClasspathEntries()
- .get((JavaLibraryRule)transitiveNotDeclaredDep);
+ ImmutableSet<String> classPaths =
+ ImmutableSet.copyOf(
+ ((JavaLibraryRule) transitiveNotDeclaredDep).getOutputClasspathEntries().values());
boolean containsMissingBuildRule = false;
// Open the output jar for every jar contained as the output of transitiveNotDeclaredDep. With
// the exception of rules that export their dependencies, this will result in a single
diff --git a/src/com/facebook/buck/java/JavacInMemoryStep.java b/src/com/facebook/buck/java/JavacInMemoryStep.java
index adfe71c..d41bf32 100644
--- a/src/com/facebook/buck/java/JavacInMemoryStep.java
+++ b/src/com/facebook/buck/java/JavacInMemoryStep.java
@@ -232,19 +232,21 @@
ImmutableSet.copyOf(transitiveClasspathEntries));
if (transitiveResult == 0) {
ImmutableSet<String> failedImports = findFailedImports(firstOrderStderr);
+ ImmutableList.Builder<String> errorMessage = ImmutableList.builder();
- context.getStdErr().println(String.format("Rule %s builds with its transitive " +
+ errorMessage.add(String.format("Rule %s builds with its transitive " +
"dependencies but not with its first order dependencies.", invokingRule.or("")));
- context.getStdErr().println("The following packages were missing:");
- context.getStdErr().println(Joiner.on(LINE_SEPARATOR).join(failedImports));
+ errorMessage.add("The following packages were missing:");
+ errorMessage.add(Joiner.on(LINE_SEPARATOR).join(failedImports));
if (suggestBuildRules.isPresent()) {
- context.getStdErr().println("Try adding the following deps:");
- context.getStdErr().println(Joiner.on(LINE_SEPARATOR)
+ errorMessage.add("Try adding the following deps:");
+ errorMessage.add(Joiner.on(LINE_SEPARATOR)
.join(suggestBuildRules.get().suggest(context.getProjectFilesystem(),
failedImports)));
}
- context.getStdErr().println();
- context.getStdErr().println();
+ errorMessage.add("");
+ errorMessage.add("");
+ context.getStdErr().println(Joiner.on("\n").join(errorMessage.build()));
}
return transitiveResult;
} else {
diff --git a/test/com/facebook/buck/java/DefaultJavaLibraryRuleIntegrationTest.java b/test/com/facebook/buck/java/DefaultJavaLibraryRuleIntegrationTest.java
index 3b4921e..e720892 100644
--- a/test/com/facebook/buck/java/DefaultJavaLibraryRuleIntegrationTest.java
+++ b/test/com/facebook/buck/java/DefaultJavaLibraryRuleIntegrationTest.java
@@ -171,7 +171,7 @@
"Rule //:raz builds with its transitive dependencies but not with its first order " +
"dependencies.",
"The following packages were missing:",
- "Foo",
+ "Meh",
"Try adding the following deps:",
"//:foo");
diff --git a/test/com/facebook/buck/java/testdata/warn_on_transitive/BUCK b/test/com/facebook/buck/java/testdata/warn_on_transitive/BUCK
index 83b07e9..1978a26 100644
--- a/test/com/facebook/buck/java/testdata/warn_on_transitive/BUCK
+++ b/test/com/facebook/buck/java/testdata/warn_on_transitive/BUCK
@@ -3,8 +3,15 @@
# with some hard-coded Java source code into a single library.
java_library(
+ name = 'meh',
+ srcs = ['Meh.java'],
+)
+
+java_library(
name = 'foo',
srcs = ['Foo.java'],
+ export_deps = True,
+ deps = [':meh']
)
java_library(
diff --git a/test/com/facebook/buck/java/testdata/warn_on_transitive/Foo.java b/test/com/facebook/buck/java/testdata/warn_on_transitive/Foo.java
index cbee490..6682e61 100644
--- a/test/com/facebook/buck/java/testdata/warn_on_transitive/Foo.java
+++ b/test/com/facebook/buck/java/testdata/warn_on_transitive/Foo.java
@@ -16,4 +16,6 @@
package com.example;
-public class Foo {}
+public class Foo {
+ private Meh meh;
+}
diff --git a/test/com/facebook/buck/java/testdata/warn_on_transitive/Meh.java b/test/com/facebook/buck/java/testdata/warn_on_transitive/Meh.java
new file mode 100644
index 0000000..a15f401
--- /dev/null
+++ b/test/com/facebook/buck/java/testdata/warn_on_transitive/Meh.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2013-present Facebook, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License. You may obtain
+ * a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.example;
+
+public class Meh {
+}
diff --git a/test/com/facebook/buck/java/testdata/warn_on_transitive/Raz.java b/test/com/facebook/buck/java/testdata/warn_on_transitive/Raz.java
index 23e2023..95691e2 100644
--- a/test/com/facebook/buck/java/testdata/warn_on_transitive/Raz.java
+++ b/test/com/facebook/buck/java/testdata/warn_on_transitive/Raz.java
@@ -17,6 +17,6 @@
package com.example;
public class Raz {
- private Foo foo;
private Bar bar;
+ private Meh meh;
}