From aac3c487e6bd335c5de97dd0fd51946bf4479871 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 13 Sep 2023 15:58:16 +0200 Subject: [PATCH 1/2] Enable the spotbugs plugin --- buildSrc/build.gradle | 2 ++ buildSrc/gradle.properties | 3 ++- .../groovy/org.lflang.java-conventions.gradle | 9 +++++++++ config/spotbugs/exclude.xml | 20 +++++++++++++++++++ gradle.properties | 1 + 5 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 config/spotbugs/exclude.xml diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index db34ac5c23..7c2d942ef8 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -13,6 +13,8 @@ dependencies { // https://mvnrepository.com/artifact/com.diffplug.spotless/spotless-lib-extra implementation group: 'com.diffplug.spotless', name: 'spotless-lib-extra', version: spotlessLibVersion + implementation group: 'com.github.spotbugs.snom', name: 'spotbugs-gradle-plugin', version: spotbugsPluginVersion + implementation "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" implementation "com.diffplug.spotless:spotless-plugin-gradle:$spotlessVersion" diff --git a/buildSrc/gradle.properties b/buildSrc/gradle.properties index 217c42b57c..a8cd2581d4 100644 --- a/buildSrc/gradle.properties +++ b/buildSrc/gradle.properties @@ -2,4 +2,5 @@ spotlessVersion=6.11.0 spotlessLibVersion=2.30.0 kotlinVersion=1.6.21 -shadowJarVersion=7.1.2 \ No newline at end of file +shadowJarVersion=7.1.2 +spotbugsPluginVersion=5.1.3 \ No newline at end of file diff --git a/buildSrc/src/main/groovy/org.lflang.java-conventions.gradle b/buildSrc/src/main/groovy/org.lflang.java-conventions.gradle index 9fc4fa50f9..d5697d312c 100644 --- a/buildSrc/src/main/groovy/org.lflang.java-conventions.gradle +++ b/buildSrc/src/main/groovy/org.lflang.java-conventions.gradle @@ -2,6 +2,7 @@ plugins { id 'java' id 'com.diffplug.spotless' id 'org.lflang.platform' + id 'com.github.spotbugs' } repositories { @@ -19,6 +20,14 @@ spotless { } } +spotbugs { + toolVersion = spotbugsToolVersion + excludeFilter.set( + rootProject.file('config/spotbugs/exclude.xml') + ) +} + + configurations.all { resolutionStrategy { dependencySubstitution { diff --git a/config/spotbugs/exclude.xml b/config/spotbugs/exclude.xml new file mode 100644 index 0000000000..fdd333f455 --- /dev/null +++ b/config/spotbugs/exclude.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/gradle.properties b/gradle.properties index 4b062644e0..636741363c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,6 +21,7 @@ xtextVersion=2.31.0 klighdVersion=2.3.0.v20230606 freehepVersion=2.4 swtVersion=3.124.0 +spotbugsToolVersion=4.7.3 [manifestPropertyNames] org.eclipse.xtext=xtextVersion From 9ea0a85beaf7446319133560fd02b088b1bc0d91 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Thu, 14 Sep 2023 14:56:32 +0200 Subject: [PATCH 2/2] treat spotbugs issues as warnings, not errors --- buildSrc/src/main/groovy/org.lflang.java-conventions.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/buildSrc/src/main/groovy/org.lflang.java-conventions.gradle b/buildSrc/src/main/groovy/org.lflang.java-conventions.gradle index d5697d312c..8730fcf7b7 100644 --- a/buildSrc/src/main/groovy/org.lflang.java-conventions.gradle +++ b/buildSrc/src/main/groovy/org.lflang.java-conventions.gradle @@ -25,6 +25,7 @@ spotbugs { excludeFilter.set( rootProject.file('config/spotbugs/exclude.xml') ) + ignoreFailures = true }