gpt4 book ai didi

java - Gradle SubProject 任务没有被拾取

转载 作者:行者123 更新时间:2023-12-03 03:16:52 25 4
gpt4 key购买 nike

我有一个具有以下结构的 Java 项目的多模块设置。

mainApp
|--> core-module
| |--> src
| |--> build.gradle
| |--> gradle.properties
|
|--> lib-module
| |--> src
| |--> build.gradle
| |--> gradle.properties
|--> lib-another-module
| |--> src
| |--> build.gradle
| |--> gradle.properties
|--> settings.gradle
|--> build.gradle
mainApp/build.gradle我提过
subprojects {
test.dependsOn "CreateMessageKeys"
//test.dependsOn ":CreateMessageKeys"
//test.dependsOn ("CreateMessageKeys")
//test.dependsOn (":CreateMessageKeys") none of this working....

}

task CreateMessageKeys(type: CreateMessageKeysTask) {
destDir = "bundle-common/src/";
outputClass = "common.messages.MessageKeys";
}
和我的 core-module/build.gradle有一个测试目标作为
test {
useTestNG() {
useDefaultListeners = true
suites 'test/testng.xml'
}
}
但得到如下错误..我在这里错过了什么?
Caused by: groovy.lang.MissingMethodException: No signature of method: java.lang.String.dependsOn() is applicable for argument types: (String) values: [CreateMessageKeys]
Possible solutions: respondsTo(java.lang.String)
编辑
subprojects {
test.dependsOn(rootProject.tasks['CreateMessageKeys'])
}

task CreateMessageKeys(type: CreateMessageKeysTask) {
destDir = "bundle-common/src/";
outputClass = "common.messages.MessageKeys";
}
它会产生错误:
* What went wrong:
A problem occurred evaluating root project 'myApp'.
> Task with name 'CreateMessageKeys' not found in root project 'mainApp'.

最佳答案

任务定义看起来不正确,见 defining tasks .
它应该如下所示:

task ('CreateMessageKeys', type: CreateMessageKeysTask) {
destDir = "bundle-common/src/";
outputClass = "common.messages.MessageKeys";
}
或者
task (CreateMessageKeys, type: CreateMessageKeysTask) {
destDir = "bundle-common/src/";
outputClass = "common.messages.MessageKeys";
}

与这个问题无关:
在您的第二个示例中,可能是任务 CreateMessageKeys评估时还不存在。一种可能的解决方法如下:
subprojects.each {
it.afterEvaluate {
it.test.dependsOn(...)
}
}
或者简单地将任务定义放在这个 block 之上可以解决这个问题。

关于java - Gradle SubProject 任务没有被拾取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63450111/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com