我在系统上安装了一些 jar,我想将它们包含在 SBT 项目的类路径中。附加到 unmanagedClasspath 似乎是一种方法,但它会拒绝任何带有斜线的值 - 不知道为什么。
目前我有以下内容,成功将我的项目下的“lib”目录添加到类路径中:
import sbt._
class OvationImporterProject(info: ProjectInfo) extends DefaultProject(info)
{
override def unmanagedClasspath: PathFinder =
{
super.unmanagedClasspath +++ "lib"
}
}
如果我尝试在其中添加绝对路径,我会得到以下结果:
java.lang.IllegalArgumentException: requirement failed: Path component '/opt/jauimodel/lib/' must not have forward slashes in it at scala.Predef$.require(Predef.scala:112) at sbt.Path$.checkComponent(Path.scala:176) at sbt.RelativePath.(Path.scala:113) at sbt.Path.$div(Path.scala:34) at sbt.Project$class.path(Project.scala:143) at sbt.BasicScalaProject.path(DefaultProject.scala:21) at OvationImporterProject.unmanagedClasspath(OvationImporter.scala:7) ....
有正确的方法吗?
谢谢!
最佳答案
尝试一下 super.unmanagedClasspath+++ Path.fromFile("/opt/jauimodel/lib/")
只有“lib”可能会触发relativePath,它会触发checkComponent方法来检查是否为.,
关于scala - 在 SBT 项目中包含任意类路径条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4210420/