Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aappddeevv/sbt-cli-codegen
Generate scala sources using a sbt plugin, slightly easier than writing your own.
https://github.com/aappddeevv/sbt-cli-codegen
Last synced: 25 days ago
JSON representation
Generate scala sources using a sbt plugin, slightly easier than writing your own.
- Host: GitHub
- URL: https://github.com/aappddeevv/sbt-cli-codegen
- Owner: aappddeevv
- License: mit
- Created: 2020-02-22T16:06:36.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-03-17T19:05:07.000Z (almost 5 years ago)
- Last Synced: 2024-11-06T09:43:51.932Z (2 months ago)
- Language: Scala
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![Bintray](https://img.shields.io/bintray/v/aappddeevv/sbt-plugins/sbt-cli-codegen)
# sbt-cli-codgen
This sbt plugin generates scala source artifacts. Sbt by default does not
cache source generated artifacts. The manual recommends optimizing code
generation. This plugin implements that pattern so you can
more easily generate artifacts with sbt caching.## Usage
Generate scala source artifacts more easily than writing your
own tasks. While it is easy to generate your own scala sources
if you read sbt manual on this topic, once you want to start
tracking input and output files so that the build is optimized
a bit more than running the generator on every compile, you encounter
a little bit of boilerplate.This plugin removes that boilerplate for simple cases but does
require you to be specific about your inputs and outputs so that
they can be manager by sbt.sbt uses the `/target/scala-/src_managed/main`
directory by default for managed sources that you generate. To make
the plugin easier to configure, you should arrange for cli to
place its outputs into that location.To use, add the following:
```scala
// plugins.sbt
resolvers += Resolver.bintrayIvyRepo("aappddeevv", "sbt-plugins")addSbtPlugin("ttg" % "sbt-cli-codegen" % "")
```Then in your build.sbt:
```scala
// build.sbt// you must be a bit more specific since it uses a more general plugin
val cli_command = (input_files: Seq[String]) =>
(Seq("awesome-cli", "--param", "1",
"--output", "mysubproject/target/scala-2.13/src_managed/main/cli_codgen/awesome.scala"),
Seq("awesome.scala"))lazy val subproject = project.in(file("subproject"))
.enablePlugin(CLICodegenPlugin)
.setting(
codegenCommand := cli_command,
codegenInputSources := Seq(sourceDirectory.value.toGlob / "mysubproject/src/main/awesome/*.awesome")
)
```There are some other ways to specify input and output files so that sbt can manage the run
process. Please check the source as the plugin is only 20-30 lines.
You can also dynamically generate an output file that has the list of output files that
were generated into the src_managed directory and the plugin will ensures that they exist.## License
[![GitHub license](https://img.shields.io/badge/license-MIT-lightgrey.svg?maxAge=2592000)](https://raw.githubusercontent.com/aappddeevv/sbt-cli-codegen/master/LICENSE)
MIT license.