簡體   English   中英

Gradle多模塊項目無法找到模塊依賴項

[英]Gradle multi module project cannot find module dependencies

我試圖在具有許多模塊的Intellij中構建簡單的Java項目。

我有以下項目結構: project_structure

我的根項目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'
}

我的根項目settings.gradle

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

和我的應用程序模塊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'
}

當我刷新項目時,出現以下錯誤:

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>

我一直在尋找類似的問題,但是他們的解決方案都無法解決我的問題。

當我只離開時

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

在每個模塊中, build.gradle

我收到以下錯誤:

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>

你有沒有嘗試過

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

代替

compile project ':model'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM