I am learning how Gradle works, and I cannot understand how it solves the transitive dependencies of a project.
At the moment I have two projects:
- projectA: which has a couple of dependencies on external libraries
- projectB: which has only one dependency on projectA
No matter how I try, when I create projectB, Gradle does not include the projectA dependencies (X and Y) in the projectpro or runtime compilation path. I managed to get it working by including projectA dependencies in the projectB build script, which in my opinion makes no sense. These dependencies should automatically join projectB. I am pretty sure that I am missing something, but I cannot understand that.
I read about "lib dependencies", but it seems that this applies only to local projects, such as described here , and not to external dependencies.
Here is the build.gradle example that I use in the root project (the one that contains both projectA and projectB):
buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.3' } } subprojects { apply plugin: 'java' apply plugin: 'idea' group = 'com.company' repositories { mavenCentral() add(new org.apache.ivy.plugins.resolver.SshResolver()) { name = 'customRepo' addIvyPattern "ssh://.../repository/[organization]/[module]/[revision]/[module].xml" addArtifactPattern "ssh://.../[organization]/[module]/[revision]/[module](-[classifier]).[ext]" } } sourceSets { main { java { srcDir 'src/' } } } idea.module { downloadSources = true } // task that create sources jar task sourceJar(type: Jar) { from sourceSets.main.java classifier 'sources' } // Publishing configuration uploadArchives { repositories { add project.repositories.customRepo } } artifacts { archives(sourceJar) { name "$name-sources" type 'source' builtBy sourceJar } } }
This only applies to project A:
version = '1.0' dependencies { compile 'com.company:X:1.0' compile 'com.company:B:1.0' }
And this is the one used by projectB:
version = '1.0' dependencies { compile ('com.company:projectA:1.0') { transitive = true } }
Thanks in advance for any help and apologize for my poor English.
Francis toth
source share