Printing is not accepted in task definition in SBT 0.13?

I am using SBT 0.13.1 .

project / build.properties is as follows:

 sbt.version=0.13.1 

Running sbt about prints the following:

 $ sbt [info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins [info] Loading project definition from /Users/jacek/sandbox/so/sbt-0.13.1/project [info] Set current project to sbt-0-13-1 (in build file:/Users/jacek/sandbox/so/sbt-0.13.1/) [sbt-0-13-1]> about [info] This is sbt 0.13.1 [info] The current project is {file:/Users/jacek/sandbox/so/sbt-0.13.1/}sbt-0-13-1 0.1-SNAPSHOT [info] The current project is built against Scala 2.10.4-RC1 [info] Available Plugins: com.typesafe.sbt.SbtGit, com.typesafe.sbt.SbtProguard, growl.GrowlingTests, np.Plugin, net.virtualvoid.sbt.graph.Plugin, com.timushev.sbt.updates.UpdatesPlugin [info] sbt, sbt plugins, and build definitions are using Scala 2.10.3 

With the following task - hello - in build.sbt :

 scalaVersion := "2.10.4-RC1" lazy val hello = taskKey[Unit]("An example task") hello := { print("Sleeping for a sec...") println("done.") } 

... and reload , sbt reports [error] Type error in expression :

 [sbt-0-13-1]> reload [info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins [info] Loading project definition from /Users/jacek/sandbox/so/sbt-0.13.1/project /Users/jacek/sandbox/so/sbt-0.13.1/build.sbt:6: error: type mismatch; found : String("Sleeping for a sec...") required: sbt.TaskKey[String] print("Sleeping for a sec...") ^ [error] Type error in expression Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? 

When I change print to println , the task is defined correctly.

 Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? r [info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins [info] Loading project definition from /Users/jacek/sandbox/so/sbt-0.13.1/project [info] Set current project to sbt-0-13-1 (in build file:/Users/jacek/sandbox/so/sbt-0.13.1/) [sbt-0-13-1]> hello Sleeping for a sec... done. [success] Total time: 0 s, completed Jan 4, 2014 10:31:43 AM 

Is print not specified in the task definition?

+3
sbt
source share
1 answer

With schleichardt, I could finally find out what caused the problem of not accepting print in the hello task.

It turned out that with the sbt-dependency-graph plugin in the global configuration directory, i.e. ~/.sbt/0.13/ (or the specified sbt.global.base directory), sbt was unable to initialize the task and, therefore, an error.

 $ cat plugins/sbt-dependency-graph.sbt addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.4") $ cat sbt-dependency-graph.sbt net.virtualvoid.sbt.graph.Plugin.graphSettings 

To reproduce, see the following sbt session starting with print ( not println ) in the build.sbt directory and empty :

 jacek:~/sandbox/so/sbt-0.13.1 $ tree . ├── build.sbt └── project └── build.properties 1 directory, 2 files jacek:~/sandbox/so/sbt-0.13.1 $ cat build.sbt scalaVersion := "2.10.4-RC1" lazy val hello = taskKey[Unit]("An example task") hello := { print("Sleeping for a sec...") println("done.") } jacek:~/sandbox/so/sbt-0.13.1 $ sbt -Dsbt.global.base=/tmp/so Getting org.scala-sbt sbt 0.13.1 ... :: retrieving :: org.scala-sbt#boot-app confs: [default] 43 artifacts copied, 0 already retrieved (12646kB/154ms) Getting Scala 2.10.3 (for sbt)... :: retrieving :: org.scala-sbt#boot-scala confs: [default] 5 artifacts copied, 0 already retrieved (24447kB/204ms) [info] Loading project definition from /Users/jacek/sandbox/so/sbt-0.13.1/project [info] Updating {file:/Users/jacek/sandbox/so/sbt-0.13.1/project/}sbt-0-13-1-build... [info] Resolving org.fusesource.jansi#jansi;1.4 ... [info] Done updating. [info] Set current project to sbt-0-13-1 (in build file:/Users/jacek/sandbox/so/sbt-0.13.1/) > hello Sleeping for a sec...done. [success] Total time: 0 s, completed Jan 4, 2014 1:35:22 PM 

He is still working.

Create files for the sbt-dependency-graph plugin in the global configuration directory.

 jacek:/tmp/so $ cat plugins/sbt-dependency-graph.sbt addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.4") jacek:/tmp/so $ cat sbt-dependency-graph.sbt net.virtualvoid.sbt.graph.Plugin.graphSettings 

... and reload .

 > reload [info] Loading global plugins from /private/tmp/so/plugins [info] Updating {file:/tmp/so/plugins/}global-plugins... [info] Resolving org.fusesource.jansi#jansi;1.4 ... [info] Done updating. [info] Loading project definition from /Users/jacek/sandbox/so/sbt-0.13.1/project [info] Updating {file:/Users/jacek/sandbox/so/sbt-0.13.1/project/}sbt-0-13-1-build... [info] Resolving org.fusesource.jansi#jansi;1.4 ... [info] Done updating. /Users/jacek/sandbox/so/sbt-0.13.1/build.sbt:6: error: type mismatch; found : String("Sleeping for a sec...") required: sbt.TaskKey[String] print("Sleeping for a sec...") ^ [error] Type error in expression Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? 

When print changes to println and (r)etry , it works fine again.

 Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? r [info] Loading global plugins from /private/tmp/so/plugins [info] Loading project definition from /Users/jacek/sandbox/so/sbt-0.13.1/project [info] Set current project to sbt-0-13-1 (in build file:/Users/jacek/sandbox/so/sbt-0.13.1/) > hello Sleeping for a sec... done. [success] Total time: 0 s, completed Jan 4, 2014 1:43:59 PM 
+1
source share

All Articles