I am new to gradle and struggling with a basic problem. I have a set of compile time dependencies declared in my project. My problem statement is, I want to make a subset of dependencies non transitive and the remaining transitive.
I have tried to make a custom configuration which extends from compile and set its transitive property to false
.
Customcompile.extendsFrom(compile)
Customcompile.transitive = false
By this, I assume that whatever I declare with
Customcompile 'xxx:xxx:1.0'
will have transitive=false
applied and that it will act as compile time dependency.
But this is not able to compile my project with these dependencies
Am I wrong anywhere in this assumption?
A “configuration” is a named grouping of dependencies. A Gradle build can have zero or more of them. A “repository” is a source of dependencies. Dependencies are often declared via identifying attributes, and given these attributes, Gradle knows how to find a dependency in a repository.
The default configuration extends from the runtime configuration, which means that it contains all the dependencies and artifacts of the runtime configuration, and potentially more. You can add dependencies and artifacts in the usual way (using a dependencies / artifacts block in B's build script).
Gradle project properties provide an easy way to customise builds which may need to run differently in certain situations. In this article you'll learn the most effective ways to use and set properties, along with some common scenarios you might come across in your Gradle project.
You need to change customCompile.extendsFrom(compile)
to compile.extendsFrom(customCompile)
.
configurations {
customCompile
customCompile.transitive = false
compile.extendsFrom(customCompile)
}
This is because the compilation classpath is derived from the dependencies for the compile
configuration.
By making compile
configuration extend from customCompile
configuration, you are now including all dependencies from customCompile
configuration into compile
configuration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With