-
-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configurations for effort and reportLevel are broken. #972
Comments
Hi @victorwss, try taking a look over at spotbugs main project https://github.com/spotbugs/spotbugs/blob/master/gradle/java.gradle. I just got that updated to 6.0.0-beta.3 and like you likely ran into it did not work per release notes options to try. Not sure if it will help you or not but worth taking a look. |
Could you check "Changes for Kotlin buildscripts" in the changelog for beta.1 release? Hope that it helps you. |
I confirm, my Gradle project doesn't like "low" as a string too. I had to use Confidence.valueOf('low') to overcome the error. But unfortunately, the import of the package doesn't work either. It seems that the classpath doesn't have required jars, or so. |
So, if I'm understanding correctly, this was somewhat intended? Anyway, it would be really appreciated if you could somehow either completely forgive the user for that or perhaps give a warning and continue business as usual in order to avoid breaking existing buildscripts without an outstanding reason for that when people are just bumping up dependencies. Or, at least fail with a very clear and direct error message telling what should be done to fix other than just "Dude, it is not a string anymore, it is now an enum. Good luck figuring out in Google how to fill in this correctly." Or minimally, make Anyway, the change is not a big deal. For now, I will stick to Keep up with the good job! |
I have stolen your code from the java.build file: def classLoader = plugins['com.github.spotbugs'].class.classLoader
def SpotBugsTask = classLoader.findLoadedClass( 'com.github.spotbugs.snom.SpotBugsTask' )
def SpotBugsEffort = classLoader.findLoadedClass( 'com.github.spotbugs.snom.Effort' )
def SpotBugsConfidence = classLoader.findLoadedClass( 'com.github.spotbugs.snom.Confidence' )
...
reportLevel = SpotBugsConfidence.LOW Seems it does the job. Can you please tell me, why is this working? Why have you decided to write it like that? |
Hi @Vest I'm still too new to gradle to understand the why. I had issues to until I did that. It didn't quite make sense to me either. If I recall, I saw another part of the script that did something similar so I gave that a shot. |
Same problem here, using a separate gradle file to configure spotbugs. Using the classloader works, but seems a bit hacky to me - there has to be a better way? |
I'm using the gradle plugin 6.0.2 with gradle 8.5 and I have the same problem. I'm using a separate gradle file to configure spotbugs. The classloader solution works fine, but it's too tricky and a bit ugly. When I was trying to write Is there a better way to configure spotbugs in a different gradle file? |
Same problem here as @javintx and @sebastian-peter Using a separate groovy gradle file to configure spotbugs and using ugly classloader workaround works. Would like to get rid of it. |
* In case you wonder, the following does not work: ``` reportLevel = com.github.spotbugs.snom.Confidence.LOW ``` * see: spotbugs/spotbugs-gradle-plugin#972
* In case you wonder, the following does not work: ``` reportLevel = com.github.spotbugs.snom.Confidence.LOW ``` * see: spotbugs/spotbugs-gradle-plugin#972
Having the same issue the example shown on https://github.com/spotbugs/spotbugs-gradle-plugin using
Literally doesn't work and will fail with message:
|
Same error for me, could not add |
Same problem here for me as well cannot import the Confidence object. The only thing that works is the class loader option referenced above from the user Vest. |
Another bump. This is fairly important — the documentation describes how to do something and it CLEARLY doesn't work. This is going to trip up a lot of developers until either the documentation is corrected or the bug is fixed! |
Unfortunately spent a lot of time trying to fix this issue, didn't find a better solution than the classloader solution above. |
same |
same here |
Until it's fixed i'm using:
Using |
* Initial cut for Java 21 support + lots of debug * Update PMD to 7.0.0-rc4 * PMD now passes * Checkstyle now passes * grdle 8.5 for full Java 21 support * Use official monocole * Initial cut for Java 21 support + lots of debug * Update PMD to 7.0.0-rc4 * PMD now passes * Checkstyle now passes * grdle 8.5 for full Java 21 support * Updates to reflect latest 17 and 21 releases * Tidy-up after 1st successful build * Tidy-up after 1st successful build * Tidy-up after 1st successful build * Updated: pmd to 7.0.0 gradle to 8.7 checkstyle to 10.15.0 spotbugs to 4.8.3 * PMD updates * Formatted output for downloadJRE and downloadJavaFXModules a little. Refactored code a little Removed few warnings detected by IDEA. * Removed an unnecessary empty line. * Use Linux 21.0.1 for aarch64 JavaFX Removed trailing spaces (IDEA) Applied few recommendations from Spotbugs (just to test it) * Updated Spotbugs Plugin to 6.0.9 (the solution was taken from spotbugs/spotbugs-gradle-plugin#972 (comment)) * Update deps * Initial cut for Java 21 support + lots of debug * Update PMD to 7.0.0-rc4 * PMD now passes * Checkstyle now passes * grdle 8.5 for full Java 21 support * Initial cut for Java 21 support + lots of debug * Update PMD to 7.0.0-rc4 * PMD now passes * Updates to reflect latest 17 and 21 releases * Tidy-up after 1st successful build * Tidy-up after 1st successful build * Tidy-up after 1st successful build * Updated: pmd to 7.0.0 gradle to 8.7 checkstyle to 10.15.0 spotbugs to 4.8.3 * PMD updates * Formatted output for downloadJRE and downloadJavaFXModules a little. Refactored code a little Removed few warnings detected by IDEA. * Removed an unnecessary empty line. * Use Linux 21.0.1 for aarch64 JavaFX Removed trailing spaces (IDEA) Applied few recommendations from Spotbugs (just to test it) * Updated Spotbugs Plugin to 6.0.9 (the solution was taken from spotbugs/spotbugs-gradle-plugin#972 (comment)) * Update deps * Last fixes for full pre release build to work * Add comments for removal of SecurityManager * * updated com.github.spotbugs to 6.0.15 * updated checkstyle to 10.17.0 * updated pmd to 7.1.0 * updated spotbugs to 4.8.5 * Corrected the distTar failure on Windows (#152) * Corrected the error UncheckedIOException related to the buildDirectory. It was resolved by Gradle to `C:...\pcgen\property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactorySFixedDirectory, C:...\pcgen\build))\launch4j` Updated few dependencies as well. Signed-off-by: Vest <[email protected]> * Formatted build.gradle, by putting a space character after "version:" Signed-off-by: Vest <[email protected]> --------- Signed-off-by: Vest <[email protected]> * Removed explicit "buildDirectory" variable. Replaced it with the lazy layout.buildDirectory Replaces projectDir with layout.projectDirectory, because the variable projectDir hides the property Project.projectDir Replaced "new File" with "file" Replaced many "eager" tasks with lazy tasks.register. Reconfigured many tasks in a lazy way Updated task-tree to v4.0.0 Renamed task all to allTasks, because it was confusing what it does. Formatted few lines in build scripts. Signed-off-by: Vest <[email protected]> * Added an explicit dependency between tasks -> this should be changed to input/output files instead (because the Jar task creates an *output* file, that will be an *input* file for the copyToOutput task). Corrected a wrong code of genProjectNsis Signed-off-by: Vest <[email protected]> * converted genProjectNsis to the "lazy" API. Removed buildDirectory as a variable, replaced it with layout.buildDirectory Signed-off-by: Vest <[email protected]> * converted buildNsis to the "lazy" API. Signed-off-by: Vest <[email protected]> * Removed 32-bit version from pcgen.nsi (NSIS installer) Replaced few tasks creation calls with the "register". Added /WX key (fail with warnings) for NSIS Corrected few "delete" calls Signed-off-by: Vest <[email protected]> * Upgrade Grade wrapper from 8.7 to 8.8 Signed-off-by: Vest <[email protected]> * Formatted code a little, replaced $projectDir with layout.projectDirectory Fixed failed :prepareRelease task. Formatted the description, so it will not have a long line in source code. Signed-off-by: Vest <[email protected]> * Fixed a typo in the property name (build.gradle) * Corrected an issue with JavaFX modules (a wrong relative folder was used). Simplified the :idea task using "fileTree" * Corrected the :genDataList task * Refactored release.gradle, this reduced the number of lines. * Refactored release.gradle, this reduced the number of lines. * Replaced eager tasks with lazy Replaced projectDir with layout.projectDirectory Moved :downloadJRE and :downloadJavaFXModules to the "lazy" (doLast) section. Now, JRE and JavaFX modules are downloaded only, when the task is required/called. Slightly improved the logging for :downloadJRE Detached :downloadJRE from :downloadJavaFXModules (they are independent). Removed codes, where the modules and JDK were extracted. It seems that the new JDK doesn't have files that we omitted in the past. Adjusted dependencies, because :downloadJRE is an independent task now. Formatted pcgen.nsi * Corrected the broken tasks: :jpackageImage, :buildNsis Removed :clean from :prepareRelease. * Corrected types of Files in :checksum Signed-off-by: Vest <[email protected]> * Refactored build.gradle: * renamed :all to :allTasks in comments * :downloadJavaFXModules is lazy, tries to reuse the downloaded files, removes empty folders (Window JRE still contains empty folders - this is TODO) * :downloadJavaFXModules remove local "mods/" from the task. This task is used to download modules for all supported platforms only * :downloadJavaFXLocal added for local builds only (used for different tests, for :run). It isn't used for packaging, but for compilation only * :extractJavaFXLocal extracts downloaded JavaFX binaries into mods/. * :compileJava - we don't download all JREs and JavaFX artifacts anymore. Added a dependency to :extractJavaFXLocal * :test - removes dependencies to :downloadJRE, :downloadJavaFXModules Corrected a typo in build-gradle.xml Ant Now we add :compileJava as a direct dependency to all ant tasks, where plugins are built. * Removed unhelpful println calls from some tasks such as :copyToLibs or :downloadJRE Corrected a bug in :downloadJRE, now we delete the JDK folder, if it contains an old JDK. Previously, we couldn't extract JDK into it (unfortunately, the deletion removes JavaFX, if it has been downloaded previously). :downloadJavaFXLocal - OS_NAME isn't used, because it is "private" :clean moved to the bottom, and it deletes probably everything. :run doesn't require all JDKs and all JavaFX modules. It simply depends on :extractJavaFXLocal now. Two dependencies were removed. Slightly improved the logging of :buildNsis, but this steps requires more testing. * Fixed a broken plugin, caused by 187f6c2 * Removed println in PlayerCharacter.java, that was added in #7056 * Updated dependencies in build.gradle and reporting.gradle * Upgraded pmd found several issues in source code that were corrected: * This collection could be an EnumMap * Unnecessary explicit array creation for varargs method call * Lambda expression could be written as a method reference: xxxxxx::yyyyyyy * Mistakenly collapsed imports in a previous commit, and violated :checkstyleMain * Upgraded gradlew to 8.9 Refactored :downloadJavaFXModules, :downloadJRE, :genDataList, :genProjectNsis to support "up-to-date" (kind of a caching) feature from gradle Added more logging to :buildNsis * Moved the creation of the nsisRelease folder from :genProjectNsis to :buildNsis * Fixed *.xsl templates: they were using a function str:substring-after-last from xsltsl (https://www.w3.org/TR/xslt11/). The second parameter has the name "chars", but the code was using "char". * Refactored :jpackage, and made is shorter. * :clean - delete files/folders that are generated during the build. * :clean - delete files/folders that are generated during the build: outputsheets/d20/western/htmlxml/psheet_fantasy_std.htm * Refactored :copyMasterSheets * Attempt to resolve the bug, when the JRE is packaged before JavaFX modules are downloaded. * Upgraded JDK and JavaFX to 21.0.4 * Language bundle date updates * Refactored Gradle scripts to support Mac builds (#175) * Upgraded Gradle wrapper to 8.10.2 * Updated com.github.spotbugs to 6.0.23 Updated checkstyle to 10.18.1 Updated pmd to 7.6.0 Reffactored Main.java -> use streams, now it has a "draft" branch that is executed, when the application is launched from Mac's bundle * Fixed an error in ConfigurationSettings.java detected by Checkstyle. * Corrected a logical error in ConfigurationSettings.java --------- Signed-off-by: Vest <[email protected]> Co-authored-by: Vest <[email protected]>
I am using spotbugs gradle plugin version 6.0.0-beta.3 with Spotbugs 4.7.3, Gradle 8.4-rc-2 and Java 21.
Trying to recompile an old project give some problems. It seems that the
effort
andreportLevel
are broken.My gradle file used to contain that:
It gives the following error:
After fixing it, it also complains about
reportLevel
not being an instance ofConfidence
. For fixing it, I needed to change it to that:Using
com.github.spotbugs.snom.Confidence.LOW
doesn't works for some reason that I couldn't understand, it seems that it somehow wrongly thinks thatLOW
is a class.Anyway, I doubt that this change was intended, at least not in the way it is.
I can provide a minimal project reproducing it, if you really need to.
The text was updated successfully, but these errors were encountered: