7

我正在尝试使用 Lift Web 框架建立一个 scala sbt 项目。我在用着

  • 斯卡拉 2.9.0-1
  • sbt 0.10.1
  • 电梯 2.3
  • xsbt-web-plugin 0.1.1(仅在 scala 2.8.1 上,见问题结尾)

(我知道的最新版本)。我按照http://d.hatena.ne.jp/k4200/20110711/1310354698https://github.com/siasia/xsbt-web-plugin/blob/master/README.md获取了以下 sbt 配置文件:

项目/build.properties

sbt.version=0.10.1

项目/插件/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))

项目/Build.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)
}

当我尝试 sbt jetty-run 时,我收到以下错误消息:

[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]

所以我注意到确实存在一些 jetty-* 命令,但不是我想要的,所以我打印了 webSettings,它应该包含所有这些新设置,它包含 jetty-context 和 jetty-port,以及 jetty-configuration 和其他人,但不是码头运行:s。

我做错了什么没有码头运行?

我尝试切换到 scala-2.8.1,因为 web 插件目前仅在 scala 2.8.1 上,通过更改我的 buildScalaVersion 变量,但这并没有改变任何东西。你有什么主意吗?

在此先感谢您的帮助

4

1 回答 1

5

任务是聚合的;命令不是。

jetty-run是一个命令。它仅在具有 Web 插件设置的子项目的上下文中可用。

> project web
> jetty-run

运行后,您可以使用该prepare-webapp任务重新部署 webapp。这可以从root项目的上下文中运行,因为它聚合了 Web 项目。

于 2011-08-14T14:13:38.583 回答