gpt4 book ai didi

java - 在构建 xml 中包含 Spotbugs 目标 (ant)

转载 作者:行者123 更新时间:2023-11-30 05:41:37 28 4
gpt4 key购买 nike

对不起,我又挣扎了。所以taskdef工作正常,但我无法实际使用spotbugs。

<target name="bugs" depends="compile">

<spotbugs home="${spotbugs.home}"
output="${spotbugs.output}"
outputFile="bugs.${spotbugs.output}"
excludeFilter="${spotbugs.exclude}">
<sourcePath path="."/>
<auxClassPath path="."/>
<fileset dir="." includes="${package}/*.class"/>
</spotbugs>

所以我想检查代码

ant -Dpackage=einstieg 错误

并收到“问题:无法创建任务或输入 Spotbugs”。我用于 checkstyle 的相同模式效果非常好。任务定义指向发现错误和所需的类 - 没有任何错误。有什么建议吗?

所以我认为发现 bug 的意义根本不存在。但/lib目录下有合适的文件。

这是任务定义的样子:

<!-- spotbugs settings -->
<property name="spotbugs.home" value="C:/ant/lib"/>
<property name="spotbugs.output" value="xml"/>
<property name="spotbugs.exclude"
value="C:/Users/wolfbiker/Documents/einstieg/exclude_filter.xml"/>
<taskdef resource="edu/umd/cs/findbugs/anttask/tasks.properties"
classpath="${spotbugs.home}/spotbugs-ant.jar"/>

最佳答案

我在阅读Using the SpotBugs Ant task时想到详细地你会看到你的

<property name="spotbugs.home" value="C:/ant/lib"/>

不应该指向您复制spotbugs-ant.jar的ant home,而是应该指向spotbugs安装本身 - 这与spotbugs ant-task不同。因此,在 ant-task 旁边还必须安装 Spotbugs。

这也意味着您必须更改类路径

<taskdef resource="edu/umd/cs/findbugs/anttask/tasks.properties" classpath="${spotbugs.home}/spotbugs-ant.jar"/>

指向应该已复制到 ant/lib 目录的 Spotbugs-ant.jar。

关于java - 在构建 xml 中包含 Spotbugs 目标 (ant),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55528229/

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