如何改变"webapp"的位置? Scalatra应用程序的目录? [英] How can one change the location of the "webapp" directory for a Scalatra application?

查看:109
本文介绍了如何改变"webapp"的位置? Scalatra应用程序的目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,Scalatra希望"webapp"目录位于src/main/webapp.怎么将其更改为例如content/doc-root?

By default, Scalatra expects the "webapp" directory to be at src/main/webapp. How could that be changed to, e.g., content/doc-root?

sbt允许使用类似于以下内容的自定义默认目录:

sbt allows for customizing its default directories using something like the following:

scalaSource <<= (baseDirectory)(_ / "src")

所以我认为这只是知道要使用的正确配置密钥" ...

So I assume it's just a matter of knowing the right "configuration key" to use...

推荐答案

@Kelsey Gilmore-Innis 有正确的答案,但是由于它不被接受,所以我们将其分解,然后分解,分解.

@Kelsey Gilmore-Innis has the right answer, but since it's not accepted let's break it, break it, break it down.

首先,我假设您正在关注入门指南使用g8安装Scalatra.希望我刚得到的版本相同.

First, I'm assuming you're following Getting started guide to install Scalatra using g8. Hopefully the same version I just got.

g8模板所做的是建立一个使用 scalatra-sbt 0.3.2插件:

What that g8 template did was to set up an sbt 0.13 build which uses scalatra-sbt 0.3.2 plugin:

addSbtPlugin("org.scalatra.sbt" % "scalatra-sbt" % "0.3.2")

此插件内部使用 JamesEarlDouglas/xsbt-web-plugin 0.4.0至进行与Webapp相关的设置.

This plugin internally uses JamesEarlDouglas/xsbt-web-plugin 0.4.0 to do the webapp-related settings.

这就是xsbt-web-plugin变得重要的原因,即使您只想更改Scalatra的设置.您需要重新布线的设置称为webappResources in Compile.怎么运作的?

This is why xsbt-web-plugin becomes relevant even though you just want to change Scalatra's setting. The setting you need to rewire is called webappResources in Compile. How does that work?

要重新接线设置,请打开project/build.scala.添加

To rewire the setting, open project/build.scala. Add

import com.earldouglas.xsbtwebplugin.PluginKeys.webappResources

到导入子句.然后如下更改设置:

to the import clauses. Then change settings as follows:

  lazy val project = Project (
    "foo",
    file("."),
    settings = Defaults.defaultSettings ++ ScalatraPlugin.scalatraWithJRebel ++ scalateSettings ++ Seq(
      organization := Organization,
      name := Name,
      version := Version,
      scalaVersion := ScalaVersion,
      resolvers += Classpaths.typesafeReleases,
      webappResources in Compile := Seq(baseDirectory.value / "content" / "doc-root"),
      ...
    )
  )

现在将src/main/webapp移至content/doc-root,重新加载sbt,就应该这样.

Now move src/main/webapp to content/doc-root, reload sbt, and that should be it.

这篇关于如何改变"webapp"的位置? Scalatra应用程序的目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆