bazelbuild / bazelbuild/bazel

Add module_ctx.template Starlark function

Open
#24,829 4 comments 0 reactions 0 assignees View on GitHub
P2 team-ExternalDeps type: feature request
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 18h
Merged PRs (30d)
75

Description

### Description of the feature request:

Create function module_ctx.template with the same interface and semantics as repository_ctx.template.

### Which category does this issue belong to?

Rules API

### What underlying problem are you trying to solve with this feature?

There's repository_ctx.template to expand a template as part of a repository rule, but no equivalent in module_ctx. This means that module rule implementations that want to expand a template either have to instantiate a private repository rule, or implement template expansion by hand.

### Which operating system are you running Bazel on?

macOS

### What is the output of `bazel info release`?

release 8.0.0

### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.

_No response_

### What's the output of `git remote get-url origin; git rev-parse HEAD` ?

_No response_

### Have you found anything relevant by searching the web?

Didn't find anything on these sites using the search query "module_ctx template"

### Any other information, logs, or outputs that you want to share?

Maybe it would be enough to move StarlarkRepositoryContext.createFileFromTemplate into StarlarkBaseExternalContext.

A similar argument could be made for other functions in StarlarkRepositoryContext: delete, rename, patch, symlink.

Contributor guide

Open the contributing guide

Research direction

Start by reading the existing repository_ctx.template behavior and the named StarlarkRepositoryContext.createFileFromTemplate entry point. Implement the corresponding module_ctx.template API with the same interface and semantics, then verify that module rule implementations can expand templates without a private repository rule.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.