Tôi đang cố gắng thiết lập dự án scala sbt với khung nâng web. Tôi đang sử dụngPlugin web sbt: Không phải là khóa hợp lệ: jetty-run (tương tự: jetty-port, jetty-context, run)
- scala 2.9.0-1
- SBT 0.10.1
- nâng 2.3
- xsbt-web-plugin 0.1.1 (đó là chỉ trên scala 2.8.1, xem kết thúc câu hỏi)
(các phiên bản gần đây tôi biết). Tôi đi theo http://d.hatena.ne.jp/k4200/20110711/1310354698 và https://github.com/siasia/xsbt-web-plugin/blob/master/README.md để có được các tập tin cấu hình SBT sau: Dự án
/build.properties
sbt.version=0.10.1
dự án/plugins/build.sbt
resolvers += "Web plugin repo" at "http://siasia.github.com/maven2"
libraryDependencies <+= sbtVersion(v => "com.github.siasia" % "xsbt-web-plugin_2.8.1" % ("0.1.1-"+v))
dự án/Xây dựng. scala
import sbt._
import Keys._
object BuildSettings {
val buildOrganization = "xbaz"
val buildScalaVersion = "2.9.0-1"
val buildVersion = "0.0.1"
val buildSettings = Defaults.defaultSettings ++ Seq (
organization := buildOrganization,
scalaVersion := buildScalaVersion,
version := buildVersion)
}
object Resolvers {
val webPluginRepo = "Web plugin repo" at "http://siasia.github.com/maven2"
val jettyRepo = "Jetty Repo" at "http://repo1.maven.org/maven2/org/mortbay/jetty"
}
object Dependencies {
// web plugin
val webPluginDeps = Seq(
"org.mortbay.jetty" % "jetty" % "6.1.26" % "jetty", // The last part is "jetty" not "test".
"javax.servlet" % "servlet-api" % "2.5" % "provided->default"
)
val liftDeps = {
val liftVersion = "2.3" // I'll switch to 2.3 soon!
Seq(
"net.liftweb" % "lift-webkit_2.8.1" % liftVersion % "compile->default",
"net.liftweb" % "lift-mapper_2.8.1" % liftVersion % "compile->default"
)
}
val scalaTest = "org.scalatest" % "scalatest_2.9.0" % "1.6.1" % "test"
val apacheHttpClient = "org.apache.httpcomponents" % "httpclient" % "4.1.1"
val apacheHttpCore = "org.apache.httpcomponents" % "httpcore" % "4.1.1"
// Logging
lazy val grizzled = "org.clapper" % "grizzled-slf4j_2.8.1" % "0.5"
lazy val junit = "junit" % "junit" % "4.8" % "test"
lazy val logback_core = "ch.qos.logback" % "logback-core" % "0.9.24" % "compile" //LGPL 2.1
lazy val logback_classic = "ch.qos.logback" % "logback-classic" % "0.9.24" % "compile" //LGPL 2.1
lazy val log4j_over_slf4j = "org.slf4j" % "log4j-over-slf4j" % "1.6.1"
val logDeps = Seq(grizzled, log4j_over_slf4j, logback_core, logback_classic)
}
object MyBuild extends Build {
import com.github.siasia.WebPlugin._ // web plugin
import BuildSettings._
import Dependencies._
import Resolvers._
//End dependencies
lazy val root = Project("root", file(".") , settings = buildSettings ++
Seq(name := "foo")
) aggregate(core, cli, web)
// mainClass:= Some("Main"))
lazy val core : Project = Project("core", file("core"), delegates = root :: Nil, settings = buildSettings ++
Seq(
name := "foo-core",
libraryDependencies ++= logDeps ++ Seq(scalaTest, apacheHttpClient, apacheHttpCore)
)
)
lazy val cli: Project = Project("cli", file("cli"), settings = buildSettings ++
Seq(
name := "foo-cli",
libraryDependencies ++= logDeps ++ Seq(apacheHttpClient),
fork in run := true,
javaOptions in run += "-Djava.library.path=/home/jolivier/Projets/asknow/lib/jnotify-lib-0.93"
)) dependsOn(core) settings(
)
lazy val web: Project = Project("web", file("web"), settings = buildSettings ++
Seq (resolvers := Seq(webPluginRepo, jettyRepo),
name := "foo-http",
libraryDependencies ++= logDeps ++ webPluginDeps ++ liftDeps
) ++
webSettings
) dependsOn(core)
}
Khi tôi cố gắng SBT cầu cảng chạy tôi nhận được thông báo lỗi sau:
[error] Not a valid command: jetty-run
[error] Not a valid project ID: jetty-run
[error] Not a valid configuration: jetty-run
[error] Not a valid key: jetty-run (similar: jetty-port, jetty-context, run)
[error] jetty-run
[error]
Vì vậy, tôi nhận thấy rằng một số lệnh * jetty- vẫn tồn tại, nhưng không phải là người tôi muốn, vì vậy tôi in webSettings mà là vụ phải chứa tất cả các cài đặt mới này và nó chứa jetty-context và jetty-port, cũng như jetty-configuration và các thiết lập khác, nhưng không chạy jetty: s.
Tôi đã làm gì sai khi không có cầu tàu?
Tôi đã thử chuyển sang scala-2.8.1 vì plugin web hiện chỉ có trên scala 2.8.1, bằng cách thay đổi biến buildScalaVersion của tôi nhưng điều đó không thay đổi bất cứ điều gì. Bạn còn ý kiến nào không?
Cảm ơn trước sự giúp đỡ của bạn
oh ok, tôi khá mới để sbt và đã không nhận được loại tinh tế, tôi đã thử cũng web/jetty-chạy kể từ khi tôi bắt đầu chạy với cli/run nhưng điều đó đã không làm việc hoặc ... Tôi cũng phải chuyển sang scala-2.8.1 cho tính không tương thích nhị phân nhưng có vẻ tốt lúc này :) Cảm ơn rất nhiều! – jolivier
Tôi nhận được lỗi 'không phải là ID dự án hợp lệ: web' hợp lệ – Jus12