Subproject build does not include subproject configuration for repositories of his own subproject dependency


#1

Short description
If the build of a subproject(ProjectA) includes the build of another subproject(ProjectB) which has dependencies to libraries located in this project, the ‘subprojects configuration’ for repositories will be ignored for this second subproject(ProjectB) and the build of the subproject(ProjectA) will fail.

In detail
I have the following file and folder structure:

  • build.gradle
  • settings.gradle
  • ProjectA
  • libraries
  • build.gradle
  • ProjectB
  • libraries
  • build.gradle

My build.gradle file on root level looks like this:

...
subprojects {
    repositories {
        flatDir {
	    name 'Local libs'
	    dirs 'libraries'
	}
    }
}
...

The ProjectA/build.gradle:

dependencies {
    compile project(':ProjectB')
}

The ProjectB/build.gradle:

dependencies {
    // Located in ProjectB/libraries
    compile name: 'anyExternalLibAsLocalJar'
}

Building ProjectA forces ProjectB to build but on this step the resolving of the dependencies leads to the following error:

What went wrong:
Could not resolve all dependencies for configuration ':ProjectA:compileClasspath'.
> Could not find :anyExternalLibAsLocalJar:.
  Searched in the following locations:
      file:/D:/ProjectA/libraries/anyExternalLibAsLocalJar-.jar
      file:/D:/ProjectA/libraries/anyExternalLibAsLocalJar.jar
	  Required by:
    MySources:ProjectA:unspecified > MySources:ProjectB:unspecified

In my opinion the build configuration of ProjectA should include all the repositories configured for the project dependencies of ProjectA. That means that ProjectA should include his own libraries folder and the libraries folder of ProjectB as repositories. This should be analysed during configuration.

Does anyone know a solution for this or what I am doing wrong?
Thanks in advance!


(tom) #2

Hello.

This seems very strange to me also.
gradle build
and
gradle subproject:build
Could generate different jars for the same subproject, this does not seem very straight forward.

Can this get fixed? Or is there a guideline?
Thanks