2012-10-22 27 views
1

我试图在使用sbt-web-plugin(用于运行container:start)时为jetty创建自定义配置。有two container settings允许指定自定义码头xml配置:configurationFilesconfigurationXml(当customConfiguration为true时)。sbt-web-plugin:使用configurationXml指定类路径为码头

但是,这完全覆盖了由sbt-web-plugin完成的jetty的内部配置,因此自定义配置应完全配置jetty。如果没有指定classpath到项目编译的.class文件和依赖关系,它将不起作用。

我试图做这样的事情:

configurationXml in container.Configuration <<= fullClasspath (
    <Configure id="Server" class="org.eclipse.jetty.server.Server"> 
    ... 
    <Set name="handler"> 
     <New class="org.eclipse.jetty.webapp.WebAppContext"> 
     <Set name="resourceBase"><SystemProperty name="jetty.home" default="."/>/src/main/webapp</Set> 
     <Set name="descriptor"><SystemProperty name="jetty.home" default="."/>/src/main/webapp/WEB-INF/web.xml</Set> 
     <Set name="contextPath">/</Set> 
     <Set name="extraClasspath">{/* classpath should be here */}</Set> 
     </New> 
    </Set> 
    ... 
    </Configure> 
) 

似乎这configurationXmlfullClasspath直接依赖是不可能的,因为configurationXml is SettingKeyfullClasspath is TaskKey

Tasks with dependencies

的实际重要性这是因为您不能将任务作为非任务设置的依赖关系。

是否可以包含fullClasspath设置configurationXml参数?

如果没有,是否仍然可以将自定义配置设置添加到在container:start上调用的jetty开发服务器?

回答

2

您可以只WebAppContext使用env设置自定义:

env in Compile := Some(file(".")/"jetty-env.xml" asFile) 

例如,请考虑以下的的myproject /码头-env.xml

<Configure class="org.eclipse.jetty.webapp.WebAppContext"> 
    <Set name="contextPath">/custom</Set> 
</Configure> 

这将部署webapp下的上下文路径/custom,但不会更改潜在的Server的任何配置。

+0

此“env”设置在哪里记录? – aij

+0

你可以在[文档0.9版本]找到它(https://github.com/earldouglas/xsbt-web-plugin/blob/master/docs/0.9.md#web-application-settings),但这很漂亮旧的和不赞成的。我会考虑更新2.1。 – earldouglas