aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/StrictJavaDepsPlugin.java9
-rw-r--r--src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/javac/AbstractJavacTurbineCompilationTest.java8
-rw-r--r--src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/javac/BUILD1
-rw-r--r--src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/javac/JavacTurbineTest.java2
4 files changed, 15 insertions, 5 deletions
diff --git a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/StrictJavaDepsPlugin.java b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/StrictJavaDepsPlugin.java
index 60ec10c581..d16ed69fac 100644
--- a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/StrictJavaDepsPlugin.java
+++ b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/StrictJavaDepsPlugin.java
@@ -22,6 +22,7 @@ import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.buildjar.JarOwner;
import com.google.devtools.build.buildjar.javac.plugins.BlazeJavaCompilerPlugin;
+import com.google.devtools.build.buildjar.javac.plugins.dependency.DependencyModule.StrictJavaDeps;
import com.google.devtools.build.lib.view.proto.Deps;
import com.google.devtools.build.lib.view.proto.Deps.Dependency;
import com.sun.tools.javac.code.Flags;
@@ -200,9 +201,11 @@ public final class StrictJavaDepsPlugin extends BlazeJavaCompilerPlugin {
// suggest private build labels.
.map(owner -> owner.withLabel(owner.label().map(label -> canonicalizeTarget(label))))
.collect(toImmutableSet());
- errWriter.print(
- dependencyModule.getFixMessage().get(canonicalizedMissing, canonicalizedLabel));
- dependencyModule.setHasMissingTargets();
+ if (dependencyModule.getStrictJavaDeps() != StrictJavaDeps.OFF) {
+ errWriter.print(
+ dependencyModule.getFixMessage().get(canonicalizedMissing, canonicalizedLabel));
+ dependencyModule.setHasMissingTargets();
+ }
}
}
diff --git a/src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/javac/AbstractJavacTurbineCompilationTest.java b/src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/javac/AbstractJavacTurbineCompilationTest.java
index 36ec4e2668..2f956d4ba1 100644
--- a/src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/javac/AbstractJavacTurbineCompilationTest.java
+++ b/src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/javac/AbstractJavacTurbineCompilationTest.java
@@ -19,6 +19,7 @@ import static com.google.common.truth.Truth.assertThat;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.io.ByteStreams;
+import com.google.devtools.build.buildjar.jarhelper.JarCreator;
import com.google.devtools.build.java.bazel.JavacBootclasspath;
import com.google.devtools.build.java.turbine.javac.JavacTurbine.Result;
import com.google.turbine.options.TurbineOptions;
@@ -37,9 +38,11 @@ import java.util.Enumeration;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.jar.Attributes;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TemporaryFolder;
@@ -119,8 +122,11 @@ public abstract class AbstractJavacTurbineCompilationTest {
protected Path createClassJar(String jarName, Class<?>... classes) throws IOException {
Path jarPath = temp.newFile(jarName).toPath();
+ Manifest manifest = new Manifest();
+ manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
+ manifest.getMainAttributes().put(JarCreator.TARGET_LABEL, "//" + jarName);
try (OutputStream os = Files.newOutputStream(jarPath);
- JarOutputStream jos = new JarOutputStream(os)) {
+ JarOutputStream jos = new JarOutputStream(os, manifest)) {
for (Class<?> clazz : classes) {
String classFileName = clazz.getName().replace('.', '/') + ".class";
jos.putNextEntry(new JarEntry(classFileName));
diff --git a/src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/javac/BUILD b/src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/javac/BUILD
index 701f380d64..039902dbda 100644
--- a/src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/javac/BUILD
+++ b/src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/javac/BUILD
@@ -5,6 +5,7 @@ java_library(
testonly = 1,
srcs = ["AbstractJavacTurbineCompilationTest.java"],
deps = [
+ "//src/java_tools/buildjar/java/com/google/devtools/build/buildjar/jarhelper",
"//src/java_tools/buildjar/java/com/google/devtools/build/java/bazel:JavacBootclasspath",
"//src/java_tools/buildjar/java/com/google/devtools/build/java/turbine/javac:javac_turbine",
"//src/main/protobuf:deps_java_proto",
diff --git a/src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/javac/JavacTurbineTest.java b/src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/javac/JavacTurbineTest.java
index c598edf538..7d44dd7462 100644
--- a/src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/javac/JavacTurbineTest.java
+++ b/src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/javac/JavacTurbineTest.java
@@ -1235,6 +1235,7 @@ public class JavacTurbineTest extends AbstractJavacTurbineCompilationTest {
result = turbine.compile();
}
assertThat(errOutput.toString()).doesNotContain("[strict]");
+ assertThat(errOutput.toString()).doesNotContain("** Please add the following dependencies:");
assertThat(result).isEqualTo(Result.ERROR);
}
@@ -1511,4 +1512,3 @@ public class JavacTurbineTest extends AbstractJavacTurbineCompilationTest {
assertThat(output.toString()).contains("A.java:2: error: class, interface, or enum expected");
}
}
-