How to add Poi Scala library to Play project? - sbt

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

Related

sbt: publishing plugin to and resolving from local repo

I am trying to publish an sbt plugin to a local file repo. In the plugin's build.sbt I have:
publishTo := Some(Resolver.file("localtrix", file("/Users/jast/repo/localtrix")))
I run the publish task and it gets published fine to
/Users/jast/repo/localtrix/org/me/sbt-plugin_2.12_1.0/1.2.3
In another project, I want to resolve this plugin. in project/plugins.sbt I have:
resolvers += Resolver.file("localtrix", file("/Users/jast/repo/localtrix"))
addSbtPlugin("org.me" % "sbt-plugin" % "1.2.3")
I try to run sbt in the this project and I get:
[info] Updating ProjectRef(uri("file:/Users/jast/playspace/untitled38/project/"), "untitled38-build")...
[warn] module not found: org.me#sbt-plugin;1.2.3
[warn] ==== typesafe-ivy-releases: tried
[warn] https://repo.typesafe.com/typesafe/ivy-releases/org.me/sbt-plugin/scala_2.12/sbt_1.0/1.2.3/ivys/ivy.xml
[warn] ==== sbt-plugin-releases: tried
[warn] https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.me/sbt-plugin/scala_2.12/sbt_1.0/1.2.3/ivys/ivy.xml/2017.2+4-3037ba82+20180314-1919/ivys/ivy.xml
[warn] ==== local: tried
[warn] /Users/jast/.ivy2/local/org.me/sbt-plugin/scala_2.12/sbt_1.0/1.2.3/ivys/ivy.xml
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/org/me/sbt-plugin_2.12_1.0/1.2.3/sbt-plugin-1.2.3.pom
[warn] ==== local-preloaded-ivy: tried
[warn] /Users/jast/.sbt/preloaded/org.me/sbt-plugin/scala_2.12/sbt_1.0/1.2.3/ivys/ivy.xml
[warn] ==== local-preloaded: tried
[warn] file:////Users/jast/.sbt/preloaded/org/me/sbt-plugin_2.12_1.0/1.2.3/sbt-plugin-1.2.3.pom
[warn] ==== localtrix: tried
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.me#sbt-plugin;1.2.3: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
So how can I publish to a local repo it in a way that also gets resolved correctly?
Note: publishLocal and resolving from .ivy2/local works, but I want to be able to publish to a repo that I can copy to another machine without messing with that directory.
sbt plugins by default are published ivy-style, so you when you refer to your local repository, use Resolver.ivyStylePatterns. To publish:
publishTo := Some(Resolver.file("localtrix", file("/Users/jast/repo/localtrix"))(Resolver.ivyStylePatterns))
And to resolve:
resolvers += Resolver.file("localtrix", file("/Users/jast/repo/localtrix"))(Resolver.ivyStylePatterns)
addSbtPlugin("org.me" % "sbt-plugin" % "1.2.3")
Alternatively you can set publishMavenStyle := true for the plugin, but I see that you already figured that out.
You missed scala version in name. And you have also strange suffix in plugin name _1.0 in your published artifact, so just fixing scala version could be not enough.
This should work.
addSbtPlugin("org.me" % "sbt-plugin_2.12_1.0" % "1.2.3")
If you find out where came this suffix _1.0 from, fix on scala version should help:
addSbtPlugin("org.me" %% "sbt-plugin" % "1.2.3")
Update after comment
Ok, thanks, I did not know that for plugins it works differently.
But try to define resolver differently for resolvers (works for me):
resolvers += "localtrix" at "file:///Users/jast/repo/localtrix"
addSbtPlugin("org.me" % "sbt-plugin" % "1.2.3")

Minimal sbt-web pipeline without Play

I'm using spray to create a single page app, and cannot get sbt-web to process any of my inputs. I started with WebJars, because, https://github.com/sbt/sbt-web/blob/master/README.md says:
One last thing regarding the public and public-test folders... any WebJar depended on by the project will be automatically extracted into these folders e.g. target/web/public/lib/jquery/jquery.js.
However, I see no such "web" folder in the target folder. I thought maybe WebJars was too complicated of an example to start with, so I instead added a jquery.js file to the root of the asset folder, and set up sbt-uglify to do some processing on it. Yet, still, I see no evidence that SbtWeb is working. I've run sbt --debug clean run and grepped the output for any output from SbtWeb or Uglify, but no errors or warnings and can't find anything wrt SbtWeb or Uglify. Just acknowledgement that it seems to "deduce" the plugins:
[debug] deducing auto plugins based on known facts [debug] :: sorting:: found:
...
[debug] :: sorted deduced result: List(sbt.plugins.CorePlugin, com.typesafe.sbt.web.SbtWeb, com.typesafe.sbt.jse.SbtJsEngine, net.ground5hark.sbt.concat.SbtConcat, sbt.plugins.IvyPlugin, com.typesafe.sbt.jse.SbtJsTask, sbt.plugins.JvmPlugin, com.typesafe.sbt.uglify.SbtUglify, sbt.plugins.JUnitXmlReportPlugin)
Here is my directory structure:
./build.sbt
./project/plugins.sbt
./src/main/assets/js/jquery.js
./src/main/resources/html/uikit/login.html
./src/main/scala/Boot.scala
./src/main/scala/main.scala
Here is my project/plugins.sbt:
resolvers += Resolver.sonatypeRepo("releases")
addSbtPlugin("com.typesafe.sbt" % "sbt-web" % "1.0.2")
addSbtPlugin("net.ground5hark.sbt" % "sbt-concat" % "0.1.8")
addSbtPlugin("com.typesafe.sbt" % "sbt-uglify" % "1.0.3")
Here is my ./build.sbt:
organization := "com.test123.spray"
version := "0.1"
scalaVersion := "2.11.6"
scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8")
libraryDependencies ++= {
val akkaV = "2.3.9"
val sprayV = "1.3.3"
Seq(
"io.spray" %% "spray-can" % sprayV,
"io.spray" %% "spray-routing" % sprayV,
"io.spray" %% "spray-testkit" % sprayV % "test",
"com.typesafe.akka" %% "akka-actor" % akkaV,
"com.typesafe.akka" %% "akka-testkit" % akkaV % "test",
// client side dependencies
"org.webjars" % "jquery" % "2.1.4",
"org.webjars" % "uikit" % "2.24.2"
)
}
lazy val root = (project.in(file("."))).enablePlugins(SbtWeb)
pipelineStages := Seq(uglify)
includeFilter in uglify := GlobFilter("js/*.js")
Here is what the root of my ./target folder looks like:
resolution-cache/
scala-2.11/
streams/
No ./target/web folder. Any ideas why?
References:
https://github.com/sbt/sbt-web/blob/master/README.md
http://mariussoutier.com/blog/2014/12/07/understanding-sbt-sbt-web-settings/
That'll learn me. I was using an old version of sbt-web. When I update it to the latest, it works as expected.
The lesson is not to copy/paste snippets like this:
addSbtPlugin("com.typesafe.sbt" % "sbt-web" % "1.0.2")
from the web. But, rather to find the latest version, manually, by one of the following methods:
If the GitHub (et al) page has a "Build Passing" badge, click on it to navigate to the build server where the latest versions are listed.
Look at the branches in GitHub
See if you can navigate to the repository for the dependency, such as Maven Central, and browse there. I didn't have luck with this one. The problem I had is that I knew it wasn't on Maven, and didn't know where else to look.
Plug in some bogus version in SBT, and look at the output for where SBT tried to look and failed:
[warn] module not found: com.typesafe.sbt#sbt-web;3.1.2
[warn] ==== typesafe-ivy-releases: tried
[warn] http://repo.typesafe.com/typesafe/ivy-releases/com.typesafe.sbt/sbt-web/scala_2.10/sbt_0.13/3.1.2/ivys/ivy.xml
[warn] ==== sbt-plugin-releases: tried
[warn] http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/com.typesafe.sbt/sbt-web/scala_2.10/sbt_0.13/3.1.2/ivys/ivy.xml
I'm positive there are better ways to find the latest versions of things that I'm just unaware of. For those more experienced than me please comment with a better way.

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.

Why can't SBT find the Play 2.1 plugin?

In my plugins.sbt file, I have
scalaVersion := "2.10.0"
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
addSbtPlugin("play" % "sbt-plugin" % "2.1")
When I try run sbt I get, among other things
[warn] ==== Typesafe repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/play/sbt-plugin_2.10_0.12/2.1/sbt- plugin-2.1.pom
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/play/sbt-plugin_2.10_0.12/2.1/sbt-plugin-2.1.pom
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: play#sbt-plugin;2.1: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] play:sbt-plugin:2.1 (sbtVersion=0.12, scalaVersion=2.10)
[warn]
sbt.ResolveException: unresolved dependency: play#sbt-plugin;2.1: not found
Why can't SBT find the plugin? I've also tried addSbtPlugin("play" % "sbt-plugin" % "2.1-RC1") with similar results.
The problem was including the scalaVersion setting inside the plugins.sbt file. This causes sbt to search for sbt-plugin_2.10.0_0.12 in the repositories when it should actually search for sbt-plugin_2.9.2_0.12.
I'm not sure about the semantics behind specifying the scalaVersion in the plugins.sbt file, but maybe it's declaring the Scala version that SBT is running on.
Here is a link to the Play 2.1 sbt-plugin files: http://repo.typesafe.com/typesafe/simple/ivy-releases/play/sbt-plugin/scala_2.9.2/sbt_0.12/2.1-RC1/srcs/
As per the documentation,
Add this in your project/plugins.sbt:
addSbtPlugin("play" % "sbt-plugin" % "2.1.0")
Change the project/build.properties
sbt.version=0.12.2

SBT, Jetty and Servlet 3.0

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")
)

Resources