Local dependencies resolved by SBT but not by Play! Framework - scala

I'm trying to use banana-RDF, a locally published library (published using SBT's publish-local) from a Play! Framework project, but when running compile from Play's console, the wanted library is not resolved, when using compile from SBT's console everything goes fine.
I find this behavior pretty weird as Play uses SBT to resolve dependencies. By the way, I'm using the 0.12.3 version of SBT in my Play project.
The error I'm getting when compiling with Play is pretty basic:
[warn] module not found: org.w3#banana_2.10;2013_02_21-SNAPSHOT
[warn] ==== local: tried
[warn] /home_local/.installedSoftware/play-2.1.1/repository/local/org.w3/banana_2.10/2013_02_21-SNAPSHOT/ivys/ivy.xml
[warn] ==== Typesafe Releases Repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/org/w3/banana_2.10/2013_02_21-SNAPSHOT/banana_2.10-2013_02_21-SNAPSHOT.pom
[warn] ==== Typesafe Snapshots Repository: tried
[warn] http://repo.typesafe.com/typesafe/snapshots/org/w3/banana_2.10/2013_02_21-SNAPSHOT/banana_2.10-2013_02_21-SNAPSHOT.pom
[warn] ==== Akka Snapshots: tried
[warn] http://repo.akka.io/snapshots/org/w3/banana_2.10/2013_02_21-SNAPSHOT/banana_2.10-2013_02_21-SNAPSHOT.pom
[warn] ==== OSS117: tried
[warn] http://oss.sonatype.org/content/repositories/snapshots/org/w3/banana_2.10/2013_02_21-SNAPSHOT/banana_2.10-2013_02_21-SNAPSHOT.pom
[warn] ==== Local Maven Repository: tried
[warn] file:///home_local/.m2/repository/org/w3/banana_2.10/2013_02_21-SNAPSHOT/banana_2.10-2013_02_21-SNAPSHOT.pom
[warn] ==== Local SBT Repository: tried
[warn] file:///home_local/.ivy2/local/org/w3/banana_2.10/2013_02_21-SNAPSHOT/banana_2.10-2013_02_21-SNAPSHOT.pom
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/org/w3/banana_2.10/2013_02_21-SNAPSHOT/banana_2.10-2013_02_21-SNAPSHOT.pom
Can anyone explain what is happening here? Thank you in advance.

The problem is that SBT's publish-local publishes your library to ~/.ivy2/local, whereas Play seems to have his ivy2 local repository pointer to the ivy2 repository of his own installation folder (your /home_local/.installedSoftware/play-2.1.1/repository/local).
You can add for example this resolver to your Play's Build.scala:
resolvers += Resolver.file("Local repo", file(System.getProperty("user.home") + "/.ivy2/local"))(Resolver.ivyStylePatterns)

Related

SBT Dependency Resolution Failure with vespa.ai

I've added Vespa to an sbt project:
libraryDependencies += "com.yahoo.vespa" % "vespa-http-client" % "6.225.3"
Which results in the following module resolution failure:
[warn] Detected merged artifact: [FAILED ] com.yahoo.vespa#component;6.225.3!component.container-plugin: (0ms).
[warn] Detected merged artifact: [FAILED ] com.yahoo.vespa#vespajlib;6.225.3!vespajlib.container-plugin: (0ms).
[warn] ==== local: tried
[warn] ==== local: tried
[warn] ==== public: tried
[warn] ==== public: tried
[warn] ==== local-preloaded-ivy: tried
[warn] https://repo1.maven.org/maven2/com/yahoo/vespa/component/6.225.3/component-6.225.3.container-plugin
[warn] C:\Users\gary\.sbt\preloaded\com.yahoo.vespa\vespajlib\6.225.3\container-plugins\vespajlib.container-plugin
[warn] ==== local-preloaded-ivy: tried
[warn] ==== local-preloaded: tried
[warn] C:\Users\gary\.sbt\preloaded\com.yahoo.vespa\component\6.225.3\container-plugins\component.container-plugin
[warn] file:/C:/Users/gary/.sbt/preloaded/com/yahoo/vespa/vespajlib/6.225.3/vespajlib-6.225.3.container-plugin
[warn] ==== local-preloaded: tried
[warn] file:/C:/Users/gary/.sbt/preloaded/com/yahoo/vespa/component/6.225.3/component-6.225.3.container-plugin
Failed with both an older version and latest sbt (1.1.1).
SBT uses the artifact's packaging type as file extension by default. Our pom.xml for the component artifact (and quite a few others) uses packaging type container-plugin, while the actual jar file of course has the standard jar suffix.
So you need to configure SBT manually with the file suffix for those artifacts. I don't know if there's a convenient way to do this for a set of dependencies at once, as I'm not an SBT expert. But for each individual artifact where you get this error, you could try the following:
libraryDependencies += "com.yahoo.vespa" % "component" % "6.225.3" artifacts( Artifact("component", "", "jar"))
I found it in this SO answer and haven't tested it myself. Perhaps you can find some useful information in the SBT reference manual on Using dependencies with artifacts.
Here are the dependencies of vespa-http-cient:
https://github.com/vespa-engine/vespa/blob/master/vespa-http-client/pom.xml
I don't know SBT very well, maybe you need to explicitly include those dependencies, or specify to include transitive dependencies.

activator dist failing when using Scala 2.12.0

I updated the scala version in my build.sbt file to 2.12.0 from 2.11.8.
scalaVersion := "2.12.0"
But now activator dist is failing with the following errors. Please advise:
[info] Resolving com.typesafe.play#twirl-api_2.12;1.1.1 ...
[warn] module not found: com.typesafe.play#twirl-api_2.12;1.1.1
[warn] ==== local: tried
[warn] /home/ubuntu/.ivy2/local/com.typesafe.play/twirl-api_2.12/1.1.1/ivys/ivy.xml
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/com/typesafe/play/twirl-api_2.12/1.1.1/twirl-api_2.12-1.1.1.pom
[warn] ==== activator-launcher-local: tried
[warn] /home/ubuntu/activator/repository/com.typesafe.play/twirl-api_2.12/1.1.1/ivys/ivy.xml
[warn] ==== typesafe-releases: tried
[warn] https://repo.typesafe.com/typesafe/releases/com/typesafe/play/twirl-api_2.12/1.1.1/twirl-api_2.12-1.1.1.pom
[warn] ==== typesafe-ivy-releasez: tried
[warn] https://repo.typesafe.com/typesafe/ivy-releases/com.typesafe.play/twirl-api_2.12/1.1.1/ivys/ivy.xml
One of your dependencies (twirl-api) has not been released for Scala 2.12. You need to remove this dependency, get it published on 2.12, or else stay on Scala 2.11.

IDEA 15 cannot resolve build.sbt after create SBT project

As the title, I've tried most solutions on the internet, but it still not work.
But I can still load my old SBT projects!
It just can't create a new one.
Remove .lock file under ~./ivy2 and ~/.sbt => not work
Change sbt and scala version (Current version is SBT 13.9, Scala 2.11.7) => not work
Invalidate cache and restart => not work
Set SDK/Java path => not work
Reinstall => not work
Does anyone know what's going on?
01:01:48 SBT project import
[warn] [FAILED ] org.scala-sbt#compiler-interface;0.13.9!compiler-interface.jar(src): (0ms)
[warn] ==== typesafe-ivy-releases: tried
[warn] https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/compiler-interface/0.13.9/srcs/compiler-interface-sources.jar
[warn] ==== sbt-plugin-releases: tried
[warn] https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.scala-sbt/compiler-interface/0.13.9/srcs/compiler-interface-sources.jar
[warn] ==== local: tried
[warn] /Users/WeiChen/.ivy2/local/org.scala-sbt/compiler-interface/0.13.9/srcs/compiler-interface-sources.jar
[warn] ==== activator-local: tried
[warn] /Users/WeiChen/activator-dist-1.3.6/repository/org.scala-sbt/compiler-interface/0.13.9/srcs/compiler-interface-sources.jar
[warn] ==== activator-launcher-local: tried
[warn] /Users/WeiChen/.activator/repository/org.scala-sbt/compiler-interface/0.13.9/srcs/compiler-interface-sources.jar
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/org/scala-sb..
It seems like a bug on IDEA 15, I temporally downgrade to IDEA 14 to avoid this problem.
Try re-importing the project.
Select your build.sbt from the tree, then in the following dialog, make sure Sources for SBT and plugins is ticked.

Unable to resolve scalajs-sbt-plugin dependency

I just tried to clone https://github.com/scala-js/scalajs-tutorial and I get this:
[info] Resolving org.scala-lang.modules.scalajs#scalajs-sbt-plugin;0.5.5 ...
[warn] module not found: org.scala-lang.modules.scalajs#scalajs-sbt-plugin;0.5.5
[warn] ==== typesafe-ivy-releases: tried
[warn] http://repo.typesafe.com/typesafe/ivy-releases/org.scala-lang.modules.scalajs/scalajs-sbt-plugin/scala_2.10/sbt_0.13/0.5.5/ivys/ivy.xml
[warn] ==== sbt-plugin-releases: tried
[warn] http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.scala-lang.modules.scalajs/scalajs-sbt-plugin/scala_2.10/sbt_0.13/0.5.5/ivys/ivy.xml
[warn] ==== local: tried
[warn] C:\Users\Joan\.ivy2\local\org.scala-lang.modules.scalajs\scalajs-sbt-plugin\scala_2.10\sbt_0.13\0.5.5\ivys\ivy.xml
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/org/scala-lang/modules/scalajs/scalajs-sbt-plugin_2.10_0.13/0.5.5/scalajs-sbt-plugin-0.5.5.pom
I also opened an issue here
Cheers
Qote from https://github.com/scala-js/scalajs-tutorial/issues/3:
This resolver is supposed to be used by default by sbt >= 0.13.0.
And this has all been working fine for a year. Now suddenly people start having this issue :-s This doesn't make any sense.
Workaround: add explicitly the following resolver in project/plugins.sbt:
resolvers += Resolver.url(
"bintray-sbt-plugin-releases",
url("https://dl.bintray.com/content/sbt/sbt-plugin-releases")
)(Resolver.ivyStylePatterns)

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