Android, compile local dependency else download from remote maven repo

Hello I am trying to make Gradle use the local instance of our commons library which is shared between applications. We currently have it set up to download through Maven at all times. But we really only want our Jenkins to do that, as the work flow is make a small edit, create a snap shot, see if it worked. By allowing us to use a local library we can cut down the development thrashing.

Mostly I am having issues with the lack of proficiency with Gradle. I am trying to include it in my top level settings.gradle. Which requires me to import the project as it’s own directory. I don’t think I really want this. I need to be able to add it as a top level dependency, per my understanding of gradle. What I want it to do is try to import it, else use the module.

Was thinking something like

configurations.all {
    resolutionStrategy.dependencySubstitution {
        substitute project(":commons") with module("com.foo.android:commons:1.2.3")
    }
}

or

    try {
        project(':commons').projectDir = new File(settingsDir, '../android-commons')
    } catch (UnknownProjectException) {
        compile ('com.foo.android:commons:1.2.3') { changing=true }
    }

currently use
compile ('com.foo.android:commons:1.2.3') { changing=true }

We have it set up in the top level build.gradle to find the dependency in our remote server with

allprojects {
    repositories {
        jcenter()
        maven { url "our url" }
}