我要升级到Gradle 6.7。
我跟随https://github.com/spotbugs/spotbugs-gradle-plugin,并更新了Gradle以选择6.7。这给了我一些有关Spotbug的错误,因此我在 buildScript 中更新了 spotbugs 版本,如下所示
buildscript {
dependencies {
.
.
classpath 'gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.6.0'
.
.
}
}
并按照我的建议添加
dependencies {
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.10.1'
spotbugs 'com.github.spotbugs:spotbugs:4.0.0'
}
并更新
spotbugs {
toolVersion = "4.1.4"
}
此后,我开始出现以下两个错误
1。评估脚本时发生问题。存在一个扩展名为'sourceSets'的扩展。您不应该通过属性设置器重新分配它。
在我的.gradle文件中,将sourceSets设置为
spotbugs {
toolVersion = "4.1.4"
sourceSets = [sourceSets.main, sourceSets.test, sourceSets.integrationTest]
}
Caused by: org.gradle.api.tasks.TaskInstantiationException: Could not create task of type 'SpotBugsTask'.
at org.gradle.api.internal.project.taskfactory.TaskFactory$1.call(TaskFactory.java:97)
at org.gradle.api.internal.project.taskfactory.TaskFactory$1.call(TaskFactory.java:84)
at org.gradle.util.GUtil.uncheckedCall(GUtil.java:442)
at org.gradle.api.internal.AbstractTask.injectIntoNewInstance(AbstractTask.java:201)
at org.gradle.api.internal.project.taskfactory.TaskFactory.create(TaskFactory.java:84)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory.create(AnnotationProcessingTaskFactory.java:48)
at org.gradle.api.internal.tasks.DefaultTaskContainer.createTask(DefaultTaskContainer.java:326)
at org.gradle.api.internal.tasks.DefaultTaskContainer.access$200(DefaultTaskContainer.java:77)
at org.gradle.api.internal.tasks.DefaultTaskContainer$TaskCreatingProvider.createDomainObject(DefaultTaskContainer.java:701)
at org.gradle.api.internal.tasks.DefaultTaskContainer$TaskCreatingProvider.createDomainObject(DefaultTaskContainer.java:658)
at org.gradle.api.internal.DefaultNamedDomainObjectCollection$AbstractDomainObjectCreatingProvider.tryCreate(DefaultNamedDomainObjectCollection.java:941)
... 184 more
Caused by: java.lang.NoSuchMethodError: 'java.lang.Object org.gradle.util.DeprecationLogger.whileDisabled(org.gradle.internal.Factory)'
at com.github.spotbugs.SpotBugsTask.createReports(SpotBugsTask.java:102)
at com.github.spotbugs.SpotBugsTask.<init>(SpotBugsTask.java:98)
at com.github.spotbugs.SpotBugsTask_Decorated.<init>(Unknown Source)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.gradle.internal.instantiation.generator.AsmBackedClassGenerator$InvokeConstructorStrategy.newInstance(AsmBackedClassGenerator.java:1969)
at org.gradle.internal.instantiation.generator.AbstractClassGenerator$GeneratedClassImpl$GeneratedConstructorImpl.newInstance(AbstractClassGenerator.java:468)
at org.gradle.internal.instantiation.generator.DependencyInjectingInstantiator.doCreate(DependencyInjectingInstantiator.java:64)
at org.gradle.internal.instantiation.generator.DependencyInjectingInstantiator.newInstanceWithDisplayName(DependencyInjectingInstantiator.java:50)
at org.gradle.api.internal.project.taskfactory.TaskFactory$1.call(TaskFactory.java:90)
... 194 more
对解决这些错误有帮助吗?
答案 0 :(得分:0)
您不能再使用 sourceSets
属性。最好重构为
spotbugs {
toolVersion = "4.1.4"
}
spotbugsTest {
enabled = false
}
更多信息:https://github.com/spotbugs/spotbugs-gradle-plugin/issues/308#issuecomment-659050508