Search code examples
gradlejarjarjar

How do I use only file based dependencies in gradle instead of specifying groupId:artifactId:versionId


I have the following entry in my gradle file

dependencies {
    compile 'org.A:A:1.0'
}

which downloads 'org.B:B:1.0' because that's it's dependency.(not mentioned explicitly in gradle)

What I want to use in my project is A* and B* which are shadows(changed namespace) of A and B respectively.

Now, I have specified the dependency for A* as

dependencies{
    compile file('libs/A*.jar')
}

But, this one still downloads 'org.B:B:1.0'

How do I wire the gradle to use file('libs/B*.jar')?


Solution

  • The first solution that comes to mind is to exclude the transitive dependency of compile 'org.A:A:1.0'

    This works like this:

    dependencies {
        compile('org.A:A:1.0') {
            exclude 'org.B:B:1.0'
        }
    }
    

    Have a look at the Gradle User Guide for more details on that subject.