I mentioned json4s-native 3.3.0 but it refering 3.3.0-SNAPSHOT.
In my project there is 3 modules (common, read and write) each have its scala.sbt.
Before change:
"org.json4s" %% "json4s-native" % Versions.Json4s % "compile",
After change:(Changed all the places in 3 modules)
"org.json4s" %% "json4s-native" % "3.3.0" % "compile",
I run:
sbt
clean
update
Error:
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.json4s#json4s-native_2.10;3.3.0-SNAPSHOT: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] org.json4s:json4s-native_2.10:3.3.0-SNAPSHOT
My Sales buld.sbt is this:
name := "myapp-sales"
organization in ThisBuild := "com.mycompany"
scalaVersion in ThisBuild := "2.11.7"
//crossScalaVersions in Thisq
//Build := List("2.10.5", scalaVersion.value)
//crossPaths := false
scalacOptions in Compile in ThisBuild ++= Seq("-unchecked", "-deprecation", "-encoding", "utf8", "-language:postfixOps", "-language:implicitConVersions")
lazy val common = Project("myapp-sales-common", file("common"))
lazy val read = Project("myapp-sales-read", file("read")).configs(IntegrationTest).settings(Defaults.itSettings: _*).dependsOn(common, write)
lazy val write = Project("myapp-sales-write", file("write")).configs(IntegrationTest).settings(Defaults.itSettings: _*).dependsOn(common)
conflictWarning in ThisBuild := ConflictWarning.disable
parallelExecution in Test in ThisBuild := false
parallelExecution in IntegrationTest in ThisBuild := false
javacOptions in Compile in ThisBuild ++= Seq("-source", "1.6", "-target", "1.6")
//Remove SNAPSHOT check from the release process (for now until Squants gets a release)
releaseProcess := releaseProcess.value.filterNot(_ == ReleaseTransformations.checkSnapshotDependencies)
My read module build.sbt:
libraryDependencies ++= Seq(
"com.mycompany" %% "myapp-core-read" % myappsales.CoreVersion % "compile", // disable using the Scala version in output paths and artifacts,
"com.mycompany" %% "myapp-core-write" % myappsales.CoreVersion % "compile",
"com.mycompany" %% "myapp-registration-common" % myappsales.RegistrationVersion % "compile",
"com.mycompany" %% "myapp-load-common" % myappsales.LoadVersion % "compile",
"com.mycompany" %% "myapp-core-write-test" % myappsales.CoreVersion % "it, test",
"com.mycompany" %% "myapp-core-test" % myappsales.CoreVersion % "it, test"
)
libraryDependencies ++= Seq(
"com.typesafe" % "config" % myappsales.TypeSafeConfigVersion % "compile",
"org.json4s" %% "json4s-native" % Versions.Json4s % "compile",
"io.spray" % "spray-routing" % Versions.Spray % "compile",
"com.typesafe.akka" %% "akka-actor" % Versions.Akka % "compile",
"com.typesafe.akka" %% "akka-remote" % Versions.Akka % "compile"
exclude ("io.netty", "netty")
)
//Assemby settings
test in assembly := {}
assemblyShadeRules in assembly := Seq(
ShadeRule.rename("play.api.libs.iteratee.**" -> "shade.play.api.libs.iteratee.#1")
.inLibrary("play" % "play-iteratees_2.10" % "2.1-RC2")
.inLibrary("org.reactivemongo" % "reactivemongo_2.10" % "0.8.1-SNAPSHOT"),
ShadeRule.rename("scala.concurrent.stm.**" -> "shade.scala.concurrent.stm.#1")
.inLibrary("org.scala-stm" % "scala-stm_2.10.0" % "0.6")
.inLibrary("play" % "play-iteratees_2.10" % "2.1-RC2")
)
assemblyMergeStrategy in assembly := {
case "application.conf" => MergeStrategy.concat
case path => MergeStrategy.defaultMergeStrategy(path)
}
//Make assembly a publishable artifact
artifact in (
Compile, assembly) := {
val art = (artifact in (Compile, assembly)).value
art.copy(`classifier` = Some("assembly"))
}
addArtifact(artifact in (Compile, assembly), assembly)
Why it still looking for SNAPSHOT version?
There's a fairly standard way of investigating this kind of problems. In your plugins.sbt
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.8.2")
Then go sbt dependencyBrowseGraph, this will open your browser and take you to a page where the entire graph of your dependencies including the evicted one can be browsed. Now figure out where the SNAPSHOT is coming from and get rid of it with an exclusion.
Related
Sorry I am fairly new to Scala and SBT. Here is my build.sbt file
name := "test_stream"
version := "0.1"
scalaVersion := "2.12.10"
resolvers in ThisBuild += Resolver.bintrayRepo("streetcontxt", "maven")
mainClass in Compile := Some("basepackage.Main")
enablePlugins(JavaAppPackaging)
enablePlugins(DockerPlugin)
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-stream" % "2.6.1",
"com.amazonaws" % "aws-java-sdk-s3" % "1.11.693",
"com.streetcontxt" %% "kcl-akka-stream" % "2.0.3",
"me.maciejb.snappyflows" %% "snappy-flows" % "0.2.0",
"org.xerial.snappy" % "snappy-java" % "1.1.7.3",
"org.apache.hadoop" % "hadoop-common" % "2.10.0",
"org.apache.hadoop" % "hadoop-core" % "1.2.1"
)
And I get the following error:
sbt.librarymanagement.ResolveException: unresolved dependency: org.apache.hadoop#hadoop-common;2.10.0: Resolution failed several times for dependency: org.apache.hadoop#hadoop-common;2.10.0 {compile=[default(compile)]}::
try removing ~/.sbt and ~/.ivy2 and run again
I am building a SBT multi-project project, which has common module and logic module, and logic.dependsOn(common).
In common, SparkSQL 2.2.1 ("org.apache.spark" %% "spark-sql" % "2.2.1") is introduced. In logic, SparkSQL also is used, however I get compilation errors, saying "object spark is not a member of package org.apache".
Now, if I add SparkSQL dependency to logic as "org.apache.spark" %% "spark-sql" % "2.2.1", it works. However if I add "org.apache.spark" %% "spark-sql" % "2.2.1" % Provided", I get the same error.
I don't get why this happened, why not the dependency can't be transitive from common to logic
here is the root sbt files:
lazy val commonSettings = Seq(
organization := "...",
version := "0.1.0",
scalaVersion := "2.11.12",
resolvers ++= Seq(
clojars,
maven_local,
novus,
twitter,
spark_packages,
artima
),
test in assembly := {},
assemblyMergeStrategy in assembly := {...}
)
lazy val root = (project in file(".")).aggregate(common, logic)
lazy val common = (project in file("common")).settings(commonSettings:_*)
lazy val logic = (project in file("logic")).dependsOn(common).settings(commonSettings:_*)
here is the logic module sbt file:
libraryDependencies ++= Seq(
spark_sql.exclude("io.netty", "netty"),
embedded_elasticsearch % "test",
scalatest % "test"
)
dependencyOverrides ++= Seq(
"com.fasterxml.jackson.core" % "jackson-core" % "2.6.5",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.6.5",
"com.fasterxml.jackson.module" % "jackson-module-scala_2.11" % "2.6.5",
"com.fasterxml.jackson.core" % "jackson-annotation" % "2.6.5",
"org.json4s" %% "json4s-jackson" % "3.2.11"
)
assemblyJarName in assembly := "***.jar"
For my existing projects I am migrating from scalaVersion 2.10.5 to 2.11.7 and sbtVersion 1.13.9 also.
Current migrating project is Sales, it have Sales-common, Sales-read, Sales-write modules. It have one dependent project Core. But I don't have Core project code I have only already published artefact jars(I have myapp-core-read_2.10-2.2.33.jar, 2.10 is Scala version).
My project looks like this
Sales
common
build.sbt
read
build.sbt
write
build.sbt
build.sbt
Till now, with scala 2.10.5 everything working fine using in real time also.
After change the version I run sbt clean and sbt update. I am getting Unresolved dependency issue like this:
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: mycompany#myapp-core-read_2.11;2.2.33: not found
[warn] :: mycomapny#myapp-core-write_2.11;2.2.33: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
My Sales buld.sbt is this:
name := "myapp-sales"
organization in ThisBuild := "com.mycompany"
scalaVersion in ThisBuild := "2.11.7"
//crossScalaVersions in Thisq
//Build := List("2.10.5", scalaVersion.value)
//crossPaths := false
scalacOptions in Compile in ThisBuild ++= Seq("-unchecked", "-deprecation", "-encoding", "utf8", "-language:postfixOps", "-language:implicitConVersions")
lazy val common = Project("myapp-sales-common", file("common"))
lazy val read = Project("myapp-sales-read", file("read")).configs(IntegrationTest).settings(Defaults.itSettings: _*).dependsOn(common, write)
lazy val write = Project("myapp-sales-write", file("write")).configs(IntegrationTest).settings(Defaults.itSettings: _*).dependsOn(common)
conflictWarning in ThisBuild := ConflictWarning.disable
parallelExecution in Test in ThisBuild := false
parallelExecution in IntegrationTest in ThisBuild := false
javacOptions in Compile in ThisBuild ++= Seq("-source", "1.6", "-target", "1.6")
//Remove SNAPSHOT check from the release process (for now until Squants gets a release)
releaseProcess := releaseProcess.value.filterNot(_ == ReleaseTransformations.checkSnapshotDependencies)
My read module build.sbt:
libraryDependencies ++= Seq(
"com.mycompany" %% "myapp-core-read" % myappsales.CoreVersion % "compile", // disable using the Scala version in output paths and artifacts,
"com.mycompany" %% "myapp-core-write" % myappsales.CoreVersion % "compile",
"com.mycompany" %% "myapp-registration-common" % myappsales.RegistrationVersion % "compile",
"com.mycompany" %% "myapp-load-common" % myappsales.LoadVersion % "compile",
"com.mycompany" %% "myapp-core-write-test" % myappsales.CoreVersion % "it, test",
"com.mycompany" %% "myapp-core-test" % myappsales.CoreVersion % "it, test"
)
libraryDependencies ++= Seq(
"com.typesafe" % "config" % myappsales.TypeSafeConfigVersion % "compile",
"org.json4s" %% "json4s-native" % Versions.Json4s % "compile",
"io.spray" % "spray-routing" % Versions.Spray % "compile",
"com.typesafe.akka" %% "akka-actor" % Versions.Akka % "compile",
"com.typesafe.akka" %% "akka-remote" % Versions.Akka % "compile"
exclude ("io.netty", "netty")
)
//Assemby settings
test in assembly := {}
assemblyShadeRules in assembly := Seq(
ShadeRule.rename("play.api.libs.iteratee.**" -> "shade.play.api.libs.iteratee.#1")
.inLibrary("play" % "play-iteratees_2.10" % "2.1-RC2")
.inLibrary("org.reactivemongo" % "reactivemongo_2.10" % "0.8.1-SNAPSHOT"),
ShadeRule.rename("scala.concurrent.stm.**" -> "shade.scala.concurrent.stm.#1")
.inLibrary("org.scala-stm" % "scala-stm_2.10.0" % "0.6")
.inLibrary("play" % "play-iteratees_2.10" % "2.1-RC2")
)
assemblyMergeStrategy in assembly := {
case "application.conf" => MergeStrategy.concat
case path => MergeStrategy.defaultMergeStrategy(path)
}
//Make assembly a publishable artifact
artifact in (
Compile, assembly) := {
val art = (artifact in (Compile, assembly)).value
art.copy(`classifier` = Some("assembly"))
}
addArtifact(artifact in (Compile, assembly), assembly)
How can I make it work with existing myapp-core-read_2.10-2.2.33.jar jar?
Important note: Scala 2.10 and 2.11 are not binary compatible so you will have to recompile the modules on which you depend
Answer to question:
This seems to be related to how SBT resolves dependencies. When you declare a dependency like so:
"com.mycompany" %% "myapp-core-read" % myappsales.CoreVersion
The %% part in the declaration means that SBT will automatically append the scala version to the library name, so your dependency becomes
group: com.mycompany
artifactId: myapp-core-read_2.11
version: `your version`
It seems that your myapp-core-read was not compiled with scala 2.11 thus SBT can't find the correct version.
You can avoid this by using % and applying the correct suffix manually, so your dependency would become:
"com.mycompany" % "myapp-core-read_2.10" % myappsales.CoreVersion
Having said that, I think scala 2.10 and 2.11 are not binary compatible so you might have to recompile the myapp-core-read module with 2.11.
I'm moving my app from RUN#Cloud to Heroku. I try to deploy the app to Heroku using sbt-heroku plugin. The dependency doesn't want to resolve.
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.heroku#sbt-heroku;0.1.5: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
sbt version is 0.13.1. The content of Build.scala file:
object ApplicationBuild extends Build {
val appName = "happymelly-teller"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
jdbc,
cache,
filters,
"be.objectify" %% "deadbolt-scala" % "2.2-RC2",
"com.andersen-gott" %% "scravatar" % "1.0.3",
"com.github.tototoshi" %% "slick-joda-mapper" % "0.4.0",
"com.typesafe.play" %% "play-slick" % "0.5.0.8",
"com.heroku" % "sbt-heroku" % "0.1.5",
//"com.typesafe.slick" %% "slick" % "1.0.1",
"mysql" % "mysql-connector-java" % "5.1.27",
"org.apache.poi" % "poi" % "3.9",
"org.apache.poi" % "poi-ooxml" % "3.9",
"org.joda" % "joda-money" % "0.9",
"org.pegdown" % "pegdown" % "1.4.2",
"org.planet42" %% "laika-core" % "0.5.0",
"org.jsoup" % "jsoup" % "1.7.3",
// update selenium to avoid browser test to hang
"org.seleniumhq.selenium" % "selenium-java" % "2.39.0",
"ws.securesocial" %% "securesocial" % "2.1.3",
"nl.rhinofly" %% "play-s3" % "3.3.3"
)
val main = play.Project(appName, appVersion, appDependencies).settings(scalariformSettings: _*).settings(
resolvers += Resolver.url("heroku-sbt-plugin-releases", url("https://dl.bintray.com/heroku/sbt-plugins/"))(Resolver.ivyStylePatterns),
resolvers += Resolver.url("sbt-plugin-releases", url("http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns),
resolvers += Resolver.url("Objectify Play Snapshot Repository", url("http://schaloner.github.com/snapshots/"))(Resolver.ivyStylePatterns),
resolvers += Resolver.url("Objectify Play Repository", url("http://schaloner.github.com/releases/"))(Resolver.ivyStylePatterns),
resolvers += "Rhinofly Internal Repository" at "http://maven-repository.rhinofly.net:8081/artifactory/libs-release-local",
resolvers += Resolver.sonatypeRepo("releases"),
routesImport += "binders._"
).settings(
/* Scalariform: override default settings - no spaces within pattern binders is the only option in IntelliJ IDEA,
preserve spaces before arguments is needed for infix function syntax (unconfirmed).*/
ScalariformKeys.preferences := FormattingPreferences().
setPreference(SpacesWithinPatternBinders, false).
setPreference(RewriteArrowSymbols, true).
setPreference(PreserveSpaceBeforeArguments, true)
// Avoid building Scaladocs and sources to reduce build time.
).settings(sources in(Compile, doc) := Seq.empty
).settings(publishArtifact in(Compile, packageDoc) := false
).settings(publishArtifact in(Compile, packageSrc) := false)
}
I tried several versions of the plugin (not only 0.1.5, but 0.1.4 and 0.1.3 also) without any success. Did anyone have this issue?
Try
"com.heroku" %% "sbt-heroku" % "0.1.5"
also, you should have added the following lines to your plugins/plugins.sbt file
resolvers += Resolver.url("heroku-sbt-plugin-releases",
url("https://dl.bintray.com/heroku/sbt-plugins/"))(Resolver.ivyStylePatterns)
addSbtPlugin("com.heroku" % "sbt-heroku" % "0.1.5")
I am following the steps for sbt 0.10 on the Assembla Lift wiki and get the following error:
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.github.mpeltonen#sbt-idea_2.8.1;0.10.0-SNAPSHOT: not found
[warn] :: com.github.siasia#xsbt-web-plugin_2.8.1;0.10.1: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[info]
probably because both pages:
http://siasia.github.com/maven2
and
http://mpeltonen.github.com/maven/
don't exist?
My build.sbt:
name := "MyWeb"
scalaVersion := "2.9.0"
seq(WebPlugin.webSettings: _*)
resolvers += "Web plugin repo" at "http://siasia.github.com/maven2"
resolvers += "Web plugin repo2" at "http://mpeltonen.github.com/maven/"
libraryDependencies ++= {
val liftVersion = "2.4-M1"
Seq(
"net.liftweb" %% "lift-webkit" % liftVersion % "compile->default",
"net.liftweb" %% "lift-mapper" % liftVersion % "compile->default",
"net.liftweb" %% "lift-wizard" % liftVersion % "compile->default"
)
}
libraryDependencies ++= Seq(
"junit" % "junit" % "4.5" % "test->default",
"org.mortbay.jetty" % "jetty" % "6.1.22" % "jetty",
"javax.servlet" % "servlet-api" % "2.5" % "provided->default",
"com.h2database" % "h2" % "1.2.138",
"ch.qos.logback" % "logback-classic" % "0.9.26" % "compile->default"
)
and plugins/build.sbt:
resolvers += "Web plugin repo" at "http://siasia.github.com/maven2"
libraryDependencies <+= sbtVersion("com.github.siasia" %% "xsbt-web-plugin" % _)
What am I doing wrong?
This link might helpful.
https://github.com/siasia/xsbt-web-plugin
Replace contents of project/plugins/build.sbt like below
resolvers ++= Seq(
"Web plugin repo" at "http://siasia.github.com/maven2",
Resolver.url("Typesafe repository", new java.net.URL("http://typesafe.artifactoryonline.com/typesafe/ivy-releases/"))(Resolver.defaultIvyPatterns)
)
//Following means libraryDependencies += "com.github.siasia" %% "xsbt-web-plugin" % "0.1.0-<sbt version>""
libraryDependencies <+= sbtVersion(v => "com.github.siasia" %% "xsbt-web-plugin" % ("0.1.0-"+v))
and replace seq(WebPlugin.webSettings: _*) with seq(webSettings :_*) in project root's build.sbt