issue with resolving sbt dependencies scalameta - scala

I have created an sbt project. I am trying to add the org.scalameta dependency for scala code formatting. I added following dependency in project/plugins.sbt
addSbtPlugin("org.scalameta" %% "scalameta_2.11" % "4.5.3")
But I am getting following error:
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] org.scalameta:scalameta_2.11:4.5.3 (sbtVersion=1.0, scalaVersion=2.12)
[warn]
[warn] Note: Unresolved dependencies path:
[error] sbt.librarymanagement.ResolveException: Error downloading org.scalameta:scalameta_2.11;sbtVersion=1.0;scalaVersion=2.12:4.5.3
[error] Not found
[error] Not found
[error] not found: https://repo1.maven.org/maven2/org/scalameta/scalameta_2.11_2.12_1.0/4.5.3/scalameta_2.11-4.5.3.pom

If a double percent symbol (%%) is used, sbt will resolve the relevant Scala version.
A single percent symbol (%) is used to resolve the dependencies to a specific Scala version.
I just copy and pasted the example from Maven, and it worked for me:
libraryDependencies += "org.scalameta" %% "scalameta" % "4.5.3"
You can find an example within the Maven repository page.

Related

Scala SBT Plugin Version Error During Build

I keep getting the following error from my GitHub Actions workflow:
[info] welcome to sbt 1.7.1 (Eclipse Adoptium Java 11.0.16.1)
[info] loading settings for project plant-simulator-build from plugins.sbt ...
[info] loading project definition from /home/runner/work/plant-simulator/plant-simulator/project
[warn]
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] org.scoverage:sbt-scoverage:2.0.7 (sbtVersion=1.0, scalaVersion=2.12)
[warn]
[warn] Note: Unresolved dependencies path:
[error] sbt.librarymanagement.ResolveException: Error downloading org.scoverage:sbt-scoverage;sbtVersion=1.0;scalaVersion=2.12:2.0.7
[error] Not found
[error] Not found
[error] not found: https://repo1.maven.org/maven2/org/scoverage/sbt-scoverage_2.12_1.0/2.0.7/sbt-scoverage-2.0.7.pom
[error] not found: /home/runner/.ivy2/localorg.scoverage/sbt-scoverage/scala_2.12/sbt_1.0/2.0.7/ivys/ivy.xml
[error] not found: https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.scoverage/sbt-scoverage/scala_2.12/sbt_1.0/2.0.7/ivys/ivy.xml
[error] not found: https://repo.typesafe.com/typesafe/ivy-releases/org.scoverage/sbt-scoverage/scala_2.12/sbt_1.0/2.0.7/ivys/ivy.xml
[error] at lmcoursier.CoursierDependencyResolution.unresolvedWarningOrThrow(CoursierDependencyResolution.scala:345)
[error] at lmcoursier.CoursierDependencyResolution.$anonfun$update$38(CoursierDependencyResolution.scala:314)
[error] at scala.util.Either$LeftProjection.map(Either.scala:573)
[error] at lmcoursier.CoursierDependencyResolution.update(CoursierDependencyResolution.scala:314)
I have the following defined in my project/plugins.sbt file:
// For code coverage test
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.7")
My question is, why is it taking the 2.12_1.0 scoverage version instead of 2.12.17_2.0.7? This is ruining my build. Any ideas on how to fix this?
My question is, why is it taking the 2.12_1.0 scoverage version instead of 2.12.17_2.0.7?
It's not. It is trying to find version 2.0.7 of the plugin. The 2.12 refer to the Scala version of plugins expected by SBT (different from the version of your project), and 1.0 refer to SBT major version.
The error message is relatively clear:
Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
org.scoverage:sbt-scoverage:2.0.7 (sbtVersion=1.0, scalaVersion=2.12)
This is ruining my build. Any ideas on how to fix this?
There's no version 2.0.7 as of today. Latest is 2.0.5. Check out the GitHub page of the plugin for reference: https://github.com/scoverage/sbt-scoverage.

sbt add plugin error

i've read all of the similar questions but neither of the suggestions fixes my problem. Perhaps i am unable to see it.
The problem is i have project/plugins.sbt
and when i try to add for example
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")
it gives me
[error] (*:update) sbt.ResolveException:
unresolved dependency: com.eed3si9n#sbt-assembly;0.11.2: not found
then i add
resolvers += "sonatype-releases" at "https://oss.sonatype.org/content/repositories/releases/"
but the error is same
my sbt version is
sbt launcher version 0.13.8
and scala version is
Scala code runner version 2.11.6 -- Copyright 2002-2013, LAMP/EPFL
Perhaps someone can point me the right direction.
Thanks in advance.
EDIT:
when i put
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.13.0")
to project/assembly.sbt
i got the same error
actually i do not think the error is for sbt-assembly
it gives the same sort of error when i try to add other plugins
[info] Resolving com.eed3si9n#sbt-assembly;0.13.0 ...
[warn] module not found: com.eed3si9n#sbt-assembly;0.13.0
[warn] ==== local: tried
[warn] .ivy2/local/com.eed3si9n/sbt-assembly/scala_2.11/sbt_0.13/0.13.0/ivys/ivy.xml
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/com/eed3si9n/sbt-assembly_2.11_0.13/0.13.0/sbt-assembly-0.13.0.pom
[warn] ==== Typesafe Repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/com/eed3si9n/sbt-assembly_2.11_0.13/0.13.0/sbt-assembly-0.13.0.pom
[info] Resolving jline#jline;2.12.1 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.eed3si9n#sbt-assembly;0.13.0: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] com.eed3si9n:sbt-assembly:0.13.0 (sbtVersion=0.13, scalaVersion=2.11)
[warn]
[warn] Note: Unresolved dependencies path:
[warn] com.eed3si9n:sbt-assembly:0.13.0 (sbtVersion=0.13, scalaVersion=2.11) (assembly.sbt#L2-3)
1.0
EDIT
Ok for the others that are careless like me
in all the docs it says like project/plugins.sbt, or project/assembly.sbt, etc...
actualy i thought "project" should be the project folder of the application but it is the [your_project_name]/project :(
so all the mentioned conf should go in that directory.
thanks a lot for the replies..
sbt-assembly:
For sbt 0.13.6+ add sbt-assembly as a dependency in
project/assembly.sbt:
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.13.0")
Maybe the problem is with the version of the plugin you want to use?
Try this:
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.13.0")

When running "play" java.lang.NoSuchMethodError occurs

I am trying to run a clone of the play project that I got from git clone https://github.com/djonmayer/play21-osm.git
I have play version 2.2.2 and scala version 2.10.4 installed.
When I type play in the directory that the project clones to I get the following error:
java.lang.NoSuchMethodError: scala.Predef$.augmentString(Ljava/lang/String;)Lscala/collection/immutable/StringOps;
at sbt.ConsoleLogger$.<init>(ConsoleLogger.scala:129)
at sbt.ConsoleLogger$.<clinit>(ConsoleLogger.scala)
at sbt.StandardMain$.<init>(Main.scala:52)
at sbt.StandardMain$.<clinit>(Main.scala)
at sbt.xMain.run(Main.scala:26)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:57)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:77)
at xsbt.boot.Launch$.run(Launch.scala:57)
at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:45)
at xsbt.boot.Launch$.launch(Launch.scala:65)
at xsbt.boot.Launch$.apply(Launch.scala:16)
at xsbt.boot.Boot$.runImpl(Boot.scala:32)
at xsbt.boot.Boot$.main(Boot.scala:21)
at xsbt.boot.Boot.main(Boot.scala)
Error during sbt execution: java.lang.NoSuchMethodError: scala.Predef$.augmentString(Ljava/lang/String;)Lscala/collection/immutable/StringOps;
This is true if I run play clean. I have read this may be a dependencies issue so I have tried adding the line scalaVersion := "2.10.4" to the play.Project.settings section of Build.scala and separately in a build.sbt file. It didn't work.
I tried to put this in a comment but it was unreadable.
Thanks, zeppaman. It does look like this issue is to do with running a Play Framework project that was created in an older version of Play. By looking at another project that had commits for upgrading to a new play version I made the following changes.
In build.properties:
sbt.version=0.12.2
became:
sbt.version=0.13.0
In plugins.sbt:
addSbtPlugin("play" % "sbt-plugin" % "2.1.1")
became:
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.2")
This enabled me to get to play update then throws the errors:
[error] Modules were resolved with conflicting cross-version suffixes in {file:/Users/michaelrichardson/Documents/Play/play21-osm/}play21-osm:
[error] org.scala-stm:scala-stm _2.10, _2.10.0
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) Conflicting cross-version suffixes in: org.scala-stm:scala-stm
I change the line in Build.scala:
"com.typesafe.play" %% "play-slick" % "0.3.2"
became:
"com.typesafe.play" %% "play-slick" % "0.5.0.2-SNAPSHOT"
EXTRA: This changes the error to:
[info] Resolving com.typesafe.play#play-slick_2.10;0.5.0.2-SNAPSHOT ...
[warn] module not found: com.typesafe.play#play-slick_2.10;0.5.0.2-SNAPSHOT
[warn] ==== Typesafe Releases Repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/com/typesafe/play/play-slick_2.10/0.5.0.2-SNAPSHOT/play-slick_2.10-0.5.0.2-SNAPSHOT.pom
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.typesafe.play#play-slick_2.10;0.5.0.2-SNAPSHOT: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: com.typesafe.play#play-slick_2.10;0.5.0.2-SNAPSHOT: not found
UPDATE: Solved unresolved dependency
The problem of unresolved dependencies seems like it may have been due to my local sbt/ivy repositories getting corrupted. See unresolved dependency: com.typesafe.play#play-slick_2.10;0.6.0.1: not found
This kind of problem is often relate to two similar prolbem:
missing jar with same class
same class into multiple jar
So check if scala and play version are compatible and if You have included a jar that already contains the class with missing method.

sbt and scct .... module not found: reaktor#sbt-scct;0.2-SNAPSHOT

scala is version 2.10.2 and sbt is 0.13.0
I am trying to setup scct for scala unit test code coverage so in build.sbt
I added
seq(ScctPlugin.instrumentSettings : _*)
and in project/plugins.sbt I added
resolvers += Classpaths.typesafeResolver
resolvers += "scct-github-repository" at "http://mtkopone.github.com/scct/maven-repo"
addSbtPlugin("reaktor" %% "sbt-scct" % "0.2-SNAPSHOT")
I get errors like ....
module not found: reaktor#sbt-scct;0.2-SNAPSHOT
Last message is
[warn] ==== scct-github-repository: tried
[warn] http://mtkopone.github.com/scct/maven-repo/reaktor/sbt-scct_2.10_0.13/0.2-SNAPSHOT/sbt-scct-0.2-SNAPSHOT.pom
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: reaktor#sbt-scct;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] reaktor:sbt-scct:0.2-SNAPSHOT (sbtVersion=0.13, scalaVersion=2.10)
I look in http://mtkopone.github.io/scct/maven-repo/reaktor/
and I see the one I seem to need is missing e.g. I see
sbt-scct_2.9.2_0.13/
scct_2.10/
and a bunch of others but no ... sbt-scct_2.10_0.13
Can you help ? (I am a sbt newbie)
SCCT has a new source code repository: https://github.com/SCCT/scct
As a result you can fetch a release version from maven central with addSbtPlugin("com.github.scct" %% "sbt-scct" % "0.2") in your plugins.sbt file.
My project to reproduce is on GitHub.
Update:
The repository has been relocated at https://github.com/sqality/scct
and you need addSbtPlugin("com.sqality.scct" % "sbt-scct" % "version") in your plugins.sbt file.
The original SCCT is inactive now.
Here are the two most active forks.
http://github.com/sqality
http://github.com/scoverage

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

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.