简体   繁体   English

Gradle构建失败

[英]Gradle build fails

I have two Gradle projects, A and B . 我有两个Gradle项目, AB B is a simple Java application and is consumed by A as a compile project dependency. B是一个简单的Java应用程序,由A作为编译项目依赖项使用。 A is a web application. A是一个Web应用程序。

Both A and B apply the java plugin, A applies the war plugin as well. AB应用java插件, A也应用war插件。

When building A , I get the following error: 构建A ,出现以下错误:

FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':war'.
> Configuration with name 'default' not found.

When separately building B I get no errors. 当单独构建B我没有错误。 When building from root, I get no errors either. 从root构建时,我也没有错误。 The issue shows up only when building A . 只有在构建A时才会出现此问题。

I've also tried copying the B.jar to the lib folder of A and setting a dependency: 我也尝试将B.jar复制到A的lib文件夹并设置依赖项:

compile files("lib/B.jar")

The build in this case works fine. 在这种情况下的构建工作正常。

What configurations do I need to include to avoid the error? 我需要包含哪些配置才能避免错误?

It's possible, when one subproject doesn't see another, if settings.gradle file is not on the parent directory for both subprojects and the subprojects in it are included via includeFlat. 当一个子项目没有看到另一个子项目时,如果两个子项目的父目录中没有settings.gradle文件,并且其中的子项目通过includeFlat包含,则可能。 In this case you can call any task from your parent projects and all subprojects will know about each other, but it'll be unable to build separate subproject. 在这种情况下,您可以从父项目中调用任何任务,并且所有子项目将相互了解,但它将无法构建单独的子项目。

Any way, you need to show your project structure and build/settings files as well, to find out the problem. 无论如何,您还需要显示项目结构和构建/设置文件,以找出问题所在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM