I'm creating a task in SBT that will create a properly-formatted classpath, but I get an undefined setting error when I try to compile
. The error is not useful enough to tell me what setting is undefined:
[error] Reference to undefined setting:
[error]
[error] *:fullClasspath from *:fcp
[error]
This is for the following build configuration:
import sbt._
import Keys._
object TestBuild extends Build {
override lazy val settings = super.settings ++ Seq(
name := "blah", scalaVersion := "2.10.2"
)
lazy val fcp = TaskKey[String]("fcp", "create formatted classpath")
lazy val fcpTask = fcp <<= fullClasspath map { tasks =>
val cp = tasks.map(_.data.getName + ":")
s"[Classpath]$cp[/Classpath]"
}
lazy val project = Project(
"project", file("."), settings = settings ++ Seq(fcpTask)
)
}
Three things:
1) You're removing all the default settings. When you create a project, you can specify a complete list of settings for the project (like you're currently doing) or you can add your settings configurations to the defaults. If you change your project definition to the following, it should start working:
lazy val project = (
Project("project", file("."))
.settings(fcpTask)
)
2) You're placing settings into the Build
itself. If these settings don't exist on the Project
level, then it will look into the Build
for the settings. However, things like name
should probable be defined in the project. So your complete build file would look like:
import sbt._
import Keys._
object TestBuild extends Build {
lazy val fcp = TaskKey[String]("fcp", "create formatted classpath")
lazy val fcpTask = fcp <<= fullClasspath map { tasks =>
val cp = tasks.map(_.data.getName + ":")
s"[Classpath]$cp[/Classpath]"
}
lazy val project = (
Project("project", file("."))
.settings(name := "blah", scalaVersion := "2.10.2")
.settings(fcpTask)
)
}
3) You should select which configuration you want to pull your class path from. Options:
What you had before is equivalent to fullClasspath in Compile
IIRC.
Hope that helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With