gpt4 book ai didi

Gradle : sourceSets. test.classes 未找到

转载 作者:行者123 更新时间:2023-12-04 04:05:39 25 4
gpt4 key购买 nike

我试图让我的一个项目 (ProjectA) 生成一个包含所有测试类的 jar 文件,以便它可以在 ProjectB 中使用。
我做了一些研究,发现这是一个可能的解决方案:Create test jar artifact in gradle .也就是说,下面的代码片段应该可以解决问题。

apply plugin: 'java'

task testJar(type: Jar) {
classifier = 'tests'
from sourceSets.test.classes
}
但是,当我将上述内容添加到我的 build.gradle 中时,我收到以下错误消息:
  • What went wrong:

A problem occurred evaluating root project 'gradle_project'.

Could not find property 'sourceSets' on task ':testJar'.


我已经在 Google 和 Gradle 文档中搜索了更多信息,但要么已将其删除,而没有在我能找到的任何地方记录它,要么我使用错误。我怀疑后者,只是不知道我做错了什么。
我在 subprojects{} 中尝试了相同的代码片段部分,但随后我收到以下错误消息:
  • What went wrong:

A problem occurred evaluating root project 'gradle_project'.

Cannot get the value of write-only property 'classes' on source set test.

最佳答案

通过以下步骤解决了它:

第 1 步:将代码片段移到 subprojects{} 中部分

第 2 步:sourceSets.test.classes已被删除。 sourceSets.test.output似乎可以解决问题。找到这个:Creating a Jar of test binaries - Gradle

关于Gradle : sourceSets. test.classes 未找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10835034/

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