I have a Play project running on Play 2.1.1.
I would like to define a separate and distinct task to jar up only a specific package in my Play project (e.g. just the models package). I do not wish to override the current package
tasks as I want to preserve their behaviour.
How would I go about creating a custom task based off of the current package
task?
I've looked at Custom Settings and Tasks in the SBT documentation but these examples are fairly trivial and don't give any examples that use the SBT library.
I'd like to propose an approach with custom configuration.
The following is a
build.sbt
of a sample project:In the above build configuration, there's
custompackage
configuration that scopes settings and tasks. As an example of how it can change the behaviour ofpackageBin
task there's a (re)definition in this scope. The last line adds the custom configuration to the project.When you run SBT shell (
sbt
), you will notice that the realpackageBin
task is untouched while it changes incustompackage
scope. By default, you're inCompile
configuration. To change it, you need to use the extended syntax to execute a task in another configuration.When you change configuration axis to
custompackage
the taskpackageBin
changes.All tested under SBT 0.13.1.