Testing uncomitted changes to snapshot dependency library in applications

I’m trying to test new versions of modules in Gradle that are not deployed to any repository.

Let’s say application A depends on library B at a snapshot version. I want to make some changes to library B and test it in application A without actually deploying the (untested) changes to B to any external repository.

Under Maven I would simply install library B into my local maven repository. I could do the same under Gradle but I don’t want to add mavenLocal() to Gradle because it’s an endless source of build instability as people accidentally bake in local dependencies.

My idea was to have a directory inside application A where I can dump jar files (or better yet, classes directories) and they will override the same dependency version in an external repository. I don’t want to change the version of library B declared in application A just to test out the new changes - it is already a snapshot so I expect it to pick up the latest version. I have tried to achieve this with a ‘flatDir’ repository but it only works for some dependencies - sometimes Gradle decided to take the version from the flatDir and sometimes from the external repository seemingly at random.

As a hacky workaround that I’m sure I’ll regret later, I have done this:

repositories {

if (Boolean.getBoolean(“enableMavenLocal”)) mavenLocal() }

… and then I ‘gradlew install’ the library into my local maven repository. I really hope one of the fantastic Gradle guys can come up with a better solution for this!