SBT, Jetty and Servlet 3.0 - servlets

I have a really tiny problem.
I have the following build.sbt file:
name := "Tueet"
libraryDependencies += "org.eclipse.jetty" % "jetty-webapp" % "8.1.2.v20120308"
After invoking sbt update, I get the following:
[info] Set current project to Tueet (in build file:/C:/dev/tueet/)
[info] Updating {file:/C:/dev/tueet/}default-d5e982...
[info] Resolving org.scala-lang#scala-library;2.9.1 ...
[info] Resolving org.eclipse.jetty#jetty-webapp;8.1.2.v20120308 ...
[info] Resolving org.eclipse.jetty#jetty-xml;8.1.2.v20120308 ...
[info] Resolving org.eclipse.jetty#jetty-util;8.1.2.v20120308 ...
[info] Resolving org.eclipse.jetty#jetty-servlet;8.1.2.v20120308 ...
[info] Resolving org.eclipse.jetty#jetty-security;8.1.2.v20120308 ...
[info] Resolving org.eclipse.jetty#jetty-server;8.1.2.v20120308 ...
[info] Resolving org.eclipse.jetty.orbit#javax.servlet;3.0.0.v201112011016 ...
[info] Resolving org.eclipse.jetty#jetty-continuation;8.1.2.v20120308 ...
[info] Resolving org.eclipse.jetty#jetty-http;8.1.2.v20120308 ...
[info] Resolving org.eclipse.jetty#jetty-io;8.1.2.v20120308 ...
[warn] [NOT FOUND ] org.eclipse.jetty.orbit#javax.servlet;3.0.0.v201112011016!javax.servlet.orbit (603ms)
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/org/eclipse/jetty/orbit/javax.servlet/3.0.0.v201112011016/javax.servlet-3.0.0.v201112011016.orbit
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: FAILED DOWNLOADS ::
[warn] :: ^ see resolution messages for details ^ ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.eclipse.jetty.orbit#javax.servlet;3.0.0.v201112011016!javax.servlet.orbit
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[error] {file:/C:/dev/tueet/}default-d5e982/*:update: sbt.ResolveException: download failed: org.eclipse.jetty.orbit#javax.servlet;3.0.0.v201112011016!javax.servlet.orbit
[error] Total time: 1 s, completed 2012-03-27 14:33:34
This is silly, as it works in Maven no prob. I found out that this is because Orbit does something with packaging (they set it to orbit apparently).
I tried doing exclude("org.eclipse.jetty.orbit", "javax.servlet") but nothing happened and it still needed that dependency.
I couldn't find any info on how to actually fix this, maybe someone will help me here :)
Update: the presented bug provides a workaround, so to fix this problem I actually changed build.sbt to
name := "Tueet"
libraryDependencies += "org.eclipse.jetty" % "jetty-server" % "8.1.2.v20120308"
ivyXML :=
<dependency org="org.eclipse.jetty.orbit" name="javax.servlet" rev="3.0.0.v201112011016">
<artifact name="javax.servlet" type="orbit" ext="jar"/>
</dependency>

See this bug: https://jira.codehaus.org/browse/JETTY-1493
The crux of the issue is that ivy doesn't support the orbit extension and needs to map the orbit packaging type to jar. Not sure if you're using ivy or not there, but the fundamental reason is the same, you can see that by looking at the url it is downloading from maven central.
This bug has a bit more of the background on the reason we switched to these dependencies in the first place.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=371954

I found a workaround. Further information can be found here: SBT, Jetty and Servlet 3.0.
classpathTypes ~= (_ + "orbit")
libraryDependencies ++= Seq(
"org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "container" artifacts (Artifact("javax.servlet", "jar", "jar")
)
)
libraryDependencies ++= Seq(
"org.eclipse.jetty" % "jetty-webapp" % "8.1.4.v20120524" % "container" artifacts (Artifact("jetty-webapp", "jar", "jar"))
)

with sbt 0.12+ (from:https://github.com/sbt/sbt/issues/499)
libraryDependencies ++= Seq(
"org.eclipse.jetty" % "jetty-webapp" % "8.1.7.v20120910" % "container",
"org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "container" artifacts Artifact("javax.servlet", "jar", "jar")
)

Related

Unable to resolve dependencies in SBT - Have I missed a fundamental piece of config somewhere?

I have installed sbt 0.13.8 on a new machine (running osx) via brew install sbt, and now I cannot for the life of me manage to successfully resolve any dependencies from any repositories other than the defaults.
To illustrate this, I have created a very simple project, with the file structure as follows:
example/
build.properties
build.sbt
The contents of build.properties is simply:
sbt.version=0.13.8
And the contents of build.sbt is:
lazy val root = (project in file(".")).
settings(
scalaVersion := "2.11.4",
libraryDependencies += "com.twitter.common.zookeeper" % "server-set" % "1.0.83",
resolvers += "Twitter Repository" at "http://maven.twttr.com"
)
That version of the dependency definitely exists in that repository, at http://maven.twttr.com/com/twitter/common/zookeeper/server-set/1.0.83/, yet when I attempt to compile or update the project it fails, and running last has just left me scratching my head:
$ sbt
[info] Set current project to root (in build file:/Users/rb/Workspace/example/)
> update
[info] Updating {file:/Users/rb/Workspace/example/}root...
[info] Resolving com.twitter.common.zookeeper#server-set;1.0.83 ...
[warn] module not found: com.twitter.common.zookeeper#server-set;1.0.83
[warn] ==== local: tried
[warn] /Users/rb/.ivy2/local/com.twitter.common.zookeeper/server-set/1.0.83/ivys/ivy.xml
[warn] ==== typesafe-ivy-releases: tried
[warn] https://repo.typesafe.com/typesafe/ivy-releases/com.twitter.common.zookeeper/server-set/1.0.83/ivys/ivy.xml
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/com/twitter/common/zookeeper/server-set/1.0.83/server-set-1.0.83.pom
[info] Resolving jline#jline;2.12 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.twitter.common.zookeeper#server-set;1.0.83: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] com.twitter.common.zookeeper:server-set:1.0.83 (/Users/rb/Workspace/exampl/build.sbt#L4)
[warn] +- root:root_2.11:0.1-SNAPSHOT
...
> last
[info] Updating {file:/Users/rb/Workspace/example/}root...
[debug] Other repositories:
[debug] Default repositories:
[debug] Using inline dependencies specified in Scala.
...
> inspect resolvers
[info] Setting: scala.collection.Seq[sbt.Resolver] = List(Twitter Repository: http://maven.twttr.com)
[info] Description:
[info] The user-defined additional resolvers for automatically managed dependencies.
[info] Provided by:
[info] {file:/Users/rb/Workspace/example/}root/*:resolvers
[info] Defined at:
[info] /Users/rb/Workspace/example/build.sbt:5
[info] Reverse dependencies:
[info] *:externalResolvers
[info] Delegates:
[info] *:resolvers
[info] {.}/*:resolvers
[info] */*:resolvers
[info] Related:
[info] */*:resolvers
> show fullResolvers
[info] ArrayBuffer(Raw(ProjectResolver(inter-project, mapped: )), FileRepository(local,FileConfiguration(true,None),Patterns(ivyPatterns=List(${ivy.home}/local/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]), artifactPatterns=List(${ivy.home}/local/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]), isMavenCompatible=false, descriptorOptional=false, skipConsistencyCheck=false)), URLRepository(typesafe-ivy-releases,Patterns(ivyPatterns=List(https://repo.typesafe.com/typesafe/ivy-releases/[organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext]), artifactPatterns=List(https://repo.typesafe.com/typesafe/ivy-releases/[organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext]), isMavenCompatible=false, descriptorOptional=false, skipConsistencyCheck=false)), public: https://repo1.maven.org/maven2/)
[success] Total time: 0 s, completed 28-May-2015 10:50:23
As you can see, when inspecting the resolvers the twitter repository is there, but when running update sbt isn't even trying to use it (and it doesn't appear at all in the rather empty list of repositories output by last).
I can't find any clue as to what I'm doing wrong in the docs or update notes. Have I missed a fundamental config file or parameter somewhere whilst initially installing sbt?
Edit: I have managed to work around this by appending to fullResolvers rather than resolvers as follows:
lazy val root = (project in file(".")).
settings(
scalaVersion := "2.11.4",
libraryDependencies += "com.twitter.common.zookeeper" % "server-set" % "1.0.83",
fullResolvers += "Twitter Repository" at "http://maven.twttr.com"
)
Works for me on OS X, without having to use fullResolvers.
I am not sure if this is related but your build.properties file should be under the project directory.
This is how your project structure should look like:
.
├── build.sbt
└── project
└── build.properties

Why does the build insist on looking for Scala 2.10 version of dependencies?

I have a root build.sbt file that looks like this:
organization := "com.acme.foo"
name := "foo-parent"
version := "1.0-SNAPSHOT"
scalaVersion := "2.11.2"
scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8")
resolvers ++= Seq(
"spray repo" at "http://repo.spray.io/"
)
lazy val root = project.dependsOn(rest,backend)
lazy val rest = project
lazy val backend = project.dependsOn(rest).settings(mainClass in (Compile, run) := Some("com.acme.foo.Main"), fork in run := true)
run in Compile <<= (run in Compile in backend)
In both the backend and rest modules the scalaVersion is also set to 2.11.2, however I keep getting this error when I try to compile from the root:
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.acme.foo#rest_2.10;1.0-SNAPSHOT: not found
[warn] :: com.acme#foo_2.10;1.0-SNAPSHOT: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
Why does it insist on looking for _2.10 versions of my modules?
I couldn't tell you why this worked, but I followed this answer, and it solved my problem
Someone had asked me in the comments what the result of executing sbt scalaVersion was. Originally it was:
[info] backend/*:scalaVersion
[info] 2.11.2
[info] rest/*:scalaVersion
[info] 2.11.2
[info] root/*:scalaVersion
[info] 2.10.3
[info] foo/*:scalaVersion
[info] 2.11.2
After taking the advice from the other SO post by replacing scalaVersion := "2.11.2" in my root's build.sbt file with:
scalaVersion in ThisBuild := "2.11.2"
I then got the correct result from sbt scalaVersion, and my compile worked fine:
[info] backend/*:scalaVersion
[info] 2.11.2
[info] rest/*:scalaVersion
[info] 2.11.2
[info] root/*:scalaVersion
[info] 2.11.2
[info] foo/*:scalaVersion
[info] 2.11.2
SBT just baffles me sometimes... but I must confess I haven't invested a lot of time in understanding it.

How to keep library dependencies updated to Scala version?

I am compiling my project with sbt and am getting an UNRESOLVED DEPENDENCIES error.
The fact is that I fetched the example I use (a hello world program) from an online blog, that uses scalaVersion := "2.10.0" as shown below. I am using 2.11.2.
How do I update the library dependencies (in the build.sbt) to the latest version of Scala, specifically the revision part?
build.sbt
name := "Hello Test #1"
version := "1.0"
scalaVersion := "2.10.0"
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
libraryDependencies += "com.typesafe.akka" % "akka-actor_2.10" % "2.2-M1"
The error:
[info] Resolving com.typesafe.akka#akka-actor_2.11.2;2.2-M1 ...
[warn] module not found: com.typesafe.akka#akka-actor_2.11.2;2.2-M1
[warn] ==== local: tried
[warn] /home/plard/.ivy2/local/com.typesafe.akka/akka-actor_2.11.2/2.2-M1/ivys/ivy.xml
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/com/typesafe/akka/akka-actor_2.11.2/2.2-M1/akka-actor_2.11.2-2.2-M1.pom
[warn] ==== Typesafe Repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/com/typesafe/akka/akka-actor_2.11.2/2.2-M1/akka-actor_2.11.2-2.2-M1.pom
[info] Resolving jline#jline;2.12 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.typesafe.akka#akka-actor_2.11.2;2.2-M1: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: com.typesafe.akka#akka-actor_2.11.2;2.2-M1: not found
[error] Total time: 1 s, completed Aug 11, 2014 10:32:11 AM
name := "Hello Test #1"
version := "1.0"
scalaVersion := "2.11.2"
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.3.4"
This should do it. Note the %% and no version specified for the Akka artifact. Doing so, SBT will automatically append your Scala version to the artifact. See docs for more details.

How to set up sbt-assembly to include jars with runtime scope?

How to set up sbt-assembly to include jars with runtime scope? What's the rationale for not doing it by default?
This is now being discussed under sbt/sbt-assembly#120.
sbt-assembly is intended to wire full classpath from Runtime configuration. And it's coded as follows:
fullClasspath in assembly <<= fullClasspath or (fullClasspath in Runtime),
For Spark, for whatever reason fullClasspath is wired, so that's likely interfering. The reason sbt-assembly included fullClasspath I think is now historical, so I might get rid of "fullClasspath or" part. As noted in the issue, the current workaround is likely:
fullClasspath in assembly := (fullClasspath in Runtime).value
FYI for those who learn sbt the above sbt-0.13+ format with := corresponds to the older pre-sbt-0.13 format with := as follows:
fullClasspath in assembly <<= (fullClasspath in Runtime)
My tests show that the plugin does include dependencies with runtime scope as evidenced with the following example.
project/plugins.sbt
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")
build.sbt
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.1.2" % "runtime"
assemblySettings
This is a sample session:
> about
[info] This is sbt 0.13.6-SNAPSHOT
[info] The current project is {file:/C:/dev/sandbox/runtime-assembly/}runtime-assembly 0.1-SNAPSHOT
[info] The current project is built against Scala 2.10.4
[info] Available Plugins: sbt.plugins.IvyPlugin, sbt.plugins.JvmPlugin, sbt.plugins.CorePlugin, sbt.plugins.JUnitXmlReportPlugin, org.sbtidea.SbtIdeaPlugin, de.johoop.jacoco4sbt.JacocoPlugin, com.timushev.sbt.updates.UpdatesPlugin, sbtassembly.Plugin
[info] sbt, sbt plugins, and build definitions are using Scala 2.10.4
> assembly
[info] Updating {file:/C:/dev/sandbox/runtime-assembly/}runtime-assembly...
[info] Resolving org.jacoco#org.jacoco.agent;0.6.4.201312101107 ...
[info] downloading http://repo1.maven.org/maven2/ch/qos/logback/logback-classic/1.1.2/logback-classic-1.1.2.jar ...
[info] [SUCCESSFUL ] ch.qos.logback#logback-classic;1.1.2!logback-classic.jar (1122ms)
[info] downloading http://repo1.maven.org/maven2/ch/qos/logback/logback-core/1.1.2/logback-core-1.1.2.jar ...
[info] [SUCCESSFUL ] ch.qos.logback#logback-core;1.1.2!logback-core.jar (1313ms)
[info] Done updating.
[info] Including: slf4j-api-1.7.6.jar
[info] Including: logback-classic-1.1.2.jar
[info] Including: logback-core-1.1.2.jar
[info] Including: scala-library.jar
[info] Checking every *.class/*.jar file's SHA-1.
[info] Merging files...
[warn] Merging 'META-INF\MANIFEST.MF' with strategy 'discard'
[warn] Strategy 'discard' was applied to a file
[info] SHA-1: 0f520cdfc30de8ced8408a3c25b326b3ff5afda8
[info] Packaging C:\dev\sandbox\runtime-assembly\target\scala-2.10\runtime-assembly-assembly-0.1-SNAPSHOT.jar ...
[info] Done packaging.
Jar verification:
/cygdrive/c/dev/sandbox/runtime-assembly
$ jar -tf target/scala-2.10/runtime-assembly-assembly-0.1-SNAPSHOT.jar | grep logback | wc -l
592

How to add Poi Scala library to Play project?

I want use Poi Scala library in the my Play framework project, And I added Poi Scala library to libraryDependencies in build.sbt:
libraryDependencies ++= Seq(
jdbc,
anorm,
cache,
"info.folone" %% "poi-scala" % "0.11",
"com.typesafe.slick" %% "slick" % "2.0.0-RC1",
"com.typesafe.slick" %% "slick-testkit" % "2.0.0-RC1" % "test",
"com.typesafe.play" %% "play-slick" % "0.5.0.8",
"com.novocode" % "junit-interface" % "0.10" % "test",
"ch.qos.logback" % "logback-classic" % "0.9.28" % "test",
"postgresql" % "postgresql" % "9.1-901.jdbc4",
"postgresql" % "postgresql" % "9.1-901.jdbc4" % "test",
"org.webjars" %% "webjars-play" % "2.2.0",
"org.webjars" % "bootstrap" % "2.3.1"
)
by instruction Poi Scala
but, when I do command "play update" appear following error:
[warn] module not found: info.folone#poi-scala_2.10;0.11
[warn] ==== local: tried
[warn] c:\tools\play-2.2.1\repository\local\info.folone\poi-scala_2.10\0.11\iv
ys\ivy.xml
[warn] ==== Maven2 Local: tried
[warn] file:/C:/Users/boyfox/.m2/repository/info/folone/poi-scala_2.10/0.11/po
i-scala_2.10-0.11.pom
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/info/folone/poi-scala_2.10/0.11/poi-scala
_2.10-0.11.pom
[warn] ==== Typesafe Releases Repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/info/folone/poi-scala_2.10/0
.11/poi-scala_2.10-0.11.pom
Anybody know how to fix this problem?
Thanks in Advance!
#gourlaysama said:
It seems like the last version of poi-scala that was published was
0.9, see bintray (bintray.com/bintray/jcenter/…), sonatype (oss.sonatype.org/index.html#nexus-search;quick~folone), and maven
central (repo1.maven.org/maven2/info/folone/poi-scala_2.10). Maybe
this is an oversight, or maybe they moved to a different maven repo.
I'd recommend opening an issue at github.com/folone/poi.scala.
This is right, library is indeed not in maven repository. And I opened an issue at github.com/folone/poi.scala by recomendation of #gourlaysama :
Issue

Resources