我有目錄層次結構像這樣:如何從Scala中的其他目錄導入文件?
src
src/Model
src/View
src/Controller
現在我想建立我的申請。如何從模型視圖和控制器導入/包含類,因爲編譯器無法看到它們?
//編輯
的src/App.scala
import swing._
object App extends Application {
val model = new Model
val view = new View(model)
val controller = new Controller(model, view)
view.visible = true
}
的src /型號/ Model.scala
class Model {
// some code
}
的src /查看/ View.scala
import swing._
class View(model:Model) extends MainFrame {
// some code
}
src/Controller/Controller.scala
class Controller(model:Model, view:View) {
// some code
}
這裏是一個構建腳本時,所有文件都放在src目錄
#!/bin/bash
source ${0%/*}/config.inc.sh
if [ ! -d $CLASSES_PATH ]; then
notice "Creating classes directory..."
mkdir $CLASSES_PATH
fi
notice "Building VirtualCut..."
scalac $SOURCE_PATH/Model/*.scala -d $CLASSES_PATH || error "Build failed (Model)."
scalac $SOURCE_PATH/View/*.scala -d $CLASSES_PATH || error "Build failed (View)."
scalac $SOURCE_PATH/Controller/*.scala -d $CLASSES_PATH || error "Build failed (Controller)."
scalac $SOURCE_PATH/*.scala -d $CLASSES_PATH || error "Build failed."
success "Building complete."
exit 0
,一切工作正常。
-1不足。請顯示一些文件的內容以及你如何編譯這個文件的細節。 – retronym 2011-05-15 14:20:40