Re: [sbt] Custom task to be called by sub-projects with sub-project scope

Skip to first unread message

Steven Yang

Mar 14, 2017, 4:04:23 AM3/14/17
Sorry I figured it out.
I have to use .settings() to override the taskKey in each sub-project.

On Thu, Mar 2, 2017 at 7:26 PM, Steven Yang <> wrote:
Hi all

I have a basic multi-project build which had no problem building and executing built-in sub-project tasks independently.
Now I need to write a small task which need to be executed by each sub-project independently and the task requires each sub-project's independent environment.
For example I have the following:
lazy val testTask = TaskKey[Unit]("test", "This is a test")

testTask in subProj1 := {

println((name in subProj1).value + " : " + (baseDirectory in subProj1).value / "version.sbt")
For this I am basically hard-coding the sub-project into the task and am able to get name and baseDirectory of the sub-project, but this means I have to write one for each sub-project.
This is obviously not good.
I wish to define this once in root and to be used in each of my sub-project.
Can some one shine some light one me? or point me to some resource?


Steven Yang

Mar 14, 2017, 4:04:23 AM3/14/17
Reply all
Reply to author
0 new messages