سؤال

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?

هل كانت مفيدة؟

المحلول

It is not the fileTree that requires 'java' plugin.

The error message is complaining about undefined compile dependency configuration. Java plugin defines this configuration for you, so that you can add dependencies (including your fileTree) to it.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top