Web项目的LIFT设置:使用mvn生成,并使用sbt管理

发布于 2024-12-17 22:20:38 字数 274 浏览 2 评论 0原文

我是 LIFT 的新手,我正在尝试找到如何分别使用 Maven 和 sbt 生成和管理 LIFT Web 项目的可靠说明。有人可以指导我(或在此处提供)如何为 Maven 生成的项目设置 sbt 的最新说明吗?从我红色的每一篇文章来看,它看起来像是 LIFT 项目的最佳设置:使用 mvn 生成,使用 sbt 管理。你会同意吗? (我无法使用 sbt 生成 LIFT/web 项目。对吗?SBT 只适合管理它。对吗?)不过,我尝试的每条指令都已过时。 (显然我可以简单地下载并解压原型项目,但我想找到一种更基本的方法来管理环境)谢谢。

I am new to LIFT, and I am trying to find a reliable instructions how to generate and manage LIFT web project with maven and sbt respectively. Can someone please direct me (or provide here) to the up to date instructions how to setup sbt for the maven generated project? From every post what I've red, it looks like the best setup for the LIFT projects: generate with mvn, manage with sbt. Will you agree? (I cannot generate LIFT/web project with sbt. Right? SBT is only good for managing it. Right? ) Every instructions I tried are out of date though. (I obviously can simply download and un-tar the archetype project, but I want to find a more fundamental approach for managing the environment ) Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

峩卟喜欢 2024-12-24 22:20:39

您的体验可能会有所不同,但我对 sbt 的体验并不出色(文档过时、版本更改造成损坏等)。与使用 sbt 相比,最近对 eclipse scala IDE 以及相应的 maven 和 jrebel 插件的改进使其成为明显的赢家。

如果您按照说明进行操作,您将能够在命令行中构建/打包,同时还能获得对 Eclipse 功能和快速开发的卓越支持。

请参阅示例项目设置:

https://github.com/awkay/lift_squeryl_demo

Your mileage may vary, but my experience with sbt has been less than stellar (out-of-date docs, breakage on version changes, etc). The recent improvements to the eclipse scala IDE and corresponding maven and jrebel plugins make it a clear winner compared to using sbt.

If you follow the instructions, you'll get the ability to build/package at the command line, but superior support for eclipse features and fast development.

See the sample project setup at:

https://github.com/awkay/lift_squeryl_demo

当爱已成负担 2024-12-24 22:20:38

当我使用 lift 时,我根本不需要专家,只需要 SBT。因此,阅读 SBT 入门 部分非常有用。 Lift wiki 还包含一些信息。但请确保您阅读了与正确的 SBT 版本相关的材料。最后,大家可以关注我github上的lift项目模板
祝电梯好运!太棒了;)

通过遵循您评论中的问题,我在这里放置了我的项目中的一些常见配置。

因此,这是 ./project/build.scala 作为 ./build.sbt

import sbt._
import Keys._
import com.github.siasia._
import PluginKeys._
import WebPlugin._
import WebappPlugin._

object LiftProjectBuild extends Build {
  override lazy val settings = super.settings ++ buildSettings

  lazy val buildSettings = Seq(
    organization := "com.yourorganization",
    version      := "0.1-SNAPSHOT",
    scalaVersion := "2.9.1")

  def yourWebSettings = webSettings ++ Seq(
    // If you are using jrebel
    scanDirectories in Compile := Nil
    )

  lazy val shade = Project(
    id = "project-name",
    base = file("."),
    settings = defaultSettings ++ yourWebSettings)

  lazy val defaultSettings = Defaults.defaultSettings ++ Seq(
    name := "project-name",
    resolvers ++= Seq(
      "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases", 
      "Java.net Maven2 Repository" at "http://download.java.net/maven/2/"),

    libraryDependencies ++= {
      val liftVersion = "2.4-M5"
      Seq(
        "net.liftweb" %% "lift-webkit" % liftVersion % "compile",
        "org.eclipse.jetty" % "jetty-webapp" % "7.5.4.v20111024" % "container",
        "org.squeryl" %% "squeryl" % "0.9.5-SNAPSHOT" % "compile",
        "ch.qos.logback" % "logback-classic" % "1.0.0" % "compile",
        "org.scalatest" %% "scalatest" % "1.6.1" % "test",
        "junit" % "junit" % "4.10" % "test")
    },

    // compile options
    scalacOptions ++= Seq("-encoding", "UTF-8", "-deprecation", "-unchecked"),
    javacOptions  ++= Seq("-Xlint:unchecked", "-Xlint:deprecation"),

    // show full stack traces
    testOptions in Test += Tests.Argument("-oF")
  )
}

./project/build.properties

#Project properties
sbt.version=0.11.1

./project/plugins.sbt

resolvers += Classpaths.typesafeResolver

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse" % "1.5.0")

libraryDependencies <+= sbtVersion(v => "com.github.siasia" %% "xsbt-web-plugin" % (v+"-0.2.10"))

的替代品拥有这三个文件足以配置 sbt。
当然,您可以通过调用 container:start 来运行您的应用程序

While I'm using lift I don't need a maven at all, just SBT. So, it is very useful to read SBT Getting Started section. Also lift wiki contains some information. But be sure that you read material related to the proper SBT version. And finally, you can pay attention to my lift project template on github.
Good Luck with Lift! It's awesome ;)

By following question in you comment I put here some common config from my projects.

So, that is ./project/build.scala as alternative to ./build.sbt

import sbt._
import Keys._
import com.github.siasia._
import PluginKeys._
import WebPlugin._
import WebappPlugin._

object LiftProjectBuild extends Build {
  override lazy val settings = super.settings ++ buildSettings

  lazy val buildSettings = Seq(
    organization := "com.yourorganization",
    version      := "0.1-SNAPSHOT",
    scalaVersion := "2.9.1")

  def yourWebSettings = webSettings ++ Seq(
    // If you are using jrebel
    scanDirectories in Compile := Nil
    )

  lazy val shade = Project(
    id = "project-name",
    base = file("."),
    settings = defaultSettings ++ yourWebSettings)

  lazy val defaultSettings = Defaults.defaultSettings ++ Seq(
    name := "project-name",
    resolvers ++= Seq(
      "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases", 
      "Java.net Maven2 Repository" at "http://download.java.net/maven/2/"),

    libraryDependencies ++= {
      val liftVersion = "2.4-M5"
      Seq(
        "net.liftweb" %% "lift-webkit" % liftVersion % "compile",
        "org.eclipse.jetty" % "jetty-webapp" % "7.5.4.v20111024" % "container",
        "org.squeryl" %% "squeryl" % "0.9.5-SNAPSHOT" % "compile",
        "ch.qos.logback" % "logback-classic" % "1.0.0" % "compile",
        "org.scalatest" %% "scalatest" % "1.6.1" % "test",
        "junit" % "junit" % "4.10" % "test")
    },

    // compile options
    scalacOptions ++= Seq("-encoding", "UTF-8", "-deprecation", "-unchecked"),
    javacOptions  ++= Seq("-Xlint:unchecked", "-Xlint:deprecation"),

    // show full stack traces
    testOptions in Test += Tests.Argument("-oF")
  )
}

./project/build.properties

#Project properties
sbt.version=0.11.1

./project/plugins.sbt

resolvers += Classpaths.typesafeResolver

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse" % "1.5.0")

libraryDependencies <+= sbtVersion(v => "com.github.siasia" %% "xsbt-web-plugin" % (v+"-0.2.10"))

Having these three files are enough to configure sbt.
And of course you can run your application by calling container:start

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文