SBT won't resolve fakehttpserver dependency because of bad commons pom file - scala

I'm trying to use this fake http server project in a sbt 0.11.0 based project. Unfortunately one of it's dependencies is giving the following error:
[error] public: bad organisation found in http://repo1.maven.org/maven2/org/apache/commons/commons-io/1.3.2/commons-io-1.3.2.pom: expected='org.apache.commons' found='commons-io'
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.apache.commons#commons-io;1.3.2: java.text.ParseException: inconsistent module descriptor file found in 'http://repo1.maven.org/maven2/org/apache/commons/commons-io/1.3.2/commons-io-1.3.2.pom': bad organisation: expected='org.apache.commons' found='commons-io';
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[error] {file:/home/project_location/}default-db401d/*:update: sbt.ResolveException: unresolved dependency: org.apache.commons#commons-io;1.3.2: java.text.ParseException: inconsistent module descriptor file found in 'http://repo1.maven.org/maven2/org/apache/commons/commons-io/1.3.2/commons-io-1.3.2.pom': bad organisation: expected='org.apache.commons' found='commons-io';
From what I can tell this can be worked around by asking that ivy not check the consistency of the pom files (Maven has this setting off by default). I can't work out how to turn this off in sbt though. I tried
ivyValidate := false
but this has no effect.
Am I on the right track with this setting and is it possible to turn this setting off?

You could try to exclude this dependency and include it manually :
"se.dannej" % "fakehttpserver" % "0.1.0" exclude("org.apache.commons", "commons-io")
"commons-io" % "commons-io" % "another version"
or even download the commons-io jar and push it in your lib directory.

Related

Sbt occurred an error because failed to install a dependency at first time though resolver was set correctly

I added resolvers definition in build.sbt to use geotools like below.
resolvers ++= Seq(
"Open Source Geospatial Foundation Repository" at "http://download.osgeo.org/webdav/geotools/"
)
I executed sbt update, it failed with an error.
[error] (*:update) sbt.ResolveException: download failed: javax.media#jai_core;1.1.3!jai_core.jar
I tried once, it was succeeded.
After I deleted ~/.ivy2, I tried it the same way and it was always reproduced on my environment. ;(
I want to know that why it was absolutely failed at first time and how can I succeed it at first time.
Ah, my environment is Scala 2.11.11, sbt 0.13.15, JDK8 in this question.
And I noticed that first time sbt update never look the repo which was defined in resolvers.
[warn] [NOT FOUND ] javax.media#jai_core;1.1.3!jai_core.jar (0ms)
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/javax/media/jai_core/1.1.3/jai_core-1.1.3.jar
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: FAILED DOWNLOADS ::
[warn] :: ^ see resolution messages for details ^ ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: javax.media#jai_core;1.1.3!jai_core.jar
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
I added jai_core directly to my dependencies and it worked for me:
// https://mvnrepository.com/artifact/javax.media/jai_core
libraryDependencies += "javax.media" % "jai_core" % "1.1.3"

Unresolved dependencies for np 0.2.0 with SBT 0.13?

Scala 2.10.2 and SBT 0.13
I'm trying to use the np plugin and added the following lines to ../0.13/np.sbt:
seq(npSettings:_*)
(NpKeys.defaults in (Compile, NpKeys.np)) ~= {
_.copy(org="me.lessis", version="0.1.0-SNAPSHOT")
}
and this to <home-directory>/.sbt/plugins.sbt
addSbtPlugin("me.lessis" % "np" % "0.2.0")
resolvers += Resolver.url("sbt-plugin-releases",url("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns)
When I execute sbt run I am getting :
[info] Updating {file:/home/Projects/helloSbt/}default-310e5b...
[info] Resolving me.lessis#np;0.2.0 ...
[warn] module not found: me.lessis#np;0.2.0
[warn] ==== local: tried
[warn] /home/.ivy2/local/me.lessis/np/scala_2.10/sbt_0.12/0.2.0/ivys/ivy.xml
[warn] ==== sbt-plugin-releases: tried
[warn] http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/me.lessis/np/scala_2.10/sbt_0.12/0.2.0/ivys/ivy.xml
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/me/lessis/np_2.10_0.12/0.2.0/np-0.2.0.pom
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: me.lessis#np;0.2.0: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] me.lessis:np:0.2.0 (sbtVersion=0.12, scalaVersion=2.10)
[warn]
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: me.lessis#np;0.2.0: not found
[error] Total time: 3 s, completed Feb 6, 2014 9:23:17 AM
What am I doing wrong ?
For scala 2.10 you have to use sbt 0.13. I tried with sbt 0.13
Open in browser link:
http://dl.bintray.com/sbt/sbt-plugin-releases/me.lessis/np/scala_2.10/
There is only:
sbt_0.13/
For scala 2.9.2 you need to use sbt 0.12
==========================
Update:
Remove global configuration from $HOME/.sbt (plugins.sbt). or make or action from fresh user account (new user never used sbt)
Create empty directory test
Go to test
Create directory project
Go to project
Create plugins.sbt with content as above in question
Go to test directory
run sbt test or other command
see output - me.lessis#np;0.2.0 should be downloaded
Use .sbt/0.13/plugins/plugins.sbt (note the 0.13/plugins in the path) or even better for quick scan of the plugins installed, use .sbt/0.13/plugins/np.sbt so it's clear from the file name(s) about the plugins.
Please also note that from the question it appears that you're using SBT 0.12:
me.lessis:np:0.2.0 (sbtVersion=0.12, scalaVersion=2.10)
Add project/build.properties under helloSbt with the following line to have 0.13 be in use:
sbt.version=0.13.1

Installing ensime in existing project cannot resolve dependency

I started an android project in scala recently, I'm an emacs nerd, and I wanted to use ensime in emacs instead of IntelliJ. Per the installation instructions, and this post:
Installing Ensime for Scala Development on emacs: sbt.ResolveException: unresolved dependency: org.ensime#ensime-sbtt-cmd;0.12: not found
my ~/.sbt/plugins/plugins.sbt looks like this:
resolvers += "Sonatype releases" at "https://oss.sonatype.org/content/repositories/snapshots"
addSbtPlugin("org.ensime" % "ensime-sbt-cmd" % "0.1.2")
and my project's project/plugins.sbt looks like this:
addSbtPlugin("org.scala-sbt" % "sbt-android" % "0.7.1-SNAPSHOT")
(though I don't think that's related).
When I run sbt, the output looks like the following:
[info] Loading global plugins from /Users/jmiles/.sbt/plugins
[info] Updating {file:/Users/jmiles/.sbt/plugins/}default-bdeac8...
[info] Resolving org.ensime#ensime-sbt-cmd;0.1.2 ...
[warn] module not found: org.ensime#ensime-sbt-cmd;0.1.2
[warn] ==== typesafe-ivy-releases: tried
[warn] http://repo.typesafe.com/typesafe/ivy-releases/org.ensime/ensime-sbt-cmd/scala_2.9.2/sbt_0.12/0.1.2/ivys/ivy.xml
[warn] ==== sbt-plugin-releases: tried
[warn] http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/org.ensime/ensime-sbt-cmd/scala_2.9.2/sbt_0.12/0.1.2/ivys/ivy.xml
[warn] ==== local: tried
[warn] /Users/jmiles/.ivy2/local/org.ensime/ensime-sbt-cmd/scala_2.9.2/sbt_0.12/0.1.2/ivys/ivy.xml
[warn] ==== Sonatype releases: tried
[warn] https://oss.sonatype.org/content/repositories/snapshots/org/ensime/ensime-sbt-cmd_2.9.2_0.12/0.1.2/ensime-sbt-cmd-0.1.2.pom
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/org/ensime/ensime-sbt-cmd_2.9.2_0.12/0.1.2/ensime-sbt-cmd-0.1.2.pom
[info] Resolving org.scala-sbt#precompiled-2_10_0-m7;0.12.1 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.ensime#ensime-sbt-cmd;0.1.2: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] org.ensime:ensime-sbt-cmd:0.1.2 (sbtVersion=0.12, scalaVersion=2.9.2)
[warn]
sbt.ResolveException: unresolved dependency: org.ensime#ensime-sbt-cmd;0.1.2: not found
at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:214)
at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:122)
at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:121)
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:114)
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:114)
at sbt.IvySbt$$anonfun$withIvy$1.apply(Ivy.scala:102)
at sbt.IvySbt.liftedTree1$1(Ivy.scala:49)
(etc.)
Any help?
I get this all the time with dependencies. While I have no explanation for it, here are the common patterns that recur over and over.
Often, the code given by the plugin/library developer is wrong. When I go to their maven repository the version they have listed doesn't exist in the repository. I just update it to the right version and then boom it works. Also, for some reason some plugins work when I put them in plugins.sbt (the suggested place). While others only work if I stick them in project/build.sbt. It doesn't make sense, but as soon as I move it there it suddenly installs and runs. Combined dependency listings. If you are hacking stuff together and stick a dependency in both build.scala and build.sbt, it will throw a generic error that is completely unhelpful. Remove one or the other and suddenly it runs.
Also keep in mind that % causes a scala version to be appended to the name of it. whereas %% defines the name explicitly. Sometimes this causes errors when using % because it doesn't have a version available for that scala version. Go to the repository and enter the name of the package explicitly to fix this.
ensime 0.1.2 is only for sbt version 0.13.x. If this is a new project, you might consider using the current version of sbt. Typically you'd do this by creating project/build.properties that contains sbt.version=0.13.0

Unresolved dependency SBT org.scala-sbt#sbt_2.9.1;0.12.1: not found, Play examples

I am trying to run the samples in Play 2.0 framework but when I go to run "play" or "sbt".
When I go to directory "/samples/scala/helloworld", I execute "sbt" and I obtain:
[info] Loading project definition from C:\src\Play20\samples\scala\helloworld\project
[warn] module not found: play#sbt-plugin;2.0
[warn] ==== typesafe-ivy-releases: tried
[warn] http://repo.typesafe.com/typesafe/ivy-releases/play/sbt-plugin/scala_2.9.2/sbt_0.12/2.0/ivys/ivy.xml
[warn] ==== sbt-plugin-releases: tried
[warn] http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/play/sbt-plugin/scala_2.9.2/sbt_0.12/2.0/ivys/ivy.xml
[warn] ==== local: tried
[warn] C:\Users\labra\.ivy2\local\play\sbt-plugin\scala_2.9.2\sbt_0.12\2.0\ivys\ivy.xml
[warn] ==== Typesafe repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/play/sbt-plugin_2.9.2_0.12/2.0/sbt-plugin-2.0.pom
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/play/sbt-plugin_2.9.2_0.12/2.0/sbt-plugin-2.0.pom
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: play#sbt-plugin;2.0: 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.0 (sbtVersion=0.12, scalaVersion=2.9.2)
[warn]
sbt.ResolveException: unresolved dependency: play#sbt-plugin;2.0: not found
at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:214)
. . .
at java.lang.Thread.run(Thread.java:722)
[error] (*:update) sbt.ResolveException: unresolved dependency: play#sbt-plugin;2.0: not found
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?
[info] Loading project definition from C:\src\Play20\samples\scala\helloworld\project
[warn] module not found: play#sbt-plugin;2.0
[warn] ==== typesafe-ivy-releases: tried
[warn] http://repo.typesafe.com/typesafe/ivy-releases/play/sbt-plugin/scala_2.9.2/sbt_0.12/2.0/ivys/ivy.xml
[warn] ==== sbt-plugin-releases: tried
[warn] http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/play/sbt-plugin/scala_2.9.2/sbt_0.12/2.0/ivys/ivy.xml
[warn] ==== local: tried
[warn] C:\Users\labra\.ivy2\local\play\sbt-plugin\scala_2.9.2\sbt_0.12\2.0\ivys\ivy.xml
[warn] ==== Typesafe repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/play/sbt-plugin_2.9.2_0.12/2.0/sbt-plugin-2.0.pom
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/play/sbt-plugin_2.9.2_0.12/2.0/sbt-plugin-2.0.pom
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: play#sbt-plugin;2.0: 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.0 (sbtVersion=0.12, scalaVersion=2.9.2)
[warn]
sbt.ResolveException: unresolved dependency: play#sbt-plugin;2.0: not found
at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:214)
at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:122)
. . .
at java.lang.Thread.run(Thread.java:722)
[error] (*:update) sbt.ResolveException: unresolved dependency: play#sbt-plugin;2.0: not found
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? q
I installed sbt version 12.1 from http://www.scala-sbt.org/release/docs/Getting-Started/Setup
I noticed a similar question here: https://groups.google.com/forum/?fromgroups=#!topic/simple-build-tool/DGUbWsgZiLw
In the answers, it seems to be related to the "Launcher" version of SBT, How can I know whhich is my Launcher sbt version? And how can I update it?
I also tried to compile xsbt from source but, when running "sbt build-all", I obtain:
. . .
[info] Reading library jar [C:\compi\jdk\jre\lib\rt.jar]
[error] Error: Can't read [proguard.ClassPathEntry#73abdb5e] (Can't process class [com/oracle/net/Sdp$1.class] (Unsupported version number [51.0] for class format))
[error] java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
[error] Use 'last' for the full log.
However, my problem is not to compile xsbt, but to know how can I execute "Play's examples"
When running "sbt sbt-version" in a new folder I obtain:
[info] Set current project to default-85f41b (...)
[info] 0.12.1
If you look at project/plugins.sbt, you will see that it expects play.version system property to be set:
addSbtPlugin("play" % "sbt-plugin" % Option(System.getProperty("play.version")).getOrElse("2.0"))
So, you should either provide necessary play.version property
$ sbt -Dplay.version=2.1-RC1
or simply change plugins.sbt as
addSbtPlugin("play" % "sbt-plugin" % "2.1-RC1")
For Activator 1.0 users:
You may encounter this problem when upgrading a Play project to a later version after you load the project into Activator 1.0. That is because Activator creates files in the /project directory that look like activator-...-shim.sbt. Delete those files and Activator should resolve the issue on your next compile.
I have solved the problem after switching to Play 2.1-RC1
I also had an issue with some dependencies which I solved inserting:
// The Typesafe snapshots repository
resolvers += "Typesafe Snapshots" at "http://repo.typesafe.com/typesafe/snapshots/"
in plugins.sbt
I was just following: https://github.com/playframework/Play20/wiki/Repositories
For play 2.0.2, version 2.0.2 of SBT worked just fine in my project. I changed the addSbtPlugin line in my plugins.sbt file to:
addSbtPlugin("play" % "sbt-plugin" % "2.0.2")
It should be analogous for earlier versions. As Labra already pointed out, since this version of SBT is not the latest anymore, you probably will need to add also the following resolver in order to get it:
resolvers += "Typesafe Snapshots" at "http://repo.typesafe.com/typesafe/snapshots/"
Another way of getting rid of this kind of problem is updating Play Framework for your project to the latest version if possible. This is probably the best choice in the long run as it allows you to keep your code base current.
Following Jose's answer, I made it work but with this resolver:
"Typesafe Snapshots" at "http://repo.typesafe.com/typesafe/maven-releases"

Sbt Unresolved Dependencies (Not a valid command: gen-idea)

I'm trying to get sbt to generate Intellij IDEA project files using the sbt-idea plugin as described here.
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: de.undercouch#sbt-docbook-plugin;0.2-SNAPSHOT: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] de.undercouch:sbt-docbook-plugin:0.2-SNAPSHOT (sbtVersion=0.11.2, scalaVersion=2.9.1)
[warn]
[error] {file:/Users/ndidi/Sandbox/specs2-spring-examples/simple/project/plugins/}default-58af23/*:update: sbt.ResolveException: unresolved dependency: de.undercouch#sbt-docbook-plugin;0.2-SNAPSHOT: not found
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? i
[warn] Ignoring load failure: no project loaded.
[error] Not a valid command: gen-idea
[error] gen-idea
[error] ^
I've gone through the project's issues page and also Googled extensively, however I haven't discovered anyone else with this issue, causing me to believe that the problem is somewhat uncommon and likely to be related to an issue with my setup..
If anyone could shine a little light on this, it'd be most appreciated.
Thanks in advance.
I solved the issue by cleaning up the "~/.ivy2" and "~/.sbt" directories as suggested in this thread on the sbt-idea official site.
Two changes have help resolve this and a number of other minor issues:
I removed this line:
addSbtPlugin("de.undercouch" % "sbt-docbook-plugin" % "0.2-SNAPSHOT")
from /project/plugins.sbt
I no longer run sbt commands from the commandline, I exclusively use the sbt console. That running '$ sbt gen-idea' fails, while '> gen-idea' in the sbt console succeeds, strikes me a somewhat odd. If I figure out why, I'll be sure to update with a comment.