Depend on a Project which has it's own dependences (Gradle)

In Android Studio using Gradle I have ProjectA which relies on ProjectB but Project B relies on Project C and Project D like so...

Project A .. Project B .. Project C .. Project D

Using the current Gradle scripts I get the following error

Error:(22, 0) Project with path ':ProjectC:app' could not be found in project ':ProjectB:app'.

Folder Structure

.\workspace
    \ProjectA
        \app
        \build
        \gradle  
        \.gradle
        \.idea
    \ProjectB (same as A)
    \ProjectC (same as A)
    \ProjectD (same as A)`

Project A settings.gradle

include ':app', ':ProjectB:app'
project (':ProjectB:app').projectDir = new File(settingsDir, '../ProjectB/app')

Project A Project build.gradle

buildscript {
    repositories {
       jcenter()
    }
dependencies {
    classpath 'com.android.tools.build:gradle:1.2.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        jcenter()
    }
}

Project A Module build.gradle

android {
    compileSdkVersion 19
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.movetogradle"
        minSdkVersion 15
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:19.1.0'
    compile project(path: ':ProjectB:app')        
}

Project B knows it's dependancies C and D using the same method above.

I'm new to the whole gradle scene. Obviously in Eclipse (ANT) you would just say ProjectB is a library. We would like to keep them as seperate projects and not modules because when code changes in ProjectB, it gets used by all projects using B.

I can get ProjectA to build if I add references to ProjectC and ProjectD like I have with ProjectB.

How could I get ProjectA to depend on ProjectB without having to declare all of ProjectBs dependencies in ProjectA?

Answers


When another project is included in a Gradle multi-project build, I'm pretty sure that the settings.gradle file is not read for that project. (see the Gradle documentation, chapter 56.2) In a multi-project build, you are expected to at least include all of the required projects in your root settings.gradle file, so in this case, ProjectA's settings.gradle I believe needs to include projects C and D in order for the build to work. A doesn't need to declare any more dependencies, but Gradle needs to be made aware of the projects in order to build them.


Need Your Help

Material Design Lite grid not adapting on mobiles

html css material-design material-design-lite

I'm creating a design update for my website, I beginned with bootstrap and did this : http://lmprepa.fr/beta/index.html

Multiple attachments

php phpmailer

I want to use php mailer for sending multiple attachment in mail.