无法为参数项目找到方法compile()

时间:2018-04-19 01:08:25

标签: java spring gradle

使用gradle构建项目时,出现错误

Could not find method compile() for arguments [project ':common'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.



org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':core'.
Caused by: org.gradle.api.GradleScriptException: A problem occurred evaluating project ':core'.
Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method compile() for arguments [project ':common'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
    at build_7ik97bgumtntdjoan6kma2j39$_run_closure1.doCall(C:\Users\Jonatan\Documents\GitHub\REST-Web-Services\core\build.gradle:6)
    at build_7ik97bgumtntdjoan6kma2j39.run(C:\Users\Jonatan\Documents\GitHub\REST-Web-Services\core\build.gradle:1)

指着这条线 https://github.com/JonkiPro/REST-Web-Services/blob/master/core/build.gradle#L9

核心模块https://github.com/JonkiPro/REST-Web-Services/blob/master/core/build.gradle

dependencies {
/*******************************
 * Compile Dependencies
 *******************************/

compile project(":common")
...
}

通用模块https://github.com/JonkiPro/REST-Web-Services/blob/master/common/build.gradle

我不知道为什么它不能编译通用模块?

1 个答案:

答案 0 :(得分:2)

您的问题似乎出现在root build.gradle file

def javaProjects = subprojects.findAll {
    it.name == "common" & it.name == "core" && it.name == "web"
}

这种情况永远不会成立。这是因为子项目的名称不能是"普通","核心"和" web"同时。尝试:

def javaProjects = subprojects.findAll { it.name in ["common", "core", "web"] }

如果名称是列表中的任何一个字符串(那是Groovy' true所做的那样),则条件现在返回in