Skip to content

crazydan/xsbt-web-plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Quick start

Add plugin to project/plugins.sbt:

addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "0.3.0")

For .sbt build definitions, inject the plugin settings in build.sbt:

seq(webSettings :_*)

For .scala build definitions, inject the plugin settings in Build.scala:

Project(..., settings = Project.defaultSettings ++ com.earldouglas.xsbtwebplugin.WebPlugin.webSettings)

Include Jetty in the container classpath:

libraryDependencies += "org.mortbay.jetty" % "jetty" % "6.1.22" % "container"

Examples

For a basic project template and walkthrough, see the xwp-template project.

There are also several examples in the sbt-test directory.

Configuration

Plugin keys are located in com.earldouglas.xsbtwebplugin.PluginKeys

Container settings

port in container.Configuration := 8081

ssl in container.Configuration := Some(ssl_port, "keystore_path", "keystore_password", "key_password")

customConfiguration in container.Configuration := true

configurationFiles in container.Configuration := Seq(file("jetty.xml"))

configurationXml in container.Configuration := <xml />

Web application settings

webappResources in Compile <+= (sourceDirectory in Runtime)(sd => sd / "static")

scanDirectories in Compile += file("lib")

scanInterval in Compile := 0

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

fullClasspath in Runtime in packageWar <+= baseDirectory.map(bd => bd / "extras")

classesAsJar in Compile := true

Content

Web application content belongs in the src/main/webapp directory. For example, web.xml should be placed in src/main/webapp/WEB-INF/web.xml.

Commands

To start a web application, use container:start:

> container:start
[info] jetty-7.3.0.v20110203
[info] NO JSP Support for /, did not find org.apache.jasper.servlet.JspServlet
[info] started o.e.j.w.WebAppContext{/,[file:/home/siasia/projects/xsbt-web-plugin/src/main/webapp/]}
[info] Started SelectChannelConnector@0.0.0.0:8080

The application is now accesible on localhost, port 8080: http://localhost:8080

To stop a running web application, use container:stop:

> container:stop
[info] stopped o.e.j.w.WebAppContext{/,[file:/home/siasia/projects/xsbt-web-plugin/src/main/webapp/]}

To reload a running web application, use container:reload <context-path>:

> container:reload /

To automatically reload a web application when source code is changed, use ~;container:start; container:reload <context-path>:

> ~;container:start; container:reload /

To build a WAR package, use package

More information

See the wiki

Changelog

0.3.0

  • Classes and resources can be packaged as a JAR file under WEB_INF/lib

0.2.13

  • Cusomizable classpath in the webapp package
  • Tomcat baseDir uses a temporary directory
  • Code cleanup/simplification

0.2.12

  • Resources are copied in the same order that the JVM resolves resources
  • Tomcat 7 is supported as a container
  • Versioning follows the common SBT plugin pattern
  • ssl is a more configurable TaskKey

License

This software is distributed under modified 3-clause BSD license. See LICENSE for more information.

About

An sbt plugin for building Scala Web applications

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published