How to get a setting in the current scope

100 views
Skip to first unread message

Udayakumar Rayala

unread,
Jun 21, 2011, 1:17:44 PM6/21/11
to simple-build-tool
Hi,

I want to access a setting in my task related to the scope in which it
is executed.

Like,

myTask <<= (classDirectory in Compile, classDirectory) map
{ (classDir, scopedDir) =>
println("Class directory: " + classDir)
println("Scoped class directory: " + scopedDir)
}


But this fails and reports the classDirectory is not initialized. I
would want the task to display different classpaths when called in
Test, it etc.

Is there a way i can do it?

Thanks,
Uday.

Mark Harrah

unread,
Jun 22, 2011, 10:14:29 AM6/22/11
to simple-b...@googlegroups.com
Hi Uday,

You have to put it into each scope you want. So, do something like:

// as above
def myTaskSetting =

myTask <<= (classDirectory in Compile, classDirectory) map
{ (classDir, scopedDir) =>
println("Class directory: " + classDir)
println("Scoped class directory: " + scopedDir)
}

// put it in each configuration desired
def myTasks = Seq(Compile, Test, IntegrationTest) flatMap { conf =>
inConfig(conf)( Seq(myTaskSetting) )
}

... = Project("...", file(...)) settings( myTasks : _*)

-Mark

Reply all
Reply to author
Forward
0 new messages