2016-08-26 129 views
0

我想設置一個多項目,其中包括一個子項目,該項目在其項目目錄中的Dependencies.scala文件中定義了一個類的導入。當我在子項目上運行sbt時,一切正常,但是當我在根項目上運行sbt時,出現錯誤提示找不到依賴關係。這裏是我的根build.sbt:sbt多項目項目導入錯誤

name   := "sbtTest" 

organization := "com.test" 

version  := "0.1" 



lazy val foo = project 

下面是Foo的build.sbt:

import Dependencies._ 

name := "foo" 

version := "0.2" 


scalaVersion := "2.10.6" 

Dependencies.scala是富/項目,這裏是確切的錯誤我得到:

/Users/xyz/git/sbtTest/foo/build.sbt:1: error: not found: object Dependencies 

import Dependencies._ 
    ^
[error] Type error in expression 

有沒有人遇到過這個問題?

回答

0

我通過使我build.sbt看起來像這樣固定的..

lazy val otherProject = RootProject(file("../otherproject")) 

lazy val rootProject = (project in file(".")) 
    // dependsOn allows the root project to use functions from 
    .dependsOn(otherProject) 
    // aggregation runs tasks of root project on aggregated projects as well 
    .aggregate(otherProject) 
+0

我試過,但FOO項目,當我用RootProject不會被包括在內。如果我編譯富不編譯,如果我運行'sbt項目'foo沒有列出。 –

+0

您將需要.dependsOn和.aggregate在您的根項目上。我將用整個解決方案編輯我的答案。 – Losmoges