How to specify sbt dependency along with the intended JDK version - scala

How do I specify the JDK version of a dependency in my Build.sbt?
I encounter such a case with the Aspose library, where the filename is postfixed with JDK version, i.e. aspose-email-4.8.0-jdk17.jar instead of the plain aspose-email-4.8.0.jar. So, specifying the dependency normally, e.g.
"com.aspose" % "aspose-email" % "4.8.0"
will cause sbt to complain with the following error, as the poor SBT tries to download a non-existing file:
[warn] [FAILED ] com.aspose#aspose-email;4.8.0!aspose-email.jar: (0ms)
[warn] ==== local: tried
[warn] /Users/developer/.ivy2/local/com.aspose/aspose-email/4.8.0/jars/aspose-email.jar
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/com/aspose/aspose-email/4.8.0/aspose-email-4.8.0.jar
[warn] ==== Aspose: tried
[warn] http://maven.aspose.com/artifactory/simple/ext-release-local/com/aspose/aspose-email/4.8.0/aspose-email-4.8.0.jar
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: FAILED DOWNLOADS ::
[warn] :: ^ see resolution messages for details ^ ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.aspose#aspose-email;4.8.0!aspose-email.jar
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
sbt.ResolveException: download failed: com.aspose#aspose-email;4.8.0!aspose-email.jar
Update
Then I figured that appending the JDK version to the version number might fix it:
"com.aspose" % "aspose-email" % "4.8.0-jdk17"
Unfortunately it will to another error caused by SBT thinking the POM file is located at aspose-email-4.8.0-jdk17.pom, while it should instead be aspose-email-4.8.0.pom.
[info] Resolving com.aspose#aspose-email;4.8.0-jdk17 ...
[warn] module not found: com.aspose#aspose-email;4.8.0-jdk17
[warn] ==== local: tried
[warn] /Users/ganeshwara/.ivy2/local/com.aspose/aspose-email/4.8.0-jdk17/ivys/ivy.xml
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/com/aspose/aspose-email/4.8.0-jdk17/aspose-email-4.8.0-jdk17.pom
[warn] ==== Aspose: tried
[warn] http://maven.aspose.com/artifactory/simple/ext-release-local/com/aspose/aspose-email/4.8.0-jdk17/aspose-email-4.8.0-jdk17.pom
[info] Resolving net.sf.proguard#proguard-base;5.1 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.aspose#aspose-email;4.8.0-jdk17: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] com.aspose:aspose-email:4.8.0-jdk17 (/Users/ganeshwara/DropMyEmail/backup-server/project/Build.scala#L290)
[warn] +- Dropmysite:common_2.11:1.0-296020c84e74fa1fd65cd5361b563519ff9c4a5d
sbt.ResolveException: unresolved dependency: com.aspose#aspose-email;4.8.0-jdk17: not found
I think if you look into the repo, you'll see that the problem is due to differing naming convention - where the jarfile is postfixed with the intended JDK version but the POM file is not.

After some googling, I've found that Maven actually has an optional extra coordinate, the classifier, which is appended just after the version number (source).
To use it in sbt, you should define your dependency as
"com.aspose" % "aspose-email" % "4.8.0" classifier "jdk17"
(source)

Related

ivy.xml links are broken for sbt debugger in scala

I'm trying to implement scala-debugger.
I have scala 2.4.3, SBT 1.0, Windows 10 (64bit)
I'm using the SBT plugging.
addSbtPlugin("org.scala-debugger" % "sbt-scala-debugger" % "1.1.0-M3")
in the file ~/.sbt/0.1/plugins/plugins.sbt
Do you know where can I find the ivy.xml required to enable sbt debugger for scala?
The status for each link is 404:
[warn] module not found: org.scala-debugger#sbt-scala-debugger;1.1.0-M3
[warn] ==== typesafe-ivy-releases: tried
[warn] https://repo.typesafe.com/typesafe/ivy-releases/org.scala-debugger/sbt-scala-debugger/scala_2.12/sbt_1.0/1.1.0-M3/ivys/ivy.xml
[warn] ==== sbt-plugin-releases: tried
[warn] https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.scala-debugger/sbt-scala-debugger/scala_2.12/sbt_1.0/1.1.0-M3/ivys/ivy.xml
[warn] ==== local: tried
[warn] C:\Users\my_user\.ivy2\local\org.scala-debugger\sbt-scala-debugger\scala_2.12\sbt_1.0\1.1.0-M3\ivys\ivy.xml
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/org/scala-debugger/sbt-scala-debugger_2.12_1.0/1.1.0-M3/sbt-scala-debugger-1.1.0-M3.pom
[warn] ==== local-preloaded-ivy: tried
[warn] C:\Users\my_user\.sbt\preloaded\org.scala-debugger\sbt-scala-debugger\1.1.0-M3\ivys\ivy.xml
[warn] ==== local-preloaded: tried
[warn] file:/C:/Users/my_user/.sbt/preloaded/org/scala-debugger/sbt-scala-debugger_2.12_1.0/1.1.0-M3/sbt-scala-debugger-1.1.0-M3.pom
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.scala-debugger#sbt-scala-debugger;1.1.0-M3: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] org.scala-debugger:sbt-scala-debugger:1.1.0-M3 (scalaVersion=2.12, sbtVersion=1.0)
[warn]
[warn] Note: Unresolved dependencies path:
[warn] org.scala-debugger:sbt-scala-debugger:1.1.0-M3 (scalaVersion=2.12, sbtVersion=1.0) (C:\Users\my_user\damolina\scala\gl-cost-dept-mapping\project\plugins.sbt#L2-3)
[warn] +- default:gl-cost-dept-mapping-build:0.1.0-SNAPSHOT (scalaVersion=2.12, sbtVersion=1.0)
This plugin just isn't available for sbt 1:
https://github.com/ensime/scala-debugger/issues/367
You will have to use sbt 0.13 for it or help the maintainers to upgrade to sbt 1 and publish it.

Unresolved dependencies path org.vegas-viz:vegas_2.12:0.3.11

I have tried to simply include Vegas dependency version 0.3.11 to my sbt.build and the dependency seems unresolved
I am using sbt version 0.1 and scala version 2.12. Intellij 2019
I cannot figure out why, are there any other dependencies needed here?
This is the error I get:
module not found: org.vegas-viz#vegas_2.12;0.3.11
[warn] ==== local: tried
C:\Users\squeo\.ivy2\local\org.vegasviz\vegas_2.12\0.3.11\ivys\ivy.xml
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/org/vegas-
viz/vegas_2.12/0.3.11/vegas_2.12-0.3.11.pom
[warn] ==== local-preloaded-ivy: tried
[warn] C:\Users\squeo\.sbt\preloaded\org.vegas-
viz\vegas_2.12\0.3.11\ivys\ivy.xml
[warn] ==== local-preloaded: tried
[warn] file:/C:/Users/squeo/.sbt/preloaded/org/vegas-
viz/vegas_2.12/0.3.11/vegas_2.12-0.3.11.pom
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.vegas-viz#vegas_2.12;0.3.11: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] org.vegas-viz:vegas_2.12:0.3.11
[warn] +- networkoptimizer:networkoptimizer_2.12:0.1
[error] sbt.librarymanagement.ResolveException: unresolved dependency:
org.vegas-viz#vegas_2.12;0.3.11: not found
Thank you in advance!
the problem here is that you're using a dependency available only for scala 2.11.
There's no Vegas dependency for scala 2.12. As you can see below

sbt unresolved dependency: scala parser combinators

I am trying to use scala parser combinators in my scala project.
The only .sbt file I have in my project is project/build.sbt:
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.4"
I tried adding this line to build/project.sbt
resolvers += "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/"
but I get the exact same error.
When I execute sbt from the terminal in the root directory of my project I obtain the following dependency error (those are the last lines before the error):
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.scala-lang.modules#scala-parser-combinators_2.10;1.0.4: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] org.scala-lang.modules:scala-parser-combinators_2.10:1.0.4 (/home/simonlbc/workspace/examslenstra/project/build.sbt#L7-8)
[warn] +- default:examslenstra-build:0.1-SNAPSHOT (scalaVersion=2.10, sbtVersion=0.13)
sbt.ResolveException: unresolved dependency: org.scala-lang.modules#scala-parser-combinators_2.10;1.0.4: not found
[error] (*:update) sbt.ResolveException: unresolved dependency: org.scala-lang.modules#scala-parser-combinators_2.10;1.0.4: not found
there are several lines which are it seems attempt from sbt to resolve the plugin at several different repositories:
[warn] module not found: org.scala-lang.modules#scala-parser-combinators_2.10;1.0.4
[warn] ==== typesafe-ivy-releases: tried
[warn] https://repo.typesafe.com/typesafe/ivy-releases/org.scala-lang.modules/scala-parser-combinators_2.10/1.0.4/ivys/ivy.xml
[warn] ==== sbt-plugin-releases: tried
[warn] https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.scala-lang.modules/scala-parser-combinators_2.10/1.0.4/ivys/ivy.xml
[warn] ==== local: tried
[warn] /home/simonlbc/.ivy2/local/org.scala-lang.modules/scala-parser-combinators_2.10/1.0.4/ivys/ivy.xml
[warn] ==== activator-launcher-local: tried
[warn] /home/simonlbc/.activator/repository/org.scala-lang.modules/scala-parser-combinators_2.10/1.0.4/ivys/ivy.xml
[warn] ==== activator-local: tried
[warn] /home/simonlbc/workspace/DB/DB2016/server/activator-dist-1.3.10/repository/org.scala-lang.modules/scala-parser-combinators_2.10/1.0.4/ivys/ivy.xml
[warn] ==== typesafe-releases: tried
[warn] http://repo.typesafe.com/typesafe/releases/org/scala-lang/modules/scala-parser-combinators_2.10/1.0.4/scala-parser-combinators_2.10-1.0.4.pom
[warn] ==== typesafe-ivy-releasez: tried
[warn] http://repo.typesafe.com/typesafe/ivy-releases/org.scala-lang.modules/scala-parser-combinators_2.10/1.0.4/ivys/ivy.xml
[warn] ==== sbt-releases-repo: tried
[warn] http://repo.typesafe.com/typesafe/ivy-releases/org.scala-lang.modules/scala-parser-combinators_2.10/1.0.4/ivys/ivy.xml
[warn] ==== sbt-plugins-repo: tried
[warn] http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.scala-lang.modules/scala-parser-combinators_2.10/1.0.4/ivys/ivy.xml
[warn] ==== maven-central: tried
[warn] http://repo1.maven.org/maven2/org/scala-lang/modules/scala-parser-combinators_2.10/1.0.4/scala-parser-combinators_2.10-1.0.4.pom
[warn] ==== Typesafe Repo: tried
[warn] http://repo.typesafe.com/typesafe/releases/org/scala-lang/modules/scala-parser-combinators_2.10/1.0.4/scala-parser-combinators_2.10-1.0.4.pom
To write my project/build.sbt file I followed the directive given by the github repository of the scala parser combinators.
Of course when I do not specify anything in project/build.sbt I get compile time errors from sbt which does not understand where the Parser classes source files are.
Would there be any in which I could configure project/build.sbt so that I can use Scala's parser combinators library?
Based on this part of the error:
[warn] Note: Unresolved dependencies path:
[warn] org.scala-lang.modules:scala-parser-combinators_2.10:1.0.4
^
It looks like you're using Scala 2.10, where parser combinators are part of the standard library. They were split from the standard library as of Scala 2.11, so the jar you're looking for doesn't exist. If you're sticking with 2.10, simply remove that dependency, you'll get it in the standard library.

Spray io - unable to resolve an error about dependencies in sbt

I can't try any example from spay.io since I can't resolve an error about dependencies in build.sbt. Here is how it looks like:
//....skipped
resolvers += "spray repo" at "http://repo.spray.io"
libraryDependencies += "io.spray" % "spray-can" % "1.0"
It gives me an error, however:
[info] Resolving io.spray#spray-can;1.0 ...
[warn] module not found: io.spray#spray-can;1.0
[warn] ==== local: tried
[warn] /home/alex/.ivy2/local/io.spray/spray-can/1.0/ivys/ivy.xml
[warn] ==== Typesafe Repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/io/spray/spray-can/1.0/spray-can-1.0.pom
[warn] ==== spray repo: tried
[warn] http://repo.spray.io/io/spray/spray-can/1.0/spray-can-1.0.pom
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/io/spray/spray-can/1.0/spray-can-1.0.pom
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: io.spray#spray-can;1.0: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
sbt.ResolveException: unresolved dependency: io.spray#spray-can;1.0: not found
//..................................... skipped
[error] (*:update) sbt.ResolveException: unresolved dependency: io.spray#spray-can;1.0: not found
Even when I change the version to be 1.1, I still have the same error.
What's wrong with that?
There is no version 1.0 of spray yet, according to the docs (and browsing the repo): see spray - Current Versions.
The latest seems to be either 1.0-M7 for scala 2.9.2 or 1.1-M7 for scala 2.10.0-RC5.

SBT + Lift - Not being able to build with sbteclipse

I just installed SBT 0.10.1.
I'm using Lift 2.4-M3
I can build with Scala 2.9.0-1 but when it tries to search for sbteclipse it just hangs:
[warn] module not found: com.typesafe.sbteclipse#sbteclipse_2.9.0-1;1.2
[warn] ==== typesafe-ivy-releases: tried
[warn] http://repo.typesafe.com/typesafe/ivy-releases/com.typesafe.sbteclipse/sbteclipse_2.9.0-1/1.2/ivys/ivy.xml
[warn] -- artifact com.typesafe.sbteclipse#sbteclipse_2.9.0-1;1.2!sbteclipse_2.9.0-1.jar:
[warn] http://repo.typesafe.com/typesafe/ivy-releases/com.typesafe.sbteclipse/sbteclipse_2.9.0-1/1.2/jars/sbteclipse_2.9.0-1.jar
[warn] ==== local: tried
[warn] /Users/JP/.ivy2/local/com.typesafe.sbteclipse/sbteclipse_2.9.0-1/1.2/ivys/ivy.xml
[warn] -- artifact com.typesafe.sbteclipse#sbteclipse_2.9.0-1;1.2!sbteclipse_2.9.0-1.jar:
[warn] /Users/JP/.ivy2/local/com.typesafe.sbteclipse/sbteclipse_2.9.0-1/1.2/jars/sbteclipse_2.9.0-1.jar
[warn] ==== Typesafe Repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/com.typesafe.sbteclipse/sbteclipse_2.9.0-1/0.10.1/1.2/ivys/sbteclipse_2.9.0-1-1.2.xml
[warn] -- artifact com.typesafe.sbteclipse#sbteclipse_2.9.0-1;1.2!sbteclipse_2.9.0-1.jar:
[warn] http://repo.typesafe.com/typesafe/releases/com.typesafe.sbteclipse/sbteclipse_2.9.0-1/0.10.1/1.2/jars/sbteclipse_2.9.0-1-1.2.jar
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/com/typesafe/sbteclipse/sbteclipse_2.9.0-1/1.2/sbteclipse_2.9.0-1-1.2.pom
[warn] -- artifact com.typesafe.sbteclipse#sbteclipse_2.9.0-1;1.2!sbteclipse_2.9.0-1.jar:
[warn] http://repo1.maven.org/maven2/com/typesafe/sbteclipse/sbteclipse_2.9.0-1/1.2/sbteclipse_2.9.0-1-1.2.jar
[warn] ==== Scala-Tools Maven2 Repository: tried
[warn] http://scala-tools.org/repo-releases/com/typesafe/sbteclipse/sbteclipse_2.9.0-1/1.2/sbteclipse_2.9.0-1-1.2.pom
[warn] -- artifact com.typesafe.sbteclipse#sbteclipse_2.9.0-1;1.2!sbteclipse_2.9.0-1.jar:
[warn] http://scala-tools.org/repo-releases/com/typesafe/sbteclipse/sbteclipse_2.9.0-1/1.2/sbteclipse_2.9.0-1-1.2.jar
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.typesafe.sbteclipse#sbteclipse_2.9.0-1;1.2: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[info]
[warn] :: problems summary ::
[warn] :::: WARNINGS
[warn] module not found: com.typesafe.sbteclipse#sbteclipse_2.9.0-1;1.2
[warn] ==== typesafe-ivy-releases: tried
[warn] http://repo.typesafe.com/typesafe/ivy-releases/com.typesafe.sbteclipse/sbteclipse_2.9.0-1/1.2/ivys/ivy.xml
[warn] -- artifact com.typesafe.sbteclipse#sbteclipse_2.9.0-1;1.2!sbteclipse_2.9.0-1.jar:
[warn] http://repo.typesafe.com/typesafe/ivy-releases/com.typesafe.sbteclipse/sbteclipse_2.9.0-1/1.2/jars/sbteclipse_2.9.0-1.jar
[warn] ==== local: tried
[warn] /Users/JP/.ivy2/local/com.typesafe.sbteclipse/sbteclipse_2.9.0-1/1.2/ivys/ivy.xml
[warn] -- artifact com.typesafe.sbteclipse#sbteclipse_2.9.0-1;1.2!sbteclipse_2.9.0-1.jar:
[warn] /Users/JP/.ivy2/local/com.typesafe.sbteclipse/sbteclipse_2.9.0-1/1.2/jars/sbteclipse_2.9.0-1.jar
[warn] ==== Typesafe Repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/com.typesafe.sbteclipse/sbteclipse_2.9.0-1/0.10.1/1.2/ivys/sbteclipse_2.9.0-1-1.2.xml
[warn] -- artifact com.typesafe.sbteclipse#sbteclipse_2.9.0-1;1.2!sbteclipse_2.9.0-1.jar:
[warn] http://repo.typesafe.com/typesafe/releases/com.typesafe.sbteclipse/sbteclipse_2.9.0-1/0.10.1/1.2/jars/sbteclipse_2.9.0-1-1.2.jar
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/com/typesafe/sbteclipse/sbteclipse_2.9.0-1/1.2/sbteclipse_2.9.0-1-1.2.pom
[warn] -- artifact com.typesafe.sbteclipse#sbteclipse_2.9.0-1;1.2!sbteclipse_2.9.0-1.jar:
[warn] http://repo1.maven.org/maven2/com/typesafe/sbteclipse/sbteclipse_2.9.0-1/1.2/sbteclipse_2.9.0-1-1.2.jar
[warn] ==== Scala-Tools Maven2 Repository: tried
[warn] http://scala-tools.org/repo-releases/com/typesafe/sbteclipse/sbteclipse_2.9.0-1/1.2/sbteclipse_2.9.0-1-1.2.pom
[warn] -- artifact com.typesafe.sbteclipse#sbteclipse_2.9.0-1;1.2!sbteclipse_2.9.0-1.jar:
[warn] http://scala-tools.org/repo-releases/com/typesafe/sbteclipse/sbteclipse_2.9.0-1/1.2/sbteclipse_2.9.0-1-1.2.jar
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.typesafe.sbteclipse#sbteclipse_2.9.0-1;1.2: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[info]
[info] :: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
[error] {file:/Users/JP/.sbt/plugins/}default-05868e/*:update: sbt.ResolveException: unresolved dependency: com.typesafe.sbteclipse#sbteclipse_2.9.0-1;1.2: not found
The steps I made:
Put the sbteclipse build.sbt in ~/.sbt/plugins/
Added scalaVersion := "2.9.0-1" to ~/.sbt/plugins/build.sbt because, for some reason, sbt was always building with Scala 2.8.1
Copy&Paste Lift scala_29/lift_basic to my project root
Added build.sbt to both project root and /project/plugins/ like stated in http://www.assembla.com/spaces/liftweb/wiki/Using_SBT
Changed build.properties sbt.version=0.7.7 to sbt.version=0.10.1
Any ideas on how to have this building properly?
Do I need to add any code from the https://github.com/typesafehub/sbteclipse ?
Thank you.
Just found the solution.
First things first, like Daniel said, you cannot have scalaVersion in ~/.sbt/plugins/build.sbt
Just remove it form there.
Secondly I updated sbteclipse build.sbt from https://github.com/typesafehub/sbteclipse
Thirdly I copied the content from /project/plugins/build.sbt and added it to ~/.sbt/plugins/build.sbt
Finally I cleaned everything from previous builds and ran sbt. It compiled with no errors whatsoever.
You shouldn't have added scalaVersion := "2.9.0-1" to ~/.sbt/plugins/build.sbt. SBT uses Scala 2.8.1 for itself, and that includes any plugins (such as sbteclipse).
You may add that to your project -- as in build.sbt in the root of your project, not project/plugin/build.sbt --, so that it uses Scala 2.9.0-1, but SBT, and sbteclipse, will continue to use Scala 2.8.1.
Again, SBT and its plugins must use SBT's Scala version, which, at the moment, is 2.8.1.