scala - How can I use SBT to help my library get around transitive dependency conflicts -
let's i'm writing scala library l depends on dependency d , consumed program p , program q. p depends on version 3.2 of d directly while q depends on version 3.3 directly.
between 2 versions d's api shuffled same function use in l, must write different import statements in l. likewise p relies on 3.2-specific behavior whereas q relies on 3.3-specific behavior.
now, happen recent version of d chosen when compiling p , q, cause either p break if l depends on version 3.3 of library or l break when compiling q if l depends on version 3.2 of d.
i ideally same version of l used both p , q since l's public api not change. possible?
the general method comes mind conditional compilation of l based on dependency resolution. seems unachievable though in jvm world since don't transitively compile project's dependencies , instead rely on precompiled artifacts.
i can right sbt if d scala (i.e. cross-compiling different scala versions , having version specific code live in own directories), of hack viewpoint of dependency resolution since sbt changes names of artifacts allow cross-compilation work.
you can tell sbt handle dependencies intransitive
:
librarydependencies ++= seq( "org.some.id" % "some-lib" % "1.0.foobar" intransitive() )
would add some-lib dependencies not follow dependencies of lib. if some-lib
had dependency some-other-lib
other lib not downloaded.
maybe bit more specific. say, need several libraries using slf4j logging interface. maybe, of libraries require different version, without api differences. work same slf4j version. mark theses librarydependencies intransitive , add slf4j once top level library dependency.
librarydependencies ++= seq( "org.slf4j" % "slf4j-api" % 1.7.6, "com.typesage.slick" %% "slick" % "2.0.0" intransitive(), "com.typesafe.akka" %% "akka-slf4j" % "2.2.0" intransitive() )
am making sense?
Comments
Post a Comment