sbt-hepek
December 8, 2023 ยท View on GitHub
An sbt plugin for writing Scala objects to files.
See also hepek, static content generator that builds upon this plugin.
Installation
Add the plugin to project/plugins.sbt:
addSbtPlugin("ba.sake" % "sbt-hepek" % "0.6.0")
and enable it in build.sbt:
myProject.enablePlugins(HepekPlugin)
Usage
The main task of sbt-hepek is hepek.
When executed, it will:
- copy all files from
src/main/resources/publictohepek_outputfolder - write all
object .. extends Renderablefrom thefilespackage tohepek_outputfolder - write accessors for
src/main/resources/publicfiles, so you don't have to type it, or make mistakes
Minimal example:
package files // mandatory !!
import java.nio.file.Paths
import ba.sake.hepek.core.Renderable
object RenderMe extends Renderable {
// access `src/main/resources/public` files through autogenerated files.<TAB>
override def render =
"Some text" // arbitrary Scala code
override def relPath =
Paths.get("renderme.txt")
}
When you run sbt hepek, you'll find the hepek_output/renderme.txt file,
with text Some text.
Examples / docs
- my blog rendered @ blog.sake.ba
- examples
- philosophy behind hepek
Fun fact
I think that this is the first project that tried this approach, namely, using first-class Scala objects for this kind of stuff.
Correct me if I'm wrong... ^_^
About the name
A "hepek" in Bosnian language is a jargon for a thing/thingy/stuff...
It is used when we don't know the name of a thing: "Give me that ... hepek".
Also, it is used in the famous show called "Top lista nadrealista" as a name for an advanced device which calms down situations of various kinds.