java_proto_library strict deps: add attributes for gradual migration
Control strict-deps through a rule-level and a package-level attribute, allowing finer-grained migration in conjunction with a global flag.
RELNOTES: java_proto_library: control strict-deps through a rule-level and a package-level attribute.
--
MOS_MIGRATED_REVID=128542363
diff --git a/src/main/java/com/google/devtools/build/lib/packages/Package.java b/src/main/java/com/google/devtools/build/lib/packages/Package.java
index 537866e..3a01bc3 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/Package.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/Package.java
@@ -38,7 +38,6 @@
import com.google.devtools.build.lib.vfs.Canonicalizer;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
-
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collection;
@@ -47,7 +46,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-
import javax.annotation.Nullable;
/**
@@ -141,10 +139,10 @@
*/
private String defaultHdrsCheck;
- /**
- * Default copts for cc_* rules. The rules' individual copts will append to
- * this value.
- */
+ /** See getter. */
+ private TriState defaultStrictDepsJavaProtos = TriState.AUTO;
+
+ /** Default copts for cc_* rules. The rules' individual copts will append to this value. */
private ImmutableList<String> defaultCopts;
/**
@@ -590,8 +588,15 @@
}
/**
- * Gets the default header checking mode.
+ * Default for 'strict_deps' of Java proto rules, when they aren't explicitly specified.
+ *
+ * <p>A value of AUTO is returned when the package didn't itself explicitly specify this value.
*/
+ public TriState getDefaultStrictDepsJavaProtos() {
+ return defaultStrictDepsJavaProtos;
+ }
+
+ /** Gets the default header checking mode. */
public String getDefaultHdrsCheck() {
return defaultHdrsCheck != null ? defaultHdrsCheck : "strict";
}
@@ -907,9 +912,12 @@
return this;
}
- /**
- * Sets the default value of copts. Rule-level copts will append to this.
- */
+ public Builder setDefaultStrictDepsJavaProtos(TriState value) {
+ pkg.defaultStrictDepsJavaProtos = value;
+ return this;
+ }
+
+ /** Sets the default value of copts. Rule-level copts will append to this. */
public Builder setDefaultCopts(List<String> defaultCopts) {
this.defaultCopts = defaultCopts;
return this;