Compile project dependency

I have a root project which includes two sub projects A and B .

Project B depends on Project A.

While specifying dependency , there are two ways of dong it.

Option 1 : dependencies {

compile “myapp:projectA:1.0” } The above declaration needs project A to be already compiled and available in the repository

Option 2 : dependencies {

compile project(":projectA") } The above declaration will work even if project A is not available in the repository . It will compile first project A and then build project B

I want to know whether there is any option like , build project A ONLY IF it is not already available in the repository.

If it is already avaialble in the repository then use the jar from repository . Bascially I want to avoid the unnecessary build of project A , if it is already available in the repo.

This will be useful in cases where the developer is not aware of the project dependencies and he might

build the two projects in any order

Currently, there is no built-in support for this in Gradle. I often saw a similar scenario, where the external dependency should be used when projectA project directory is not available in the working copy. You can find a sample project at https://github.com/peterwalker/elastic-deps. For your requirements, you need to change the logic in the settings.gradle file.

cheers, René

Thanks. That was very informative.