发布时未指定 gradle suproject 版本

Nar*_*yel 5 java gradle gradle-plugin

我有两个 Nexus 存储库:一个用于发布,另一个用于快照。我在发布任务中有代码来定义根据文档选择哪个存储库:

        repositories {
            repositories {
                maven {
                    credentials {
                        username "$nexusUser"
                        password "$nexusPassword"
                    }
                    def releasesRepoUrl = "https://xxx/repository/factoring-maven-release/"
                    def snapshotsRepoUrl = "https://xxx/repository/factoring-maven-snapshots/"
                    url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
                }
            }
            publications {
                create("default", MavenPublication.class) {
                    from(components["java"])
                }
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

以及此代码包含的子项目:

rootProject.name = 'xxx-integration-lib'

include 'xxx-service1-dto'
include 'xxx-service2-dto'
Run Code Online (Sandbox Code Playgroud)

子项目build.gradle:

group = "xxx"
version = "0.0.6-SNAPSHOT"
Run Code Online (Sandbox Code Playgroud)

但这不起作用,因为子项目版本始终未指定。尝试过:

  1. 制作新的 allproject 任务以返回版本
  2. 使用project.property('propName') - 但这似乎是一种解决方法,而不是解决方案

有什么想法吗?

Nar*_*yel 3

the only worked way for me was a workaround: placing subproject version management in root build.gradle like this

project(':subproject1') {
    version '0.0.6-SNAPSHOT'
}

project(':subproject2') {
    version '0.0.12-SNAPSHOT'
}

project(':subproject14) {
    version '0.0.5-SNAPSHOT'
}
Run Code Online (Sandbox Code Playgroud)

and then project.version property is being injecting correctyl