tasks in build.sbt

750 views
Skip to first unread message

Channing

unread,
Sep 18, 2011, 4:24:52 PM9/18/11
to simple-b...@googlegroups.com
Hi,
I'm trying to write tasks in a simple configuration, build.sbt, at the root of my project. I've read https://github.com/harrah/xsbt/wiki/Tasks but nothing I try from there works for me.

I am using v 0.11.0RC1

I've tried just adding a simple:

intTask := 5
 
in the build.sbt but I get 
 
.../build.sbt:44: error: not found: value intTask
intTask := 5
^
.../build.sbt:44: error: reassignment to val
intTask := 5
        ^
[error] Type error in expression

I then tried 

val intTask = TaskKey[Int]("int-task")


intTask := 5 

but that results in 

.../build.sbt:44: error: illegal start of simple expression
val intTask = TaskKey[Int]("int-task") 

What am I doing wrong? 

Jason Zaugg

unread,
Sep 19, 2011, 3:27:13 AM9/19/11
to simple-b...@googlegroups.com
The Light Configuration (build.sbt) isn't a single Scala program; instead it is a collection of independent expressions. So you can't define vals and refer to them from lower in the file.

Alternatives:

1. Inline the task key into the expression.

TaskKey[Int]("int-task") <:= 5


2. Use a block expression

{
   val intTask = TaskKey[Int]
   intTask := 5
}

3. Define the key `intTask` in the full configuration and refer to it from the light configuration.

-jason

Channing Walton

unread,
Sep 19, 2011, 6:13:01 AM9/19/11
to simple-b...@googlegroups.com
Hi,
I just tried:

TaskKey[Int]("int-task") <:= 5

But got

.../build.sbt:44: error: reassignment to val
Error occurred in an application involving default arguments.
TaskKey[Int]("int-task") <:= 5

Josh Suereth

unread,
Sep 19, 2011, 8:47:49 AM9/19/11
to simple-b...@googlegroups.com
You want := not <:=

--
You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
To post to this group, send email to simple-b...@googlegroups.com.
To unsubscribe from this group, send email to simple-build-t...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/simple-build-tool?hl=en.

Doug Tangren

unread,
Sep 19, 2011, 9:31:20 AM9/19/11
to simple-b...@googlegroups.com
On Mon, Sep 19, 2011 at 8:47 AM, Josh Suereth <joshua....@gmail.com> wrote:
You want := not <:=


or possibly <<=. see https://github.com/harrah/xsbt/wiki/Settings for the list of available symbolic binding methods
Reply all
Reply to author
Forward
0 new messages