How do I override a subproject dependency?

In my subproject, I have a dependency

dependencies {
    compile 'group:name:1.0'
}

I want my root project to replace it with a custom subproject that exposes the same API as the dependency

project(':subproject') {
    dependencies {
        compile project(':namecompatible')
    }
}

Is there any way to do this?

The ability to replace external module dependencies with project dependencies is coming in Gradle 2.5. You can download the latest nightly and try this out now if you’d like.

http://gradle.org/docs/nightly/release-notes#dependency-substitution-rules