I have an Android application project with a separate Android library module that is published as binary. I would like to add the ability to switch gradle between creating a library from sources or using a published artifact. Android app depends on binary artifact by default:
compile "com.example.konstantin.mylibrary:mylibrary:${mylibraryVersion}"
Now I want my binary artifact to be replaced with the source code, so I am adding the following code to the root build.gradle file:
configurations.all { resolutionStrategy { dependencySubstitution { substitute module("com.example.konstantin.mylibrary:mylibrary:${mylibraryVersion}") with project(':mylibrary') } }
However, when I try to build a gradle, the binary artifact is still taken. What is wrong here?
here is the complete source code
It is also interesting that if I move the dependency substitution code to the allprojects section or to the build.gradle file for the application module, than gradle will not be created with the following message:
Error:Module version MyApplication:app:unspecified, configuration '_debugCompile' declares a dependency on configuration 'default' which is not declared in the module descriptor for MyApplication:mylibrary:unspecified
source share