2014-10-28 63 views
1

使用sbt 0.13.7,我在我的build.sbt文件中設置target := new File("sbt-target")。這適當地設置編譯器輸出所有類文件到./sbt-target/scala-2.11/{test-,}classes。這是好的,但是當我調用sbt test)時,JVM是找不到我的源文件:如何獲得`sbt test`來識別我的自定義目標?

> 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 

(但是,它爲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 

我大吃一驚。

我的更高目標是我試圖讓scala-ide對編譯的工件使用不同於sbt的文件夾。這是另一個問題,但編碼器scala-ide忽略了<classpathentry output="..."設置。

回答

1

我剛剛有完全相同的問題。

您需要設置您的目標目錄相對於您的基礎項目目錄。替換:

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

有了:

target := baseDirectory.value/"sbt-target" 
相關問題