Gradle fails injecting dependencies into subprojects using fileTree

Posted by Matthias on Stack Overflow See other posts from Stack Overflow or by Matthias
Published on 2011-01-14T12:48:47Z Indexed on 2011/01/14 12:53 UTC
Read the original article Hit count: 288

Maybe I'm missing something about the way Gradle works. What I have here is a parent project, which only contains configuration, i.e. there won't be any artifact being built when building it, it merely manages and builds all its subprojects.

Now the subprojects share some dependency configuration, so I figured what I would do in the root project's build.gradle is:

subprojects {
  dependencies {
    compile fileTree(dir: 'lib', includes: ['*.jar'])
  }    
}

that, however, does not work, it fails with a rather obscure error message:

A problem occurred evaluating root project 'qype-android' Cause: No signature of method: org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.compile() is applicable for argument types: (org.gradle.api.internal.file.DefaultConfigurableFileTree) values: [file set 'lib'] Possible solutions: module(java.lang.Object)

after some trial and error, I could "fix" this issue by applying the 'java' plugin to the parent project.

How come? I don't see anywhere from the Gradle docs that a fileTree dependency requires the Java plugin. Even so, why would I need it on the project that is injecting the configuration, as opposed to on the project that is being configured (note that the subprojects all apply the Java plugin themselves)?

Does this mean that if I have N different subprojects that are all of varying natures, and apply different plugins, that the parent projects must always apply the set of all plugins beings used somewhere to itself, too?

© Stack Overflow or respective owner

Related posts about dependency-injection

Related posts about gradle