我正在升级到 Gradle 6.7。
我关注了https://github.com/spotbugs/spotbugs-gradle-plugin并更新了 Gradle 以选择 6.7。这给了我一些关于 spotbugs 的错误,所以我在 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
修复这些错误有什么帮助吗?