SBT jetty webapp - files from src are not copied into target folder - can't view simple HTML files i placed there
well, I'm a newbie to both SBT and Scala, and I'm trying to create a simple web app. right now I'm struggling to get some simple HTML files to show on http://localhost:8080 my folder structure is as follows:
+clever_dropbox_server
|-+project
| |-+boot
| | |-...
| |-+plugins
| | |-build.sbt
| | |-...
| |-+target
| | |-...
|-+src
| |-+main
| | |-+scala
| | |-+webapps
| | | |-+cleverdropbox
| | | | |-+css
| | | | | |-style.css
| | | | |-+images
| | | | | |-...
| | | | |-+js
| | | | | |-...
| | | | |-+WEB-INF
| | | | | |-+classes
| | | | |-index.html
| | | | |-...
| |-+test
| | |-...
|-+target
| |-...
|-build.sbt
well, the build.sbt file under plugins, contain this:
//**********************
//* SBT Eclipse plugin *
//**********************
resolvers += {
val typesafeRepoUrl = new java.net.URL("http://repo.typesafe.com/typesafe/releases")
val pattern = Patterns(false, "[organisation]/[module]/[sbtversion]/[revision]/[type]s/[module](-[classifier])-[revision].[ext]")
Resolver.url("Typesafe Repository", typesafeRepoUrl)(pattern)
}
libraryDependencies <<= (libraryDependencies, sbtVersion) { (deps, version) =>
deps :+ ("com.typesafe.sbteclipse" %% "sbteclipse" % "1.3-RC2" extra("sbtversion" -> version))
}
//******************
//* SBT Web plugin *
//******************
resolvers += "Web plugin repo" at "http://siasia.github.com/maven2"
//Following means libraryDependencies += "com.github.siasia" %% "xsbt-web-plugin" % "0.1.1-<sbt version>""
libraryDependencies <+= sbtVersion(v => "com.github.siasia" %% "xsbt-web-plugin" % ("0.1.1-"+v))
so I'll have the ability to work on the project in eclipse, and for the web plugin support.
the build.sbt file in the main directory contains:
name := "clever_dropbox_server"
version := "0.1"
organization := "GilaDana"
scalaVersion := "2.9.0-1"
seq(webSettings: _*)
resolvers += "Java.net Maven2 Repository" at "http://download.java.net/maven/2/"
// Customize any further dependencies as desired
libraryDependencies ++= Seq(
"org.mortbay.jetty" % "jetty" % "6.1.22" % "jetty,test",
"org.eclipse.jetty" % "jetty-server" % "7.4.5.v20110725",// % "compile,jetty",
"org.eclipse.jetty" % "jetty-servlet" % "7.4.5.v20110725",// % "compile,jetty",
"javax.ws.rs" % "jsr311-api" % "1.1.1",
"com.sun.jersey" % "jersey-server" % "1.8",
"com.sun.jersey" % "jersey-core" % "1.8",
"com.sun.jersey" % "jersey-json" % "1.8",
"org.scala-tools.testing" % "specs_2.9.0" % "1.6.8" % "test", // For specs.org tests
"javax.servlet" % "servlet-api" % "2.5" % "provided->default"
)
my intentions are to have one simple jetty server that will serve for browser requests, and another embedde开发者_StackOverflow社区d jetty server to serve on a different port for clever_dropbox_client communication. both would have to deal with the same database, and same files folder, but other than that, there is no relation between the two.
(a few words on the project: I'm a student at BIU, and we got this project to create a dropbox-like application, only with a few modifications, like storing only one copy from each file on the server - even if it is shared by 2 different users under different names - to save server storage, or having a tagging system with M:N relation to the files in each account, etc'...)
the problem is, that when i execute jetty-run command from within the sbt console, i get 404 on localhost:8080/cleverdropbox
when i tried to figure out why, i discovered that sbt won't copy the HTML/JS/CSS files to the target folder.
I wouldn't want to copy the files manually, nor do i think i should (will sbt allow it? or are the files going to be deleted on the next reload/update/compile command?)
so, what am I doing wrong?
As stated in the comment, sbt
will look for your HTML files in the src/main/webapp
folder, without your trailing 's'.
精彩评论