Unresolved Dependencies when building play 2.0 project - scala

Downloaded play-2.0 from type safe yesterday, following instructions as far as I can, but when I come to build with sbt I get unresolved dependency errors:
[warn] :: org.slf4j#slf4j-api;1.6.1: configuration not found in
org.slf4j#slf4j-api;1.6.1: 'compile'. It was required from
org.hibernate#hibernate-validator;4.2.0.Final compile [warn] ::
commons-codec#commons-codec;1.4: configuration not found in
commons-codec#commons-codec;1.4: 'compile'. It was required from
org.apache.httpcomponents#httpclient;4.1.2 compile [warn]
:::::::::::::::::::::::::::::::::::::::::::::: [error]
{file:/Users/george/work/play/gbraw/}gbraw/*:update:
sbt.ResolveException: unresolved dependency:
org.slf4j#slf4j-api;1.6.1: configuration not found in
org.slf4j#slf4j-api;1.6.1: 'compile'. It was required from
org.hibernate#hibernate-validator;4.2.0.Final compile [error]
unresolved dependency: commons-codec#commons-codec;1.4: configuration
not found in commons-codec#commons-codec;1.4: 'compile'. It was
required from org.apache.httpcomponents#httpclient;4.1.2 compile
I have deleted my .sbt directory (from an earlier install of sbt) but no joy. I'm sure I have something lying around that I shouldn't have but I'd appreciate any guidance on where to look...
Thanks

so there is a problem with .ivy2 repository
as for commons-codec-1.4
there are ivy-1.4.xml and ivydata-1.4.properties files
in ${ivy_home}/cache/commons-codec/commons-codec dir
but NO real commons-codec-1.4.jar in /jars subdir
DELETE these .xml and .properties files and compile your project with sbt once again
dependency should fetch now
the same is for slf4j-api-1.6.1.jar

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 ignored unmanaged directory for Scala js

I have an old Scala 2.11 project where one of the libraries for Scala.js is not available any more. It's a multiproject build so, I created a lib folder inside of my Scala js project and in the settings of that project set:
unmanagedBase := baseDirectory.value / "lib"
When I go in the SBT shell to js project and type: unmanagedBase it shows correct path to the lib folder. But when I try to import the project in Intellij I'm getting this error:
[warn] :: com.mediamath#scala-json_2.11;1.1: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] com.mediamath:scala-json_2.11:1.1 (/home/my_project/pg/build.sbt#L59)
[warn] +- js:js_sjs0.6_2.11:0.1-SNAPSHOT
[trace] Stack trace suppressed: run 'last js/*:ssExtractDependencies' for the full output.
[trace] Stack trace suppressed: run 'last js/*:update' for the full output.
[error] (js/*:ssExtractDependencies) sbt.ResolveException: unresolved dependency: com.mediamath#scala-json_2.11;1.1: not found
[error] (js/*:update) sbt.ResolveException: unresolved dependency: com.mediamath#scala-json_2.11;1.1: not found
And I have scala-json_2.11-1.1.jar in my lib folder
This warning
[warn] Note: Unresolved dependencies path:
[warn] com.mediamath:scala-json_2.11:1.1 (/home/my_project/pg/build.sbt#L59)
[warn] +- js:js_sjs0.6_2.11:0.1-SNAPSHOT
suggest that the actual issue that requires js:js_sjs0.6_2.11:0.1-SNAPSHOT, so some dependency related to Scala.js 0.6, while you provided scala-json_2.11-1.1.jar, a JAR dedicated for Scala.js 1.1.
Since you added a JAR as unmanaged, resolvers cannot perform evictions or suggest incompatibilities, and can merely verify whether dependencies are there or not, so you'd have to resolve them on your own.
You have some options like editing the MANIFEST file (if code would happen to be compatible between versions), or (if it's open source) compile the offending library yourself for Scala.js 1.1.

sbt new RuntimeException

I got lost trying to start with a scala toy example, when running sbt new scala/hello-world.g8 or even sbt new, the program crashes with the following error. Any ideas what might be wrong? Thanks in advance!
(In fact, I am running sbt -java-home /usr/lib/jvm/jdk-8-oracle-x64 new since my system uses older version of jdk by defualt)
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.antlr#ST4;4.0.8: org.sonatype.oss#oss-parent;9!oss-parent.pom(pom.original) origin location must be absolute: file:/home/michal/.m2/repository/org/sonatype/oss/oss-parent/9/oss-parent-9.pom
[warn] :: com.googlecode.javaewah#JavaEWAH;0.7.9: org.sonatype.oss#oss-parent;5!oss-parent.pom(pom.original) origin location must be absolute: file:/home/michal/.m2/repository/org/sonatype/oss/oss-parent/5/oss-parent-5.pom
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[error] java.lang.RuntimeException: Retrieval of org.scala-sbt.sbt-giter8-resolver:sbt-giter8-resolver:0.1.3 failed.
[error] at scala.sys.package$.error(package.scala:27)
[error] at sbt.TemplateCommandUtil$.classpathForInfo(TemplateCommand.scala:119)
[error] at sbt.TemplateCommandUtil$.infoLoader(TemplateCommand.scala:81)
[error] at sbt.TemplateCommandUtil$.$anonfun$run$1(TemplateCommand.scala:48)
[error] at sbt.TemplateCommandUtil$.$anonfun$run$1$adapted(TemplateCommand.scala:47)
[error] at sbt.TemplateCommandUtil$$$Lambda$1762/658781536.apply(Unknown Source)
...
[error] at xsbt.boot.Boot$.runImpl(Boot.scala:41)
[error] at xsbt.boot.Boot$.main(Boot.scala:17)
[error] at xsbt.boot.Boot.main(Boot.scala)
[error] Retrieval of org.scala-sbt.sbt-giter8-resolver:sbt-giter8-resolver:0.1.3 failed.
[error] Use 'last' for the full log.
I had this problem too. I fixed it by blowing away my ~/.ivy2 directory
I had this problem too, had an out-of-date ~/.sbt/repositories file.
Either:
remove or rename ~/.sbt/repositories
add missing repositories to ~/.sbt/repositories from the current repositories list, see https://github.com/sbt/sbt/blob/v1.0.2/launch/src/main/input_resources/sbt/sbt.boot.properties
Upgrade your SBT version
Create a new user, to have a clean configuration, make sure that it is available for this user JDK and SBT with a "-version". I executed it and everything worked perfectly. Sometimes you have both installed or configured for your user that the programs conflict with each other.
P.S. I do not recommend using openjdk in this case.

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.

Sbt Unresolved Dependencies (Not a valid command: gen-idea)

I'm trying to get sbt to generate Intellij IDEA project files using the sbt-idea plugin as described here.
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: de.undercouch#sbt-docbook-plugin;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] de.undercouch:sbt-docbook-plugin:0.2-SNAPSHOT (sbtVersion=0.11.2, scalaVersion=2.9.1)
[warn]
[error] {file:/Users/ndidi/Sandbox/specs2-spring-examples/simple/project/plugins/}default-58af23/*:update: sbt.ResolveException: unresolved dependency: de.undercouch#sbt-docbook-plugin;0.2-SNAPSHOT: not found
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? i
[warn] Ignoring load failure: no project loaded.
[error] Not a valid command: gen-idea
[error] gen-idea
[error] ^
I've gone through the project's issues page and also Googled extensively, however I haven't discovered anyone else with this issue, causing me to believe that the problem is somewhat uncommon and likely to be related to an issue with my setup..
If anyone could shine a little light on this, it'd be most appreciated.
Thanks in advance.
I solved the issue by cleaning up the "~/.ivy2" and "~/.sbt" directories as suggested in this thread on the sbt-idea official site.
Two changes have help resolve this and a number of other minor issues:
I removed this line:
addSbtPlugin("de.undercouch" % "sbt-docbook-plugin" % "0.2-SNAPSHOT")
from /project/plugins.sbt
I no longer run sbt commands from the commandline, I exclusively use the sbt console. That running '$ sbt gen-idea' fails, while '> gen-idea' in the sbt console succeeds, strikes me a somewhat odd. If I figure out why, I'll be sure to update with a comment.