Skip to main content

scala-cli-adding-directives

Add or change using directives in Scala CLI. Use when adding a new //> using directive, registering a directive handler, or editing directive preprocessing.

来源信息

仓库
VirtusLab/scala-cli
最近来源活动
2026年3月18日 07:40
检测到的 SKILL.md 语言
英语
星标
645
分支
169

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
scala-cli-adding-directives
description
Add or change using directives in Scala CLI. Use when adding a new //> using directive, registering a directive handler, or editing directive preprocessing.
# Adding a new directive (Scala CLI) 1. **Create a case class** in `modules/directives/src/main/scala/scala/build/preprocessing/directives/` extending one of: - `HasBuildOptions` — produces `BuildOptions` directly - `HasBuildOptionsWithRequirements` — produces `BuildOptions` with scoped requirements (e.g. `test.dep`) - `HasBuildRequirements` — produces `BuildRequirements` (for `//> require`) 2. **Annotate**: `@DirectiveLevel(SpecificationLevel.EXPERIMENTAL)`, `@DirectiveDescription("…")`, `@DirectiveUsage("…")`, `@DirectiveExamples("…")`, `@DirectiveName("key")` on fields. 3. **Companion**: `val handler: DirectiveHandler[YourDirective] = DirectiveHandler.derive` 4. **Register** in `modules/build/.../DirectivesPreprocessingUtils.scala` in the right list: `usingDirectiveHandlers`, `usingDirectiveWithReqsHandlers`, or `requireDirectiveHandlers`. 5. **Regenerate reference docs**: `./mill -i 'generate-reference-doc[]'.run` CLI options always override directive values when both set the same thing.
在 GitHub 查看