My favorites | Sign in
Project Home Downloads Wiki Issues
Search
for

sbt has moved

sbt has now completely moved to GitHub.

See https://github.com/harrah/xsbt/wiki.

Getting Started

WebstartExample  
Updated Jul 27, 2011 by dmhar...@gmail.com

sbt has moved

sbt has now completely moved to GitHub.

See https://github.com/harrah/xsbt/wiki.

import sbt._

// A project that defines a webstart application in the 'app' directory
// and a web project to serve it in the 'web' directory.
class WebstartTest(info: ProjectInfo) extends ParentProject(info)
{
  val app = project("app", "Webstart Test Application", new ApplicationProject(_))
  val web = project("web", "Webstart Test Server", new ServerProject(_), app)

  // The web project.  Running 'jetty-run' on this project will serve the
  // webstart application from http://localhost:8080 using jetty.
  class ServerProject(info: ProjectInfo) extends DefaultWebProject(info)
  {
    // Jetty is only need for the 'test' classpath
    val jetty6 = "org.mortbay.jetty" % "jetty" % "6.1.14" % "test"
    // We need the packaged jar from the application project
    override def prepareWebappAction = super.prepareWebappAction dependsOn app.`package`
    // Include the webstart files directly in the web app root directory.
    override def extraWebappFiles = (app.webstartOutputDirectory ##) ** AllPassFilter
  }
  class ApplicationProject(info: ProjectInfo) extends DefaultWebstartProject(info)
  {
    import SignJar._
    override def webstartSignConfiguration = Some(new SignConfiguration("mark", storePassword("fakepassword") :: Nil))
    //override def webstartPack200 = false // uncomment to disable pack200 compression, which is enabled by default
    //override def webstartGzip = false// uncomment to disable gzip compression, which is enabled by default

    def jnlpXML(libraries: Seq[WebstartJarResource]) =
      <jnlp spec="1.0+" codebase="http://localhost:8080/" href={artifactBaseName + ".jnlp"}>
        <information>
          <title>Webstart Test</title>
          <vendor>Vendor</vendor>
          <description>Webstart test</description>
          <offline-allowed />
        </information>
        <resources>
          <j2se version="1.5+" />
          { defaultElements(libraries) }
        </resources>
        <application-desc main-class="test.Main" />
      </jnlp>
  }
}

To request full access to the client machine, use:

  <security>
    <all-permissions/>
  </security> 

after the information tag.

For full details, see the webstart guide and the JNLP File Syntax page.

Comment by han.l...@gmail.com, Apr 12, 2010

Since the example includes jar signing, it might be a good idea to add a security element to the jnlp element as well:

<security> <all-permissions/> </security>

(It took a while for me to find out why the example didn't work.)

Cheers, /Hanna

Comment by project member dmhar...@gmail.com, Apr 12, 2010

Added it along with some links.

Thanks, Mark

Comment by dh.evolu...@gmail.com, Jun 17, 2011

It would make more sense if the jnlp configuration is on the web side and not the application side, since you can feasibly have multiple web apps configuring the same app but with different settings.

Powered by Google Project Hosting