In a multi-project gradle build, it is obvious to define dependencies between projects as :
dependencies { compile project(':foo:bar') }
However if you are using maven-publish plugin for publishing the artifacts and you are publishing more than one artifacts (i.e., have more than one MavenPublication defined) in a project, then you cannot mark that project as dependency for other subproject. This means if in above example, subproject ‘:foo:bar’ defines two MavenPublication (as below) then gradle fails to configure the project and fails with error as :
// This publication publishes artifacts generated by 'integTest' sourceSet and 'main' sourceSet. publishing { publications { publishTestCode(MavenPublication) { artifactId project.name + '-' + integTestJar.appendix artifact integTestJar } publishMainCode(MavenPublication) { from components.java } } }
Publishing is not yet able to resolve a dependency on a project with multiple different publications
This is a known issue with gradle tracked in GRADLE-2966
The solution (or workaround) is to modify the publications in foo/bar/build.gradle as
// This publication publishes artifacts generated by 'integTest' sourceSet and 'main' sourceSet. publishing { publications { publishTestCode(MavenPublication) { artifactId project.name + '-' + integTestJar.appendix artifact integTestJar } publishMainCode(MavenPublication) { artifactId project.name artifact jar } } }