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)
Create a case class in
modules/directives/src/main/scala/scala/build/preprocessing/directives/extending one of:HasBuildOptions— producesBuildOptionsdirectlyHasBuildOptionsWithRequirements— producesBuildOptionswith scoped requirements (e.g.test.dep)HasBuildRequirements— producesBuildRequirements(for//> require)
Annotate:
@DirectiveLevel(SpecificationLevel.EXPERIMENTAL),@DirectiveDescription("…"),@DirectiveUsage("…"),@DirectiveExamples("…"),@DirectiveName("key")on fields.Companion:
val handler: DirectiveHandler[YourDirective] = DirectiveHandler.deriveRegister in
modules/build/.../DirectivesPreprocessingUtils.scalain the right list:usingDirectiveHandlers,usingDirectiveWithReqsHandlers, orrequireDirectiveHandlers.Regenerate reference docs:
./mill -i 'generate-reference-doc[]'.run
CLI options always override directive values when both set the same thing.