From 3d58efb10b456878e08a88c0a3c11dfc9669579c Mon Sep 17 00:00:00 2001 From: Said Tahsin Dane Date: Thu, 21 Nov 2019 20:46:57 +0100 Subject: [PATCH] Fix Gradle 6 issue Gradle loads classes with all its dependencies. So FindbugsConfigurator.create would fail on Gradle 6. Guarding it in a separate Factory class solves the issue --- .../StaticAnalysisPlugin.groovy | 4 ++-- .../findbugs/FindbugsConfigurator.groovy | 13 +----------- .../FindbugsConfiguratorFactory.groovy | 20 +++++++++++++++++++ 3 files changed, 23 insertions(+), 14 deletions(-) create mode 100644 plugin/src/main/groovy/com/novoda/staticanalysis/internal/findbugs/FindbugsConfiguratorFactory.groovy diff --git a/plugin/src/main/groovy/com/novoda/staticanalysis/StaticAnalysisPlugin.groovy b/plugin/src/main/groovy/com/novoda/staticanalysis/StaticAnalysisPlugin.groovy index 36f1719..cf45d3d 100644 --- a/plugin/src/main/groovy/com/novoda/staticanalysis/StaticAnalysisPlugin.groovy +++ b/plugin/src/main/groovy/com/novoda/staticanalysis/StaticAnalysisPlugin.groovy @@ -3,7 +3,7 @@ package com.novoda.staticanalysis import com.novoda.staticanalysis.internal.Configurator import com.novoda.staticanalysis.internal.checkstyle.CheckstyleConfigurator import com.novoda.staticanalysis.internal.detekt.DetektConfigurator -import com.novoda.staticanalysis.internal.findbugs.FindbugsConfigurator +import com.novoda.staticanalysis.internal.findbugs.FindbugsConfiguratorFactory import com.novoda.staticanalysis.internal.ktlint.KtlintConfigurator import com.novoda.staticanalysis.internal.lint.LintConfigurator import com.novoda.staticanalysis.internal.pmd.PmdConfigurator @@ -42,7 +42,7 @@ class StaticAnalysisPlugin implements Plugin { [ CheckstyleConfigurator.create(project, violationsContainer, evaluateViolations), PmdConfigurator.create(project, violationsContainer, evaluateViolations), - FindbugsConfigurator.create(project, violationsContainer, evaluateViolations), + FindbugsConfiguratorFactory.create(project, violationsContainer, evaluateViolations), SpotBugsConfigurator.create(project, violationsContainer, evaluateViolations), DetektConfigurator.create(project, violationsContainer, evaluateViolations), KtlintConfigurator.create(project, violationsContainer, evaluateViolations), diff --git a/plugin/src/main/groovy/com/novoda/staticanalysis/internal/findbugs/FindbugsConfigurator.groovy b/plugin/src/main/groovy/com/novoda/staticanalysis/internal/findbugs/FindbugsConfigurator.groovy index 658ce08..fb86873 100644 --- a/plugin/src/main/groovy/com/novoda/staticanalysis/internal/findbugs/FindbugsConfigurator.groovy +++ b/plugin/src/main/groovy/com/novoda/staticanalysis/internal/findbugs/FindbugsConfigurator.groovy @@ -4,7 +4,6 @@ import com.novoda.staticanalysis.Violations import com.novoda.staticanalysis.internal.CodeQualityConfigurator import org.gradle.api.Action import org.gradle.api.DomainObjectSet -import org.gradle.api.NamedDomainObjectContainer import org.gradle.api.Project import org.gradle.api.Task import org.gradle.api.file.FileCollection @@ -24,17 +23,7 @@ class FindbugsConfigurator extends CodeQualityConfigurator violationsContainer, - Task evaluateViolations) { - Violations violations = violationsContainer.maybeCreate('Findbugs') - return new FindbugsConfigurator(project, violations, evaluateViolations) - } - - private FindbugsConfigurator(Project project, - Violations violations, - Task evaluateViolations) { + FindbugsConfigurator(Project project, Violations violations, Task evaluateViolations) { super(project, violations, evaluateViolations) } diff --git a/plugin/src/main/groovy/com/novoda/staticanalysis/internal/findbugs/FindbugsConfiguratorFactory.groovy b/plugin/src/main/groovy/com/novoda/staticanalysis/internal/findbugs/FindbugsConfiguratorFactory.groovy new file mode 100644 index 0000000..ed086f2 --- /dev/null +++ b/plugin/src/main/groovy/com/novoda/staticanalysis/internal/findbugs/FindbugsConfiguratorFactory.groovy @@ -0,0 +1,20 @@ +package com.novoda.staticanalysis.internal.findbugs + +import com.novoda.staticanalysis.Violations +import org.gradle.api.NamedDomainObjectContainer +import org.gradle.api.Project +import org.gradle.api.Task + +@Deprecated +class FindbugsConfiguratorFactory { + + private FindbugsConfiguratorFactory() { + } + + static FindbugsConfigurator create(Project project, + NamedDomainObjectContainer violationsContainer, + Task evaluateViolations) { + Violations violations = violationsContainer.maybeCreate('Findbugs') + return new FindbugsConfigurator(project, violations, evaluateViolations) + } +}