Question

I have multiple projects A, B, C. Some are utility libraries and some are applications.

If I have the dependency heirarchy A->B->C and use publish-local I have to include Both dependency B and C in A. Even if A does not use anything directly from C (only by proxy). It is as if all project B dependencies are added with provided scope.

How come these dependencies won't be resolved and added to the classpath?

This is not a multi project Build.scala (on purpose) I have several simplified build files and I want them to be self contained build-wise.

I'm using the command re-start (Revolver) when starting the application A.

/Magnus


Example configuration In this example I've had to include multiple libraries (bouncy castle) that are only really used in one of the following libraries (all published with publish-local)

"mollyware"         %% "fulla-utils"    % fulla,
"mollyware"         %% "brage-http"     % brage,
"mollyware"         %% "saga-domain"    % saga,

Concatenated build.sbt file

scalaVersion := "2.10.3"

name := "mimer-idp"

organization := "mollyware"

version := "0.0.1"

import scalariform.formatter.preferences._

net.virtualvoid.sbt.graph.Plugin.graphSettings

// compile options
scalacOptions ++= Seq( 
  "-encoding", 
  "UTF-8", 
  "-optimise", 
  "-deprecation", 
  "-unchecked", 
  "-feature", 
  "-Yinline-warnings" 
)

javacOptions  ++= Seq( 
  "-Xlint:unchecked", 
  "-Xlint:deprecation" 
)

resolvers += Classpaths.typesafeReleases

resolvers ++= Seq(
  "Spray repo" at "http://repo.spray.io",
  "Spray nightlies" at "http://nightlies.spray.io",
  "Sonatype Snapshot Repo" at "http://oss.sonatype.org/content/repositories/snapshots/"
)

scalariformSettings

ScalariformKeys.preferences := FormattingPreferences()
    .setPreference( RewriteArrowSymbols, true )
    .setPreference( AlignParameters, true )
    .setPreference( AlignSingleLineCaseStatements, true )
    .setPreference( SpaceInsideParentheses, true )
    .setPreference( DoubleIndentClassDeclaration, true )
    .setPreference( PreserveDanglingCloseParenthesis, true )

libraryDependencies <<= scalaVersion { scala_version => 
  val akka          = "2.2.1"
  val ampq          = "1.3-SNAPSHOT"
  val spray         = "1.2.0"
  val sprayJson     = "1.2.5"
  val fulla         = "0.0.1"
  val brage         = "0.0.1"
  val saga          = "0.0.1"
  val scalaTest     = "2.0.RC2"
  val commons       = "1.7"
  val bcastle       = "1.49"
  Seq(
    "io.spray"          % "spray-routing"   % spray,
    "io.spray"          % "spray-can"       % spray,
    "io.spray"          % "spray-http"      % spray,
    "io.spray"          % "spray-client"    % spray,
    "io.spray"          % "spray-testkit"   % spray     % "test",
    "io.spray"          %% "spray-json"     % sprayJson,
    "com.typesafe.akka" %% "akka-actor"     % akka,
    "com.typesafe.akka" %% "akka-remote"    % akka,
    "com.github.sstone" %% "amqp-client"    % ampq,
    "mollyware"         %% "fulla-utils"    % fulla,
    "mollyware"         %% "brage-http"     % brage,
    "mollyware"         %% "saga-domain"    % saga,
    "commons-codec"     %  "commons-codec"  % commons,
    "org.scalatest"     %  "scalatest_2.10" % scalaTest % "test",
    "org.bouncycastle"  % "bcprov-jdk15on"  % bcastle,
    "org.bouncycastle"  % "bcpkix-jdk15on"  % bcastle
  )
}

import sbtassembly.Plugin._

import AssemblyKeys._

import spray.revolver.RevolverPlugin._

assemblySettings

assembleArtifact in packageScala := false

assembleArtifact in packageDependency := true

assemblyOption in packageDependency ~= { _.copy(includeScala = false) }

Revolver.settings
Was it helpful?

Solution

So this is what went wrong: at some point I decided to remove -SNAPSHOT from my build versions when I was setting up a CI-server.

This in turn seems to implicate that that publish-local would not update the package with the same version.

This took me a while to figure out because I made that change a while ago. The strangeness of it all is that the code still seemed to be updated anyhow since I got class not found exceptions. Is it possible that the jars got overwritten but not the ivy or poms?

I had good help of the sbt-dependency-graph plugin to figure this out in the end. The dependencies were not listed. And when I bumped the version or change to snapshot it started working again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top