I am building a sbt plugin and want to reference assembly task in the sbt-assembly plugin ( to be dependent on my task)
to do this i need to reference it as a library ( as opposed to a plugin), and somehow sbt is not able to resolve it as a libraryDepdendencies
this is what my sbt looks like
sbtPlugin := true
name := "my-sbt-plugin"
scalaVersion := "2.10.6"
sbtVersion := "0.13.0"
resolvers ++= Seq(Resolver.sbtPluginRepo("releases"), Resolver.sbtPluginRepo("snapshots"))
libraryDependencies ++= Seq(
"com.eed3si9n" % "sbt-assembly" % "0.13.0")
the output looks like
Resolving com.eed3si9n#sbt-assembly;0.13.0 ...
[warn] module not found: com.eed3si9n#sbt-assembly;0.13.0
[warn] ==== typesafe-ivy-releases: tried
[warn] https://repo.typesafe.com/typesafe/ivy-releases/com.eed3si9n/sbt-assembly/0.13.0/ivys/ivy.xml
[warn] ==== sbt-plugin-releases: tried
[warn] https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/com.eed3si9n/sbt-assembly/0.13.0/ivys/ivy.xml
[warn] ==== local: tried
[warn] /Users/myuser/.ivy2/local/com.eed3si9n/sbt-assembly/0.13.0/ivys/ivy.xml
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/com/eed3si9n/sbt-assembly/0.13.0/sbt-assembly-0.13.0.pom
[warn] ==== sbt-plugin-releases: tried
[warn] https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/com.eed3si9n/sbt-assembly/0.13.0/ivys/ivy.xml
[warn] ==== sbt-plugin-snapshots: tried
[warn] https://repo.scala-sbt.org/scalasbt/sbt-plugin-snapshots/com.eed3si9n/sbt-assembly/0.13.0/ivys/ivy.xml
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.eed3si9n#sbt-assembly;0.13.0: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
It is not resolving because you did not specify a scala version. It should be something like:
libraryDependencies ++= Seq(
"com.eed3si9n" % "sbt-assembly_2.11" % "0.13.0"
)
Or, to automatically get the scala version used in project:
libraryDependencies ++= Seq(
// notice the double %% here
"com.eed3si9n" %% "sbt-assembly" % "0.13.0"
)
But, sbt-assembly is not supposed to be installed that way. The docs show that you must add the following line to your project/plugins.sbt instead:
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.2")
If developing an sbt plugin, the addSbtPlugin line has to go directly into ./build.sbt.
In my case, correcting the sbt assembly version from 14.3 to 14.5 did the trick. Please check what's yours and try that.
So in the project\assembly.sbt , it was like-
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.3")
Then I changed it to-
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.5")
Hope it helps!
It is not resolving for Scala - 2.12.
Add the following line in - project/plugins.sbt -
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.5")
resolvers += Resolver.url("bintray-sbt-plugins", url("http://dl.bintray.com/sbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)
To find the proper path, try the following -
https://dl.bintray.com/sbt/sbt-plugin-releases/com.eed3si9n/sbt-assembly/scala_<version>/
So, using version 2.12, the resolvable path can be found as below -
https://dl.bintray.com/sbt/sbt-plugin-releases/com.eed3si9n/sbt-assembly/scala_2.12/sbt_1.0/0.14.5/ivys/
In addition to the above suggestions I had to add
resolvers += Resolver.url("bintray-sbt-plugins", url("http://dl.bintray.com/sbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)
to project/plugins.sbt.
I had the same issues, All I did was, remove the ==>
addSbtPlugin("com.eed3si9n" %% "sbt-assembly" % "0.14.5")
line from build.sbt and copied to another file, named assembly.sbt at the same project level, where build.sbt is.
It resolved the error.(After 3 hours of reading all posts on the internet. :-) )
Related
I'm starting a new project to try out Scala Cats, and my SBT seems to refuse to find the cats-core. It has no trouble bringing in something like ScalaTest, but whenever I try to refresh my sbt project with the cats-core as a libraryDependencies, it claims it is an unresolved dependency, looking into the error, it says:
[warn] module not found: org.typelevel#cats-core_2.13;2.0.0-M2
[warn] ==== local: tried
[warn] /Users/me/.ivy2/local/org.typelevel/cats-core_2.13/2.0.0-M2/ivys/ivy.xml
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/org/typelevel/cats-core_2.13/2.0.0-M2/cats-core_2.13-2.0.0-M2.pom
[warn] ==== local-preloaded-ivy: tried
[warn] /Users/me/.sbt/preloaded/org.typelevel/cats-core_2.13/2.0.0-M2/ivys/ivy.xml
[warn] ==== local-preloaded: tried
[warn] file:////Users/me/.sbt/preloaded/org/typelevel/cats-core_2.13/2.0.0-M2/cats-core_2.13-2.0.0-M2.pom
[warn] ==== cats-core: tried
[warn] https://mvnrepository.com/artifact/org.typelevel/cats-core/org/typelevel/cats-core_2.13/2.0.0-M2/cats-core_2.13-2.0.0-M2.pom
My build.sbt looks like this:
scalaVersion := "2.13.0"
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-core" % "2.0.0-M2",
"org.scalatest" %% "scalatest" % "3.0.8" % Test
)
resolvers += "cats-core" at "https://mvnrepository.com/artifact/org.typelevel/cats-core" // it gives the same errors without this line
scalacOptions ++= Seq("-Xfatal-warnings","-Ypartial-unification")
val exportFullResolvers = taskKey[Unit]("debug resolvers")
exportFullResolvers := {
for {
(resolver,idx) <- fullResolvers.value.zipWithIndex
} println(s"${idx}. ${resolver.name}")
}
Any idea how to bring it in?
The error is pretty explicit module not found: org.typelevel#cats-core_2.13;2.0.0-M2
What I do is then just search (google) for mavenrepo cats-core
Usually the top result will lead you to
https://mvnrepository.com/artifact/org.typelevel/cats-core
Or on on (sometimes this site is easier, when navigating scala versions):
https://index.scala-lang.org/typelevel/cats/cats-core
I am trying to add a dependency to json4, but I get a module not found error. I am using scala-version 2.12.4 and sbt-version 1.1.1. My other dependency additions seem to add in a normal way.
Here is my code in build.sbt:
scalaVersion := "2.12.4"
libraryDependencies += "io.spray" %% "spray-json" % "1.3.4"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.4" % Test
libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.13.4" % Test
libraryDependencies += "org.json4s" %% "json4s-native" % "3.3.0"
This is the error message that I get:
[warn] module not found: org.json4s#json4s-native_2.12;3.3.0
[warn] ==== local: tried
[warn] /Users/*****/.ivy2/local/org.json4s/json4s-native_2.12/3.3.0/ivys/ivy.xml
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/org/json4s/json4s-native_2.12/3.3.0/ json4s-native_2.12-3.3.0.pom
[warn] ==== local-preloaded-ivy: tried
[warn] /Users/*****/.sbt/preloaded/org.json4s/json4s-native_2.12/3.3.0/ivys/ivy.xml
[warn] ==== local-preloaded: tried
[warn] file:////Users/*****/.sbt/preloaded/org/json4s/json4s-native_2.12/3.3.0/ json4s-native_2.12-3.3.0.pom
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.json4s#json4s-native_2.12;3.3.0: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
Help appreciated, thanks!
You need to use a newer version of this library.
Try this:
libraryDependencies += "org.json4s" %% "json4s-native" % "3.6.0-M3"
or some earlier version but not 3.3.0
Link to versions:
http://search.maven.org/#search%7Cga%7C2%7Cg%3A%22org.json4s%22
Edit: This problem is with compatibility. You use a new version of Scala and sbt. Previous version of this library are not compatible with this Scala version or sbt version.
Newbie in scala here, going through a scala tutorial.
I am trying to use scalatest as mentioned in the tutorial but getting this error:
[error] (*:update) sbt.ResolveException: unresolved dependency: org.scalatest#scalatest;3.0.1: not found
> scalaVersion
[info] 2.10.6
My build.sbt file looks like this:
name := "tasky"
version := "0.1.0"
libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.1"
libraryDependencies += "org.scalatest" % "scalatest" % "3.0.1" % "test"
Also as mentioned here, I have created the global.sbt and plugins.sbt file at the respective locations with the required details. But, I am still getting the error:
[info] Updating {file:/home/tushar/lsbt/tasky/}tasky...
[info] Resolving org.scalatest#scalatest;3.0.1 ...
[warn] module not found: org.scalatest#scalatest;3.0.1
[warn] ==== local: tried
[warn] /home/tushar/.ivy2/local/org.scalatest/scalatest/3.0.1/ivys/ivy.xml
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/org/scalatest/scalatest/3.0.1/scalatest-3.0.1.pom
[warn] ==== local-preloaded-ivy: tried
[warn] /home/tushar/.sbt/preloaded/org.scalatest/scalatest/3.0.1/ivys/ivy.xml
[warn] ==== local-preloaded: tried
[warn] file:////home/tushar/.sbt/preloaded/org/scalatest/scalatest/3.0.1/scalatest-3.0.1.pom
[warn] ==== Artima Maven Repository: tried
[warn] http://repo.artima.com/releases/org/scalatest/scalatest/3.0.1/scalatest-3.0.1.pom
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.scalatest#scalatest;3.0.1: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] org.scalatest:scalatest:3.0.1 (/home/tushar/lsbt/tasky/built.sbt#L4-5)
[warn] +- default:tasky_2.10:0.1.0
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: org.scalatest#scalatest;3.0.1: not found
Any pointers to resolve this issue?
you should use %% instead of a single % as shown below. the %% changes the artifact from scalatest to scalatest_2.10 since the version of scala used in the project is 2.10.
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test"
You can either use %% or specify the artifact_id explicitly as below
libraryDependencies += "org.scalatest" % "scalatest_2.10" % "3.0.1" % "test"
the former approach is recommended over the later.
Explanation
Scala's minor version's are not backward compatible. so a library compiled with 2.10 version cannot be used in a project using scala 2.11. So a library has to be published by compiling it for each versions separately (2.10, 2.11 and 2.12 for eg).
thus all Scala artifacts are published with scala version suffixed at the end. Thus scalatest has a artifact scalatest_2.10,scalatest_2.11 and scalatest_2.12.
In order to make it easier to select the right version of the artifact in your SBT build depending on your scala version , SBT provides a convient symbol %% that will change the artifact id by appending the scala version for you. Thus if "org.scalatest" %% "scalatest" % "3.0.1" would translate to org.scalatest#scalatest_2.10;3.0.1 on your build dynamically.
If you are using maven repository then it should be
libraryDependencies += "org.scalatest" % "scalatest_2.11" % "3.0.1"
And your scalactic should be
libraryDependencies += "org.scalactic" % "scalactic_2.11" % "3.0.1"
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"
What is the repository for the current version of scrooge-sbt-plugin? Or are the setup instructions outdated?
According to the documentation, I added this to a Play Framework project:
In project/plugins.sbt
addSbtPlugin("com.twitter" %% "scrooge-sbt-plugin" % "3.3.2")
In build.sbt:
com.twitter.scrooge.ScroogeSBT.newSettings
libraryDependencies ++= Seq(
"org.apache.thrift" % "libthrift" % "0.8.0",
"com.twitter" %% "scrooge-core" % "3.3.2",
"com.twitter" %% "finagle-thrift" % "6.5.0"
)
After play clean-all and play-compile I get this output:
[warn] module not found: com.twitter#scrooge-sbt-plugin;3.3.2
[warn] ==== typesafe-ivy-releases: tried
[warn] http://repo.typesafe.com/typesafe/ivy-releases/com.twitter/scrooge-sbt-plugin/scala_2.10/sbt_0.13/3.3.2/ivys/ivy.xml
[warn] ==== sbt-plugin-releases: tried
[warn] http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/com.twitter/scrooge-sbt-plugin/scala_2.10/sbt_0.13/3.3.2/ivys/ivy.xml
[warn] ==== local: tried
[warn] /opt/play-2.2.0/repository/local/com.twitter/scrooge-sbt-plugin/scala_2.10/sbt_0.13/3.3.2/ivys/ivy.xml
[warn] ==== Maven2 Local: tried
[warn] file:/home/fernando/.m2/repository/com/twitter/scrooge-sbt-plugin_2.10_0.13/3.3.2/scrooge-sbt-plugin-3.3.2.pom
[warn] ==== sonatype-oss-snapshots: tried
[warn] http://oss.sonatype.org/content/repositories/snapshots/com/twitter/scrooge-sbt-plugin_2.10_0.13/3.3.2/scrooge-sbt-plugin-3.3.2.pom
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/com/twitter/scrooge-sbt-plugin_2.10_0.13/3.3.2/scrooge-sbt-plugin-3.3.2.pom
[warn] ==== Typesafe repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/com/twitter/scrooge-sbt-plugin_2.10_0.13/3.3.2/scrooge-sbt-plugin-3.3.2.pom
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.twitter#scrooge-sbt-plugin;3.3.2: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] com.twitter:scrooge-sbt-plugin:3.3.2 (sbtVersion=0.13, scalaVersion=2.10)
[warn]
sbt.ResolveException: unresolved dependency: com.twitter#scrooge-sbt-plugin;3.3.2: not found
There seems to be a version 3.3.1 at maven.twttr.com. What about version 3.3.2? I couldn't find it at mvnrepository.com or oss.sonatype.org.
The repository is on https://oss.sonatype.org/content/groups/public.
With a look into the Build.scala you can find out to which repository they publish.
If you look into https://oss.sonatype.org/content/groups/public/com/twitter/ and search for "scrooge-sbt-plugin" you fill find folders that ends with "_0.12", so it is published there as SBT 0.12.x plugin. You probably can't use this plugin for Play 2.2.x since it uses SBT 0.13.x.
Version 3.3.2 is not the latest release and I had problems to resolve all files. Using 3.9.2 works:
project/build.properties mus contain SBT 0.12 (example):
sbt.version=0.12.2
project/plugins.sbt must contain the resolver:
resolvers += "sonatype" at "https://oss.sonatype.org/content/groups/public"
addSbtPlugin("com.twitter" %% "scrooge-sbt-plugin" % "3.9.2")
And finally build.sbt or Build.scala must contain:
com.twitter.scrooge.ScroogeSBT.newSettings
scalaVersion := "2.10.1"
libraryDependencies ++= Seq(
"org.apache.thrift" % "libthrift" % "0.8.0",
"com.twitter" %% "scrooge-core" % "3.9.2",
"com.twitter" %% "finagle-thrift" % "6.5.0"
)
First of all, version 3.16.3 is the latest version for sbt 0.13.x
What do you mean by repository?
The code repository is on GitHub, all of the Scrooge stuff including the sbt-plugin stuff are all there.
As for the artifact repository, I am pretty sure it's on maven central or some other standard repo. You should not have to add a resolver to your sbt build. But if you do for some reason than the sonatype one mentioned by #Schleichardt seems about right.