首页 > 解决方案 > Gradle - 嵌套目录中的子项目

问题描述

目前我正在使用 gradle 4.10.2,但预计必须迁移到 gradle 5.0,因此我正在尝试解决与 gradle 5.0 相关的任何弃用警告。

我的项目中有以下 gradle 文件:settings.gradle:(在 acfs 中,即根目录、文件夹中)

rootProject.name = "acfs"
include 's/p/w/manager:code'
include 's/p/w/manager:distribution'

build.gradle:(在 acfs/s/p/w/manager/code 文件夹中)

apply from: "$projectDir/../../common.gradle"
apply plugin: 'war'

war {
    // Note: this also determines the context path.
    archiveName "${parent.name}.war"

    from('src/main/web/resources') {
        into 'resources'
        include '**/*'
    }
}

从 acfs 文件夹的命令提示符中,如果我运行,gradle clean build --warning-mode all我会收到以下警告:

The project name 's/p/w/manager' contains at least one of the following characters: [ , /, \, :, <, >, ", ?, *, |]. This has been deprecated and is scheduled to be removed in Gradle 5.0. Set the 'rootProject.name' or adjust the 'include' statement (see https://docs.gradle.org/4.10.2/dsl/org.gradle.api.initialization.Settings.html#org.gradle.api.initialization.Settings:include(java.lang.String[]) for more details).

尝试解决上述警告,按照上述链接中的建议,我将 settings.gradle 修改为:

rootProject.name = "acfs"
include 's/p/w/manager:code'
include 's/p/w/manager:distribution'
project(':s/p/w/manager').name = "manager"

如果我然后运行,gradle clean build --warning-mode all我不再收到警告,但是,我收到以下错误:

Could not determine the dependencies of task 'manager:code:compileJava'.
> Could not resolve all dependencies for configuration ':manager:code:compileClasspath'
  > Project :manager:code not found.

如果我改为将 settings.gradle 修改为,基于https://discuss.gradle.org/t/the-name-aaa-bbb-contains-at-least-one-of-the-following-characters-this-has -已弃用且已计划在 gradle-5-0/24173 中删除

rootProject.name = "acfs"
include 's:p:w:manager:code'
include 's:p:w:manager:distribution'

当我然后运行gradle clean build --warning-mode all它是成功的,并且没有警告。但是,不会生成构建工件。

我在 settings.gradle 中做错了什么,和/或我需要在 build.gradle 文件中修改什么?

标签: gradlebuild.gradle

解决方案


在花了几天时间一无所获之后,我在发布这张facepalm大约一个小时后发现了我做错了什么。我需要在 common.gradle 文件中更新 project.ext.artifactFrom 的值


推荐阅读