sbt unresolved library dependencies - scala

sbt compile issues unresolved dependencies error
Research SBT configuration. I do have the correct syntax. But SBT still issues error
name := "MyProject"
version := "1.0"
scalaVersion := "2.11.12"
resolvers +=
"Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/releases"
libraryDependencies += "java.io.IOException" % "IOException" % "latest.integration"
libraryDependencies += "java.io.FileReader" % "FileReader" % "latest.integration"
libraryDependencies += "java.io.FileNotFoundExceptiom" % "FileNotFoundException" % "latest.integration"
I have a working scala program. I expect the dependencies to be included instead I receive the following Warning. What am I missing?
Warning Message
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: java.io.IOException#IOException;latest.integration: not found
[warn] :: java.io.FileReader#FileReader;latest.integration: not found
[warn] :: java.io.FileNotFoundExceptiom#FileNotFoundException;latest.integration: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::

hmm, there's something weird.
Typically you declare dependencies in a form of a lib/jar that does contain a set of classes, and not the individual class itself.
In your specific case, you don't even need to add any dependency to get java.io.* classes since it belong to standard library and are included by default

Related

Unable to download lwjgl3-awt from Maven using SBT

Following simple SBT fails to import org.lwjglx / lwjgl3-awt:
name := "LWJGLTest"
version := "0.1"
scalaVersion := "2.12.8"
libraryDependencies += "org.lwjglx" % "lwjgl3-awt" % "0.1.5"
The error is:
[warn] Detected merged artifact: [FAILED ] org.lwjgl#lwjgl-opengl;3.2.2!lwjgl-opengl.jar: (0ms).
[warn] Detected merged artifact: [FAILED ] org.lwjgl#lwjgl;3.2.2!lwjgl.jar: (0ms).
[warn] ==== public: tried
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/org/lwjgl/lwjgl-opengl/3.2.2/lwjgl-opengl-3.2.2-natives-${platform}.jar
[warn] https://repo1.maven.org/maven2/org/lwjgl/lwjgl/3.2.2/lwjgl-3.2.2-natives-${platform}.jar
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: FAILED DOWNLOADS ::
[warn] :: ^ see resolution messages for details ^ ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.lwjgl#lwjgl;3.2.2!lwjgl.jar
[warn] :: org.lwjgl#lwjgl-opengl;3.2.2!lwjgl-opengl.jar
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[error] sbt.librarymanagement.ResolveException: download failed: org.lwjgl#lwjgl;3.2.2!lwjgl.jar
[error] download failed: org.lwjgl#lwjgl-opengl;3.2.2!lwjgl-opengl.jar
Is this an issue with SBT, or with the lwjgl3-awt artifact? Is there some way how to work around it?
For a comparison, following sbt loads fine:
name := "LWJGLTest"
version := "0.1"
scalaVersion := "2.12.8"
libraryDependencies += "org.lwjgl" % "lwjgl" % "3.2.2"
libraryDependencies += "org.lwjgl" % "lwjgl-opengl" % "3.2.2"
Following workaround allows to proceed by specifying the necessary dependencies manually:
libraryDependencies += "org.lwjgl" % "lwjgl" % "3.2.2"
libraryDependencies += "org.lwjgl" % "lwjgl-opengl" % "3.2.2"
libraryDependencies += "org.lwjglx" % "lwjgl3-awt" % "0.1.5" excludeAll ExclusionRule("org.lwjgl")
I think the problem is SBT somehow does not understand the ${platform} in the pom.xml. The solution above prevents it trying to resolve those dependencies, which is why they are provided explicitly.

How to set up blueeyes project in SBT?

I'm having trouble setting up this project using SBT.
It does not resolve blueeyes dependency when I type sbt run:
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.reportgrid#blueeyes_2.9.1.RC1;0.4.19: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] com.reportgrid:blueeyes_2.9.1.RC1:0.4.19 (.../blueeyes-example/build.sbt#L19-22)
[warn] +- com.foo:blueeyes-test-api_2.9.1.RC1:0.1.0
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: com.reportgrid#blueeyes_2.9.1.RC1;0.4.19: not found
The BlueEyes project on Github seems abandoned but I hope there's still someone who can help me with this!
Form the documentation of the blueeyes repository, the dependencies should be declares like this:
resolvers ++= Seq(
"Sonatype" at "http://oss.sonatype.org/content/repositories/public",
"Typesafe" at "http://repo.typesafe.com/typesafe/releases/"
)
libraryDependencies ++= Seq(
"com.github.jdegoes" %% "blueeyes-core" % "0.6.0",
"com.github.jdegoes" %% "blueeyes-mongo" % "0.6.0",
"com.github.jdegoes" %% "blueeyes-json" % "0.6.0",
"ch.qos.logback" % "logback-classic" % "1.0.0" % "runtime"
)
your library dependencies look a bit different:
libraryDependencies ++= Seq(
"com.reportgrid" % "blueeyes_2.9.1.RC1" % "0.4.19" % "compile"
)
UPDATE:
And scala version needs to be
scalaVersion := "2.9.1"
instead of
scalaVersion := "2.9.1.RC1"

Unresolved dependency SBT, scalariform

I am receiving this compilation error:
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.typesafe.sbt#sbt-scalariform;1.3.0: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] com.typesafe.sbt:sbt-scalariform:1.3.0 (scalaVersion=2.11, sbtVersion=0.13)
[warn]
In the root of my project I have a build.sbt file:
scalaVersion in ThisBuild := "2.11.6"
I also have a core/build.sbt file with several resolvers, libraryDependencies, and exclusions.
project/plugins.sbt:
addSbtPlugin(...)
resolvers += "Typesafe Public Repo" at "http://repo.typesafe.com/typesafe/releases"
resolvers += "JBoss Repository" at "http://repository.jboss.org/nexus/content/groups/public//"
~/.sbt/0.13/global.sbt
scalaVersion := "2.11.6"
You need to remove scalaVersion := "2.11.6" from ~/.sbt/0.13/global.sbt.
In sbt 0.13, sbt and its ecosystem of plugins is current using Scala 2.10.
The sbt-scalariform changed the groupId/organization
1.3.0 - "com.typesafe.sbt" % "sbt-scalariform" % "1.3.0"
available only for scala 2.9.1, 2.9.2 and 2.10
sbt 0.13
as seen here: https://dl.bintray.com/sbt/sbt-plugin-releases/com.typesafe.sbt/sbt-scalariform/scala_2.10/sbt_0.13/1.3.0/
1.4.0, 1.5.0, ... , 1.8.2 - "org.scalariform" % "sbt-scalariform" & "1.8.2"
https://repo1.maven.org/maven2/org/scalariform/sbt-scalariform_2.10_0.13/
https://search.maven.org/#search%7Cga%7C1%7Ca%3A%22sbt-scalariform%22

sbt can't find local repository defined by Resolver.file()

I use
name := "sbt-publish-test"
version := "0.1-SNAPSHOT"
publishTo := Some(Resolver.file("sbt-repo", file("/home/pishen/sbt-repo")))
and sbt publish to publish my project into the directory.
Now in another project, I want to resolve the project I just published. I use
resolvers += "my-repo" at "file:///home/pishen/sbt-repo"
libraryDependencies += "default" %% "sbt-publish-test" % "0.1-SNAPSHOT"
and is able to resolve the project without any error. The result of show resolvers is:
> show resolvers
[info] List(my-repo: file:///home/pishen/sbt-repo)
But, when I use
resolvers += Resolver.file("my-repo", file("/home/pishen/sbt-repo"))
libraryDependencies += "default" %% "sbt-publish-test" % "0.1-SNAPSHOT"
The result of show resolvers become:
> show resolvers
[info] List(FileRepository(my-repo,FileConfiguration(true,None),Patterns(ivyPatterns=List(), artifactPatterns=List(/home/pishen/sbt-repo/[organisation]/[module](_[scalaVersion])(_[sbtVersion])/[revision]/[artifact]-[revision](-[classifier]).[ext]), isMavenCompatible=true, descriptorOptional=false, skipConsistencyCheck=false)))
and sbt said that it can't resolve the dependency when I typed sbt update:
[warn] module not found: default#sbt-publish-test_2.10;0.1-SNAPSHOT
[warn] ==== local: tried
[warn] /home/pishen/.ivy2/local/default/sbt-publish-test_2.10/0.1-SNAPSHOT/ivys/ivy.xml
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/default/sbt-publish-test_2.10/0.1-SNAPSHOT/sbt-publish-test_2.10-0.1-SNAPSHOT.pom
[warn] ==== my-repo: tried
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: default#sbt-publish-test_2.10;0.1-SNAPSHOT: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
Is this a bug? Or am I use Resolver.file() in a wrong way? What's the difference between "name" at "url" and Resolver.file()? I'm using sbt 0.13.7.
My suspicion is that when you use Resolver.file in that context, it's intended to be more of a "builder" creator, expecting subsequent method calls to fill in additional configuration information that have different defaults when using the "name" at "uri" syntax.
The sbt ScalaDoc for Resolver.file.apply alludes to something along these lines:
Constructs a file resolver with the given name. The patterns to use must be explicitly specified using the ivys or artifacts methods on the constructed resolver object.
When I've done something similar to what you're doing, I start with a File and use its API to convert it into the URI form:
resolvers += "my-repo" at file("/home/pishen/sbt-repo").toURI.toASCIIString

UNRESOLVED DEPENDENCIES error while trying to create jar

I'm trying to build a Scala jar file to run it in spark.
I'm following this tutorial.
when trying to build jar file using sbt as here, i'm facing with following error
[info] Resolving org.apache.spark#spark-core_2.10.4;1.0.2 ...
[warn] module not found: org.apache.spark#spark-core_2.10.4;1.0.2
[warn] ==== local: tried
[warn] /home/hduser/.ivy2/local/org.apache.spark/spark-core_2.10.4/1.0.2/ivys/ivy.xml
[warn] ==== Akka Repository: tried
[warn] http://repo.akka.io/releases/org/apache/spark/spark-core_2.10.4/1.0.2/spark-core_2.10.4-1.0.2.pom
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/org/apache/spark/spark-core_2.10.4/1.0.2/spark-core_2.10.4-1.0.2.pom
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.apache.spark#spark-core_2.10.4;1.0.2: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[error] {file:/home/prithvi/scala/asd/}default-d57abf/*:update: sbt.ResolveException: unresolved dependency: org.apache.spark#spark-core_2.10.4;1.0.2: not found
[error] Total time: 2 s, completed 13 Aug, 2014 5:24:24 PM
what's the issue and how to solve it.
Dependency issue has been resolved. Thank you "om-nom-nom"but new error arised
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: FAILED DOWNLOADS ::
[warn] :: ^ see resolution messages for details ^ ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.eclipse.jetty.orbit#javax.transaction;1.1.1.v201105210645!javax.transaction.orbit
[warn] :: org.eclipse.jetty.orbit#javax.servlet;3.0.0.v201112011016!javax.servlet.orbit
[warn] :: org.eclipse.jetty.orbit#javax.mail.glassfish;1.4.1.v201005082020!javax.mail.glassfish.orbit
[warn] :: org.eclipse.jetty.orbit#javax.activation;1.1.0.v201105071233!javax.activation.orbit
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[error] {file:/home/prithvi/scala/asd/}default-c011e4/*:update: sbt.ResolveException: download failed: org.eclipse.jetty.orbit#javax.transaction;1.1.1.v201105210645!javax.transaction.orbit
[error] download failed: org.eclipse.jetty.orbit#javax.servlet;3.0.0.v201112011016!javax.servlet.orbit
[error] download failed: org.eclipse.jetty.orbit#javax.mail.glassfish;1.4.1.v201005082020!javax.mail.glassfish.orbit
[error] download failed: org.eclipse.jetty.orbit#javax.activation;1.1.0.v201105071233!javax.activation.orbit
[error] Total time: 855 s, completed 14 Aug, 2014 12:28:33 PM
You have your dependency defined as
"org.apache.spark" %% "spark-core" % "1.0.2"
That %% instructs sbt to substitute current scala version to artifact name. Apparently, spark was build for the whole family of 2.10 scala, without specific jars for 2.10.1, 2.10.2 ...
So all you have to do is to redefine it as:
"org.apache.spark" % "spark-core_2.10" % "1.0.2"
I had the same issue.
Looks like that some bugs are in different versions/compilations/etc.
For me the following build.sbt worked fine
name := "My Project"
version := "1.0"
scalaVersion := "2.11.8"
libraryDependencies += "org.apache.spark" %% "spark-sql" % "2.3.2"
Hope it helps
spark-core_2.10.4;1.0.2 means that it is build on top of scala 2.10 vesion.
so you have to specified this scalaVersion := "2.10.4" in your build file.
Please check your .sbt file and change accordingly.
libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-core" % "1.1.0",
"org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016",
"org.eclipse.jetty.orbit" % "javax.transaction" % "1.1.1.v201105210645",
"org.eclipse.jetty.orbit" % "javax.mail.glassfish" % "1.4.1.v201005082020"
)
How can you change the current dependencies? I mean, when you type sbt package for a build file like:
name := "Simple Project"
version := "1.0"
scalaVersion := "2.10.4"
libraryDependencies += "org.apache.spark" %% "spark-core" % "1.2.0"
SBT will start resolving and downloading all kinds of dependencies. But if you see that it is failing on a dependency that is no longer inthe maven repo, what to do? Where can you change the dpencies it tries.
#OP: The problem is that your SBT is outdated. If you downloaded it using apt, you can use apt to remove it as well. In any case, download the latest .tgz (not the .deb) and simply unpack it, after that add the /sbt/bin/ folder to your .bashrc I noticed that older SBT's (the .deb and apt-get versions) work with older scala versions. You either need to manually add or change the dependencies that the older SBT is trying to find or simply change to the latest (not sooo)SBT.