Skip to content

Commit

Permalink
[cleanup] Address long noted trait issue of bringing up properties to…
Browse files Browse the repository at this point in the history
… trait directly
  • Loading branch information
hazendaz committed Nov 11, 2024
1 parent 028a1a3 commit 1ef0895
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import org.apache.maven.plugins.annotations.ResolutionScope
import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver
import org.codehaus.plexus.resource.ResourceManager

abstract class BaseViolationCheckMojo extends AbstractMojo {
abstract class BaseViolationCheckMojo extends AbstractMojo implements SpotBugsPluginsTrait {

/** Location where generated html will be created. */
@Parameter(defaultValue = '${project.reporting.outputDirectory}', required = true)
Expand Down Expand Up @@ -223,21 +223,6 @@ abstract class BaseViolationCheckMojo extends AbstractMojo {
@Parameter(property = 'spotbugs.omitVisitors')
String omitVisitors

/**
* The plugin list to include in the report. This is a comma-delimited list.
* <p>
* Potential values are a filesystem path, a URL, or a classpath resource.
* <p>
* This parameter is resolved as resource, URL, then file. If successfully
* resolved, the contents of the configuration is copied into the
* <code>${project.build.directory}</code>
* directory before being passed to Spotbugs as a plugin file.
*
* @since 1.0-beta-1
*/
@Parameter(property = 'spotbugs.pluginList')
String pluginList

/**
* Restrict analysis to the given comma-separated list of classes and packages.
*
Expand Down
14 changes: 0 additions & 14 deletions src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsGui.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,6 @@ class SpotBugsGui extends AbstractMojo implements SpotBugsPluginsTrait {
@Parameter(defaultValue = 'Default', property = 'spotbugs.effort')
String effort

/** The plugin list to include in the report. This is a SpotbugsInfo.COMMA-delimited list. */
@Parameter(property = 'spotbugs.pluginList')
String pluginList

/**
* Collection of PluginArtifact to work on. (PluginArtifact contains groupId, artifactId, version, type, classifier.)
* See <a href="./usage.html#Using Detectors from a Repository">Usage</a> for details.
*
* @since 2.4.1
* @since 4.8.3.0 includes classfier
*/
@Parameter
PluginArtifact[] plugins

/** Artifact resolver, needed to download the coreplugin jar. */
@Inject
ArtifactResolver artifactResolver
Expand Down
25 changes: 0 additions & 25 deletions src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsMojo.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -346,31 +346,6 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait {
@Parameter(property = 'spotbugs.omitVisitors')
String omitVisitors

/**
* The plugin list to include in the report. This is a comma-delimited list.
* <p>
* Potential values are a filesystem path, a URL, or a classpath resource.
* <p>
* This parameter is resolved as resource, URL, then file. If successfully
* resolved, the contents of the configuration is copied into the
* <code>${project.build.directory}</code>
* directory before being passed to Spotbugs as a plugin file.
*
* @since 1.0-beta-1
*/
@Parameter(property = 'spotbugs.pluginList')
String pluginList

/**
* Collection of PluginArtifact to work on. (PluginArtifact contains groupId, artifactId, version, type, classifier.)
* See <a href="./usage.html#Using Detectors from a Repository">Usage</a> for details.
*
* @since 2.4.1
* @since 4.8.3.0 includes classifier
*/
@Parameter
PluginArtifact[] plugins

/**
* Restrict analysis to the given comma-separated list of classes and packages.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package org.codehaus.mojo.spotbugs
import org.apache.maven.artifact.Artifact

import org.apache.maven.plugin.logging.Log
import org.apache.maven.plugins.annotations.Parameter
import org.apache.maven.project.ProjectBuildingRequest
import org.apache.maven.plugin.MojoExecutionException

Expand All @@ -40,12 +41,38 @@ trait SpotBugsPluginsTrait {
abstract Log getLog()
abstract ResourceManager getResourceManager()

// TODO This has been fixed for 2 years now, apply as noted...
// properties in traits should be supported but don't compile currently:
// https://issues.apache.org/jira/browse/GROOVY-7536
// when fixed, should move pluginList and plugins properties here
abstract String getPluginList()
abstract PluginArtifact[] getPlugins()
/**
* <p>
* The plugin list to include in the report. This is a comma-delimited list.
* </p>
*
* <p>
* Potential values are a filesystem path, a URL, or a classpath resource.
* </p>
*
* <p>
* This parameter is resolved as resource, URL, then file. If successfully
* resolved, the contents of the configuration is copied into the
* <code>${project.build.directory}</code>
* directory before being passed to Spotbugs as a plugin file.
* </p>
*
* @since 1.0-beta-1
*/
@Parameter(property = "spotbugs.pluginList")
String pluginList

/**
* <p>
* Collection of PluginArtifact to work on. (PluginArtifact contains groupId, artifactId, version, type.)
* See <a href="./usage.html#Using Detectors from a Repository">Usage</a> for details.
* </p>
*
*
* @since 2.4.1
*/
@Parameter
PluginArtifact[] plugins;

/**
* Adds the specified plugins to spotbugs. The coreplugin is always added first.
Expand Down

0 comments on commit 1ef0895

Please sign in to comment.