简体   繁体   中英

How do I get `sbt test` to recognize my custom target?

Using sbt 0.13.7 , I am setting target := new File("sbt-target") in my build.sbt file. This appropriately sets the compiler to output all class files to ./sbt-target/scala-2.11/{test-,}classes . That is fine, but when I invoke sbt test ), the JVM is unable to find my source files:

> test
[error] (test:executeTests) java.lang.IllegalArgumentException: Unable to load class: com.spingo.api.test.presenter.EventSummaryPresenterSpec
[error] Total time: 2 s, completed Oct 28, 2014 3:41:27 PM

(however, it works for sbt test:console )

> test:console
[warn] Multiple resolvers having different access mechanism configured with same name 'SpinGo Releases'. To avoid conflict, Remove duplicate project resolvers (`resolvers`) or rename publishing resolver (`publishTo`).
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.11.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_05).
Type in expressions to have them evaluated.
Type :help for more information.

scala> Class.forName("com.spingo.api.test.presenter.EventSummaryPresenterSpec")
res0: Class[_] = class com.spingo.api.test.presenter.EventSummaryPresenterSpec

I'm flabbergasted.

My higher goal is I'm trying to get scala-ide to use a different folder for compiled artifacts than sbt . This is another issue, but the compiler under scala-ide ignores the <classpathentry output="..." setting.

I have created a patch to sbt which fixes the issue I am seeing; also, I've described the issue in further depth here: https://github.com/sbt/sbt/issues/1701

I just had the exact same issue.

You need to set your target directory relative to your base project directory. Replace:

target := new File("sbt-target")

With:

target := baseDirectory.value / "sbt-target"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM