Gradle子项目无法从root build.gradle识别第三方依赖性

问题描述 投票:0回答:1

我有一个这样的项目:

  • module1
    • src /
    • build.gradle
  • module2
    • src /
    • build.gradle
  • build.gradle
  • settings.gradle

在root build.gralde中,我定义了所有子模块所需的第三方依赖关系。但是,在intellij中,子模块似乎无法识别依赖项,因此无法编译。我过去看过这项工作,无法弄清楚我在做什么错]

Root build.gradle插件{id'java'}

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

sourceCompatibility = 1.8

allprojects {
    repositories {
        mavenLocal()
        mavenCentral()
        jcenter()
    }
}

dependencies { 
   ...
}

settings.gradle

rootProject.name = 'XXX'
include 'module1'
include 'module2'

module1 build.gradle

plugins {
    id 'java'
}

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

sourceCompatibility = 1.8
java gradle intellij-idea
1个回答
0
投票
[我意识到我只需要将依赖项放在“ subprojects”块中的root build.gradle中,并添加Java插件。

subprojects { apply plugin: 'java' dependencies { ... } }

© www.soinside.com 2019 - 2024. All rights reserved.