Skip to content
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

Add a built-in http module extension #14570

Closed
shs96c opened this issue Jan 13, 2022 · 9 comments
Closed

Add a built-in http module extension #14570

shs96c opened this issue Jan 13, 2022 · 9 comments
Assignees
Labels
area-Bzlmod Bzlmod-specific PRs, issues, and feature requests P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: feature request

Comments

@shs96c
Copy link
Contributor

shs96c commented Jan 13, 2022

Description of the problem / feature request:

Quite often rulesets depend on resources that are downloaded using http_file. As an example, rules_jvm_external depends on downloading both coursier and jq as tools that it uses. In a WORKSPACE file, this is easy: a call to http_file and the job is done. bazel_dep doesn't allow this behaviour, which means that it's impossible to use these kinds of dependencies when using a purely modularised build.

Further, some of these dependencies are only used using development, so the equivalent of bazel_dep's dev_dependency flag is needed to prevent unnecessary downloads for users.

Feature requests: what underlying problem are you trying to solve with this feature?

I'd like to be able to download useful tools and artifacts and expose them in a purely modularised build.

What's the output of bazel info release?

release 5.0.0rc3

@Wyverald
Copy link
Member

What's wrong with using an extension?

@Wyverald Wyverald added the area-Bzlmod Bzlmod-specific PRs, issues, and feature requests label Jan 13, 2022
@sventiffe sventiffe added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. untriaged labels Jan 13, 2022
@fmeum
Copy link
Collaborator

fmeum commented Jan 13, 2022

Does this example of an extension do what you want?

@shs96c
Copy link
Contributor Author

shs96c commented Jan 14, 2022

Almost. The solution I've gone for has to been to create a bzlmod extension called http_file that exposes the http_file repo rule to a MODULE.bazel. In hindsight, it would be neater to have called that http and have file and archive tags on that, but the idea is sound.

It would be most helpful if extensions like this shipped with @bazel_tools to avoid a proliferation of these appearing across rulesets.

@Wyverald
Copy link
Member

I think it's probably cleaner to go with @fmeum's example -- this way, you don't have to copy http_file's attributes into a tag class. You don't need to write what you want to download in the MODULE.bazel file anyway -- just write them in the extension impl function.

@fmeum
Copy link
Collaborator

fmeum commented Jan 16, 2022

@Wyverald Now that I've thought more about it, I think that this issue may be worth reopening. While the "put repository rules in a static module extension" approach works well for rulesets, it may be difficult to sell to Bazel end users. If MODULE.bazel is assumed to fully replace WORKSPACE some day, I think it would need to offer an easier way for end users to download their custom external repos and files (e.g., via a http.file tag).

@Wyverald
Copy link
Member

Ah, true -- we were thinking about introducing an http.archive tag too.

@Wyverald Wyverald reopened this Jan 17, 2022
@Wyverald Wyverald changed the title No way for bzlmod to depend on non-modularised external dependencies Add a built-in http module extension Jan 17, 2022
@meteorcloudy meteorcloudy added the P2 We'll consider working on this in future. (Assignee optional) label Apr 8, 2022
@Wyverald
Copy link
Member

Update: @SalmaSamy sent a draft PR (#16000). The repo name conflict issue makes it not worth it to create this built-in module extension (see #16000 (comment)) IMO.

@Wyverald
Copy link
Member

Chatted with @shs96c ; we decided that writing a separate module extension every time works well enough that this shouldn't be needed.

@Wyverald Wyverald closed this as not planned Won't fix, can't repro, duplicate, stale Aug 31, 2022
@meteorcloudy
Copy link
Member

#17141 is a duplicated issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Bzlmod Bzlmod-specific PRs, issues, and feature requests P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: feature request
Projects
None yet
Development

No branches or pull requests

6 participants