Home > Blockchain >  When using SBT, is there a generic way to hot-fix a Scala dependency?
When using SBT, is there a generic way to hot-fix a Scala dependency?

Time:05-27

Let's say I am creating an SBT project called Y which is using the package X in an SBT build:

libraryDependencies   = Seq(
  "org.something" %% "X" % XVersion
)

I've learned that X contains a minor bug, which the developer is working on (thank you!). The code of X (built with SBT) is available to clone and I know how to hot-fix this issue while the developer works on it.

Here's what I would love to be able to do:

  1. Clone X to ~/code/X
  2. Create the hot-fix by just editing the code
  3. In the build.sbt for my own project Y, replace "org.something" %% "X" % XVersion with a link to ~/code/X so that my own code is compiled with the hot-fix.

Is there a general way to do this? There's a good chance this is described in the SBT Docs, I'd be happy for a pointer - there's a lot of docs with new terminology.

Example in point (but the question is about the general case): This build file for a package I'm trying to hot-fix is complex, and I'd love to have a way of hot-fixing without requiring to understand this build file fully.

CodePudding user response:

You can edit the dependency code and then run sbt publishLocal which will create a new local version of the dependency with the changes applied, you can then edit your build.sbt to use that new version and that is all you need for a local setup

If you have some CI pipeline or you deeply your code you would need to do more things but this is the basic idea.

  • Related