gpt4 book ai didi

java - gradle 测试和主要设置相同

转载 作者:太空宇宙 更新时间:2023-11-04 11:06:33 25 4
gpt4 key购买 nike

出于各种原因,不值得讨论,但我认为非常重要 - 我只想有一个源集 - java 源,并在其中进行测试 - 但我不知道如何使用 gradle 来做到这一点。

如果我将测试源集指向同一目录 - 我会收到错误消息,指出两个源集不能共享同一根目录。

gradle 中有没有简单的方法来告诉“测试”任务只使用主源集?

最佳答案

结果比我想象的要容易,采用完全不同的方式,只需添加一个新的测试任务

task mainTest( type: Test ) {
description = "Runs tests embedded in the code"
testClassesDir = sourceSets.main.output.classesDir
classpath = sourceSets.main.runtimeClasspath
binResultsDir=file("$buildDir/main-test-results")
reports {
html.destination = "$buildDir/reports/main"
junitXml.destination="$buildDir/reports/main"
}
}

check.dependsOn mainTest;

关于java - gradle 测试和主要设置相同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46419497/

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