sake92 / sbt-hepek   0.6.0

Apache License 2.0 GitHub

Sbt plugin for rendering Scala objects to files. And more!

Scala versions: 2.12
sbt plugins: 1.x

sbt-hepek

Maven Central

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:

  1. copy all files from src/main/resources/public to hepek_output folder
  2. write all object .. extends Renderable from the files package to hepek_output folder
  3. write accessors for src/main/resources/public files, 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


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.