Skip to content

[6.3.0] Allow overrides in non-root modules #18388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ public SkyValue compute(SkyKey skyKey, Environment env)
moduleKey,
module.getVersion());
}
if (!moduleFileGlobals.buildOverrides().isEmpty()) {
throw errorf(Code.BAD_MODULE, "The MODULE.bazel file of %s declares overrides", moduleKey);
}

return NonRootModuleFileValue.create(module, moduleFileHash);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,8 @@ private void addOverride(String moduleName, ModuleOverride override) throws Eval
doc =
"Specifies that a dependency should still come from a registry, but its version should"
+ " be pinned, or its registry overridden, or a list of patches applied. This"
+ " directive can only be used by the root module; in other words, if a module"
+ " specifies any overrides, it cannot be used as a dependency by others.",
+ " directive only takes effect in the root module; in other words, if a module"
+ " is used as a dependency by others, its own overrides are ignored.",
parameters = {
@Param(
name = "module_name",
Expand Down Expand Up @@ -703,9 +703,9 @@ public void singleVersionOverride(
name = "multiple_version_override",
doc =
"Specifies that a dependency should still come from a registry, but multiple versions of"
+ " it should be allowed to coexist. This directive can only be used by the root"
+ " module; in other words, if a module specifies any overrides, it cannot be used"
+ " as a dependency by others.",
+ " it should be allowed to coexist. This directive only takes effect in the root"
+ " module; in other words, if a module is used as a dependency by others, its own"
+ " overrides are ignored.",
parameters = {
@Param(
name = "module_name",
Expand Down Expand Up @@ -756,9 +756,9 @@ public void multipleVersionOverride(String moduleName, Iterable<?> versions, Str
name = "archive_override",
doc =
"Specifies that this dependency should come from an archive file (zip, gzip, etc) at a"
+ " certain location, instead of from a registry. This directive can only be used by"
+ " the root module; in other words, if a module specifies any overrides, it cannot"
+ " be used as a dependency by others.",
+ " certain location, instead of from a registry. This"
+ " directive only takes effect in the root module; in other words, if a module"
+ " is used as a dependency by others, its own overrides are ignored.",
parameters = {
@Param(
name = "module_name",
Expand Down Expand Up @@ -840,8 +840,8 @@ public void archiveOverride(
name = "git_override",
doc =
"Specifies that a dependency should come from a certain commit of a Git repository. This"
+ " directive can only be used by the root module; in other words, if a module"
+ " specifies any overrides, it cannot be used as a dependency by others.",
+ " directive only takes effect in the root module; in other words, if a module"
+ " is used as a dependency by others, its own overrides are ignored.",
parameters = {
@Param(
name = "module_name",
Expand Down Expand Up @@ -907,8 +907,8 @@ public void gitOverride(
name = "local_path_override",
doc =
"Specifies that a dependency should come from a certain directory on local disk. This"
+ " directive can only be used by the root module; in other words, if a module"
+ " specifies any overrides, it cannot be used as a dependency by others.",
+ " directive only takes effect in the root module; in other words, if a module"
+ " is used as a dependency by others, its own overrides are ignored.",
parameters = {
@Param(
name = "module_name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,10 @@ public void testSimpleDiamond() throws Exception {
.addModule(
createModuleKey("ccc", "2.0"),
"module(name='ccc', version='2.0');bazel_dep(name='ddd',version='3.0')")
.addModule(createModuleKey("ddd", "3.0"), "module(name='ddd', version='3.0')");
.addModule(
createModuleKey("ddd", "3.0"),
// Add a random override here; it should be ignored
"module(name='ddd', version='3.0');local_path_override(module_name='ff',path='f')");
ModuleFileFunction.REGISTRIES.set(differencer, ImmutableList.of(registry.getUrl()));

EvaluationResult<DiscoveryValue> result =
Expand Down