Fabian Schmitthenner
Fabian Schmitthenner

Reputation: 1706

pinning dependency version to folder with sbt/ivy

Our project consists of multiple subprojects which we publish in a local Nexus. Now, when working on a library, we would like to use this library and build the application without having to upload this library to Nexus all the time.

For a prototypical example, consider we have two projects A and B, with B depending on A:

A/build.sbt:

version := 0.1.7
organization := "org.example"
name := "libraryA"
scalaVersion := "2.11.8"
libraryDependencies += "some.external" % "dependency" % "0.1"

B/build.sbt:

version := 0.2.3
organization := "org.example"
name := "applicationB"
scalaVersion := "2.11.8"
libraryDependencies += "some.other.external" % "dependency" % "0.2"
libraryDependencies += "org.example" % "libraryA" % "0.1.7"

Now let's say I want to work on libraryA and want to test my changes by running applicationB. So I check out A and B to some local folders respectively. Our current approaches are the following:

What we ideally want to have is some way to pin specific library versions to specific folders. This should fix a dependency in the transitive graph to the specific version, and it should be possible for this to be a folder that gets compiled then. The process should look like the following:

Is there something like this available in sbt? I've been told by my coworker that ocaml has something like this (it's called opam pin there).

Upvotes: 0

Views: 632

Answers (1)

Alexey Kiselev
Alexey Kiselev

Reputation: 946

First of all, you can provide versions to your dependencies in Ivy dynamic version format. For example, "1.2.+" or "latest.integration".

To stick to a specific version of dependency you could use sbt-lock plugin. This plugin allows you to 'lock' dynamic version not in build.sbt file but in additional lock.sbt file. It is good idea to put this file under version control. Using plugin's commands 'unlock' and 'relock' you can change locked versions later.

Upvotes: 1

Related Questions