Failed dependencies with multiproject build in buildSrc

(Christian Abegg) #1

I try to add a dependency to a plugin developed as part of a multiproject build in the buildSrc folder of my project. To reproduce the problem, I took the “multiProjectBuildSrc” sample and modified it as follows:

A) Apply the groovy plugin to buildSrc root project to avoid the exception “Could not find method runtime() for arguments [project ‘:plugina’]” when executing ‘gradle dependencies’ in folder ‘buildSrc’

// buildSrc/build.gradle
 apply plugin: "groovy"

B) Added a build.gradle project to Plugin A where I define the dependency.

// buildSrc/plugina/build.gradle
 repositories {
dependencies {
 compile 'commons-io:commons-io:2.4''

Executing ‘gradle dependencies’ in the folder ‘buildSrc/plugina’ works as expected.

Executing ‘gradle dependencies’ in the ‘buildSrc’ folder shows the following dependency failure:

Root project
  default - Configuration for default artifacts.
+--- project :plugina
  \--- commons-io:commons-io:2.4 FAILED
\--- project :pluginb

Executing ‘gradle dependencies’ in the root folder of the project shows the following dependency failure:

Could not resolve all dependencies for configuration ':runtime'.
> Could not find commons-io:commons-io:2.4.
  Required by:
      :buildSrc:unspecified > buildSrc:plugina:unspecified

What is the missing piece to avoid the “Could not resolve all dependencies for configuration ‘:runtime’” failure?

(Peter Niederwieser) #2

What’s in the root build script?

(Christian Abegg) #3

The root project of ‘sample/multiProjectBuildSrc’ contains a single ‘build.gradle’ file with the following content:

apply plugin: "plugina"
apply plugin: "pluginb"
  task showPlugins << {
  project.plugins.each {
    println it.getClass().name

(Peter Niederwieser) #4

Not sure then. 1.12 had some regressions around class loading, so perhaps try with 1.11 or a nightly.

(Christian Abegg) #5

It does neither work with 1.11 nor with 1.12.

Could you please have a look at the project? Maybe I missed a relevant detail in the description above. I uploaded it to:

(Peter Niederwieser) #6

Each project whose configurations are to be resolved (‘buildSrc/build.gradle’ in this case) needs to declare the appropriate repositories.