GithubHelp home page GithubHelp logo

xsbt-web-plugin's Introduction

Build Status

Quick start

Add plugin to project/plugins.sbt:

To use xsbt-web-plugin with sbt 0.12 or Scala 2.9.x, substitute version 0.5.0 below.

addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "0.7.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 (or Tomcat) on the container classpath:

Jetty:

libraryDependencies ++= Seq(
  "org.eclipse.jetty" % "jetty-webapp" % "9.1.0.v20131115" % "container",
  "org.eclipse.jetty" % "jetty-plus"   % "9.1.0.v20131115" % "container"
)

Tomcat:

libraryDependencies ++= Seq(
  "org.apache.tomcat.embed" % "tomcat-embed-core"         % "7.0.22" % "container",
  "org.apache.tomcat.embed" % "tomcat-embed-logging-juli" % "7.0.22" % "container",
  "org.apache.tomcat.embed" % "tomcat-embed-jasper"       % "7.0.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

host in container.Configuration := "192.168.1.4"

port in container.Configuration := 8080

ssl in container.Configuration := Some("192.168.1.4", 8443, "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 [email protected]: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. To change the output directory of the WAR file, modify its artifactPath:

artifactPath in (Compile, packageWar) ~= { defaultPath =>
  file("dist") / defaultPath.getName
}

Artifacts

.war file

To disable publishing of the .war file, add the setting:

packagedArtifacts <<= packagedArtifacts map { as => as.filter(_._1.`type` != "war") }

Note that package can still be used to create the .war file under the project target/ directory.

.jar file

To enable publishing of the project's .jar file, add the setting:

publishArtifact in (Compile, packageBin) := true

More information

See the wiki

License

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

xsbt-web-plugin's People

Contributors

earldouglas avatar aolshevskiy avatar cdow avatar davidharcombe avatar mdedetrich avatar ambisoft avatar bwkimmel avatar jannic avatar mtye avatar hjast avatar rladstaetter avatar ymasory avatar agjini avatar zvozin avatar

Watchers

James Cloos avatar Bùi Việt Thành avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.