is it possible to specify a dependency in Gradle (in android studio) to another gradle project outside of the current project boundaries? For example with a relative path something like this:
dependencies { compile project('../../stdlib/dagger') }
So what I trie is something like this:
I have an Android Application. The structure looks like this:
And I have a gradle android library project containing 3 submodules:
What I want is to compile the dagger, utils, http module into MyApp project.
The stdlib libraries modules are under heavy development and will grow as MyApp grow. Hence I do not want to push them into a maven repository everytime I make a little change.
So is there a possibility to link other gradle projects somehow? Im looking for a temporarly solution. I will push the std library into maven repository once the source is stable.
Also, as workaround, a solution with sourceSet would be possible. I have also considered to make a libraries folder in MyApp who is a symlink to stdlib, but I didnt get it to work as expected:
dependencies { compile project(':libraries:dagger') }
Any idea how to solve such a dependency in gradle?
This isn't necessary. The order inside the dependencies { } block is preserved. You are kind of right. Dependency ordering is preserved, but for example all compile dependencies will be before testCompile dependencies no matter of how you order them.
Gradle declares dependencies on JAR files inside your project's module_name /libs/ directory (because Gradle reads paths relative to the build.gradle file). This declares a dependency on version 12.3 of the "app-magic" library, inside the "com.example.android" namespace group.
You can include an outside root project module using 'settings.gradle' file from your main project. It must to be a gradle project too and in the specific Android building situation, you must configure every module as an "android-library" plugin project.
For example, in 'MyApp' project settings.gradle you can try this:
include 'app' include 'dagger' project(':dagger').projectDir = new File('/Users/foo/workspace/stdlib/dagger')
Your 'MyApp' build.gradle must reflect the need of the 'dagger' module in a relative path Gradle way:
dependencies { compile project(':dagger') }
And that's it. Repeat this step with every external module you need and you'll have a proper Gradle multi-project 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