简体   繁体   English

Gradle多模块项目无法找到模块依赖项

[英]Gradle multi module project cannot find module dependencies

I'm trying to build simple java project in Intellij that has many modules. 我试图在具有许多模块的Intellij中构建简单的Java项目。

I've got following project structure: project_structure 我有以下项目结构: project_structure

my root project build.gradle : 我的根项目build.gradle

group 'com.wat'
version '1.0-SNAPSHOT'

apply plugin: 'java'

sourceCompatibility = 1.8
repositories {
    mavenCentral()
}
dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
}

my root project settings.gradle : 我的根项目settings.gradle

rootProject.name = 'Foot'
include 'app'
include 'model'

and my app module build.gradle : 和我的应用程序模块build.gradle

group 'com.wat'
version '1.0-SNAPSHOT'

apply plugin: 'java'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    compile project ':model'
}

When I'm refreshing the project I get following error: 当我刷新项目时,出现以下错误:

Error:(14, 0) Could not get unknown property ':model' for DefaultProjectDependency{dependencyProject='project ':app'', configuration='default'} of type org.gradle.api.internal.artifacts.dependencies.DefaultProjectDependency.
<a href="openFile:C:\Users\lukas\IdeaProjects\Foot\app\build.gradle">Open File</a>

I was looking for similar problems but none of their solutions was resolving mine. 我一直在寻找类似的问题,但是他们的解决方案都无法解决我的问题。

When I was leaving only 当我只离开时

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile project ':model'
}

In each module build.gradle 在每个模块中, build.gradle

I get the following error: 我收到以下错误:

Error:(2, 0) Gradle DSL method not found: 'testCompile()'
Possible causes:<ul><li>The project 'Foot' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
<a href="fixGradleElements">Upgrade plugin to version 2.3.0 and sync project</a></li><li>The project 'Foot' may be using a version of Gradle that does not contain the method.
<a href="open.wrapper.file">Open Gradle wrapper file</a></li><li>The build file may be missing a Gradle plugin.
<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>

Have you tried 你有没有尝试过

compile project(path: ':model', configuration: 'compile')

instead of 代替

compile project ':model'

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

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