Skip to content

Commit

Permalink
[cleanup] Address long standing comment to move pluginList / plugins …
Browse files Browse the repository at this point in the history
…to trait
  • Loading branch information
hazendaz committed Jan 21, 2025
1 parent 7cf8924 commit 7a37019
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ import org.apache.maven.plugins.annotations.LifecyclePhase
import org.apache.maven.plugins.annotations.Mojo
import org.apache.maven.plugins.annotations.Parameter
import org.apache.maven.plugins.annotations.ResolutionScope
import org.apache.maven.repository.RepositorySystem
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 @@ -104,6 +105,13 @@ abstract class BaseViolationCheckMojo extends AbstractMojo {
@Parameter(property = 'plugin.artifacts', readonly = true, required = true)
List pluginArtifacts

/**
* List of Remote Repositories used by the resolver.
*
*/
@Parameter(property = "project.remoteArtifactRepositories", required = true, readonly = true)
List remoteRepositories

/** Maven Session. */
@Parameter (defaultValue = '${session}', readonly = true, required = true)
MavenSession session
Expand Down Expand Up @@ -137,6 +145,13 @@ abstract class BaseViolationCheckMojo extends AbstractMojo {
@Inject
ArtifactResolver artifactResolver

/**
* Used to look up Artifacts in the remote repository.
*
*/
@Component(role = RepositorySystem.class)
RepositorySystem factory

/**
* File name of the include filter. Only bugs in matching the filters are reported.
* <p>
Expand Down Expand Up @@ -223,21 +238,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 7a37019

Please sign in to comment.