Open jochenberger opened 4 years ago
I guess you upgraded not only spotbugs-gradle-plugin but also Gradle.
It could be problem of Gradle side. Make sure you can reproduce this problem with spotbugs-gradle-plugin v3 and the latest Gradle version. If you can reproduce, we're sure that it's not our problem, so we can close this issue safely.
refs #95
I can't.
Then please share the mcve project to reproduce. Thanks! But actually what this plugin uses is a Gradle official plugin, so I'm not sure we can provide a fix or not.
Just add this build file in an empty directory and run gradle spotbugsMain
.
groovy
plugins {
id "com.github.spotbugs" version '4.0.7'
}
repositories {
jcenter()
}
apply plugin: 'java'
spotbugsMain.reports.xml.enabled = false
Could it be that the time that the reports objects are created changed from the 3.x releases? It looks as if the xml
entry is not yet created at the time that I try to disable it.
Yes it's recreated, to eliminate the dependency on Gradle's internal API.
In v3.0.0 we have the SpotBugsReport interface which extends a Gradle internal API. So in v4.0.0 we changed it to a plain NamedDomainObjectContainer<SpotBugsReport>.
I'll try to solve this issue, by making a SpotBugsReport
interface which extends NamedDomainObjectContainer, and delegate to getByName(String)
like v3.0.0.
I'll try to solve this issue, by making a SpotBugsReport interface which extends NamedDomainObjectContainer, and delegate to getByName(String) like v3.0.0.
This way doesn't work, because
SpotBugsReport
interface, it needs to extends NamedDomainObjectContainer
. But NamedDomainObjectContainer
instances need to be created by a Gradle API ObjectFactory.domainObjectContainer(...)
and it cannot create instance of user-defined one.getMissingProperty(String)
is the method invoked when the missing property is called, however, it's method of internal API so we cannot hook it.A workaround is that, configure the reports
property of SpotBugsTask
like below, but it breaks another backward compatibility: 'can generate a report in specified reportsDir' test in ReportFunctionalTest
.
.configure {
it.create("xml").setEnabled(false);
it.create("html").setEnabled(false);
it.create("text").setEnabled(false);
}
So for now, we have no solution on this issue. We may handle this as an intentional breaking change. :sob:
FYI: I've run into this issue during https://issues.apache.org/jira/browse/FINERACT-947, and inspired by https://github.com/spotbugs/spotbugs-gradle-plugin#configure-the-spotbugstask, have replaced our:
// To generate an HTML report instead of XML
tasks.withType(SpotBugsTask) {
reports.xml.enabled = false
reports.html.enabled = true
reportLevel = "high"
}
with:
// To generate an HTML report instead of XML
spotbugs {
reportLevel = 'high'
}
spotbugsMain {
reports {
html {
enabled = true
stylesheet = 'fancy-hist.xsl'
}
}
}
spotbugsTest {
reports {
html {
enabled = true
stylesheet = 'fancy-hist.xsl'
}
}
}
spotbugsIntegrationTest {
reports {
html {
enabled = true
stylesheet = 'fancy-hist.xsl'
}
}
}
Note also new issue #242.
+1. Same issue with Spotbugs v4.0.3 and spotbugs-gradle-plugin v4.2.1.
It publishes the reports in mail.xml regardless the path defined with xml.destination or html.destination
spotbugs classpath "com.github.spotbugs.snom:spotbugs-gradle-plugin:4.7.10" spotbugs 'com.github.spotbugs:spotbugs:4.5.0'
when i use report. but it just create one report. html or xml . now i want to create both reports.
Generate HTML and XML reports at the same time,how can i do
reports {
xml.configure {
required = true
outputLocation = file("$reportsConfigDir/spotbugs/spotbugs.xml")
}
html.configure {
required = true
outputLocation = file("$reportsConfigDir/spotbugs/spotbugs.html")
stylesheet = 'fancy-hist.xsl'
}
}
how can i do ?
In 3.x, you could write
If you try that with 4.0(.5), you get
You have to use