Class ValidateConfigurationMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.revapi.maven.ValidateConfigurationMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
@Mojo(name="validate-configuration", defaultPhase=VALIDATE, threadSafe=true) public class ValidateConfigurationMojo extends org.apache.maven.plugin.AbstractMojo
- Since:
- 0.4.0
- Author:
- Lukas Krejci
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ValidateConfigurationMojo.ValidateReporter
-
Field Summary
Fields Modifier and Type Field Description protected boolean
alwaysCheckForReleaseVersion
If true (the default) revapi will always download the information about the latest version from the remote repositories (instead of using locally cached info).protected org.codehaus.plexus.configuration.PlexusConfiguration
analysisConfiguration
The JSON or XML configuration of various analysis options.protected Object[]
analysisConfigurationFiles
The list of files containing the configuration of various analysis options.protected boolean
checkDependencies
Whether to include the dependencies in the API checks.protected String
disallowedExtensions
Deprecated.since 0.11.0, use thepipelineConfiguration
insteadprotected boolean
expandProperties
If set to true, the Maven properties will be expanded in the configuration before it is supplied to Revapi.protected boolean
failBuildOnProblemsFound
If true (the default), the maven plugin will fail the build when it finds API problems (e.g.protected String
failCriticality
The minimum criticality of the found differences at which to fail the build.protected boolean
failOnMissingConfigurationFiles
Set to false if you want to tolerate files referenced in theanalysisConfigurationFiles
missing on the filesystem and therefore not contributing to the analysis configuration.protected boolean
failOnUnresolvedArtifacts
If true, the build will fail if one of the old or new artifacts fails to be resolved.protected boolean
failOnUnresolvedDependencies
If true, the build will fail if some of the dependencies of the old or new artifacts fail to be resolved.protected FailSeverity
failSeverity
Deprecated.use the newfailCriticality
protected String[]
newArtifacts
The coordinates of the new artifacts.protected PromotedDependency[]
newPromotedDependencies
A list of dependencies of the new artifact(s) that should be considered part of the new API.protected String
newVersion
The new version of the artifact.protected String[]
oldArtifacts
The coordinates of the old artifacts.protected PromotedDependency[]
oldPromotedDependencies
A list of dependencies of the old artifact(s) that should be considered part of the old API.protected String
oldVersion
If you don't want to compare a different artifact than the one being built, specifying the just the old version is simpler way of specifying the old artifact.protected org.codehaus.plexus.configuration.PlexusConfiguration
pipelineConfiguration
The JSON or XML configuration of the extensions pipeline.protected org.apache.maven.project.MavenProject
project
protected PromotedDependency[]
promotedDependencies
A list of dependencies of both the old and new artifact(s) that should be considered part of the old/new API.protected org.eclipse.aether.RepositorySystem
repositorySystem
protected org.eclipse.aether.RepositorySystemSession
repositorySystemSession
protected boolean
resolveProvidedDependencies
When establishing the API classes, Revapi by default also looks through theprovided
dependencies.protected boolean
resolveTransitiveProvidedDependencies
In addition toresolveProvidedDependencies
this property further controls how provided dependencies are resolved.protected boolean
skip
Whether to skip the mojo execution.protected String
versionFormat
If set, this property demands a format of the version string when theoldVersion
ornewVersion
parameters are set toRELEASE
orLATEST
special version strings.
-
Constructor Summary
Constructors Constructor Description ValidateConfigurationMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.revapi.AnalysisResult
analyze(Class<? extends org.revapi.Reporter> reporter, org.revapi.PipelineConfiguration.Builder pipelineConfiguration, Object... contextDataKeyValues)
protected org.revapi.Criticality
determineMaximumCriticality(org.revapi.PipelineConfiguration pipelineConfiguration)
void
doExecute()
void
execute()
protected boolean
initializeComparisonArtifacts()
protected Analyzer
prepareAnalyzer(org.apache.maven.project.MavenProject project, org.revapi.PipelineConfiguration.Builder pipelineConfiguration, Class<? extends org.revapi.Reporter> reporter, Map<String,Object> contextData)
protected Analyzer
prepareAnalyzer(org.apache.maven.project.MavenProject project, org.revapi.PipelineConfiguration.Builder pipelineConfiguration, Class<? extends org.revapi.Reporter> reporter, Map<String,Object> contextData, Map<String,Object> propertyOverrides)
-
-
-
Field Detail
-
pipelineConfiguration
@Parameter(property="", defaultValue="") protected org.codehaus.plexus.configuration.PlexusConfiguration pipelineConfiguration
The JSON or XML configuration of the extensions pipeline. This enables the users easily specify which extensions should be included/excluded in the Revapi analysis pipeline and also to define transformation blocks - a way of grouping transforms together to enable more fine grained control over how differences are transformed.- Since:
- 0.11.0
-
analysisConfiguration
@Parameter(property="", defaultValue="") protected org.codehaus.plexus.configuration.PlexusConfiguration analysisConfiguration
The JSON or XML configuration of various analysis options. The available options depend on what analyzers are present on the plugin classpath through the<dependencies>
. Consult configuration documentation for more details.These settings take precedence over the configuration loaded from
analysisConfigurationFiles
.
-
failOnMissingConfigurationFiles
@Parameter(property="revapi.failOnMissingConfigurationFiles", defaultValue="true") protected boolean failOnMissingConfigurationFiles
Set to false if you want to tolerate files referenced in theanalysisConfigurationFiles
missing on the filesystem and therefore not contributing to the analysis configuration.The default is
true
, which means that a missing analysis configuration file will fail the build.
-
analysisConfigurationFiles
@Parameter(property="revapi.analysisConfigurationFiles", defaultValue="") protected Object[] analysisConfigurationFiles
The list of files containing the configuration of various analysis options. The available options depend on what analyzers are present on the plugins classpath through the<dependencies>
.The
analysisConfiguration
can override the settings present in the files.The list is either a list of strings or has the following form:
<analysisConfigurationFiles> <configurationFile> <path>path/to/the/file/relative/to/project/base/dir</path> <resource>path/to/the/file/in/one/of/the/dependencies</resource> <roots> <root>configuration/root1</root> <root>configuration/root2</root> ... </roots> </configurationFile> ... </analysisConfigurationFiles>
path
is the path on the filesystem,resource
is the path to the resource file in one of the artifacts the plugin depends onroots
is optional and specifies the subtrees of the JSON/XML config that should be used for configuration. If not specified, the whole file is taken into account.
path
orresource
has to be specified but not both. Theconfiguration/root1
andconfiguration/root2
are paths to the roots of the configuration inside that JSON/XML config file. This might be used in cases where multiple configurations are stored within a single file and you want to use a particular one.An example of this might be a config file which contains API changes to be ignored in all past versions of a library. The classes to be ignored are specified in a configuration that is specific for each version:
{ "0.1.0" : [ { "extension": "revapi.ignore", "configuration": [ { "code" : "java.method.addedToInterface", "new" : "method void com.example.MyInterface::newMethod()", "justification" : "This interface is not supposed to be implemented by clients." }, ... ] } ], "0.2.0" : [ ... ] }
-
promotedDependencies
@Parameter(property="", defaultValue="") protected PromotedDependency[] promotedDependencies
A list of dependencies of both the old and new artifact(s) that should be considered part of the old/new API. This is a convenience property if you just need to specify a set of dependencies to promote into the API and that set can be specified in a way common to both old and new APIs. If you need to specify different sets for the old and new, useoldPromotedDependencies
ornewPromotedDependencies
respectively. IfoldPromotedDependencies
ornewPromotedDependencies
are specified, they override whatever is specified using this property.The individual properties of the dependency (e.g.
groupId
,artifactId
,version
,type
orclassifier
) are matched exactly. If you enclose the value in forward slashes, they are matched as regular expressions instead.E.g.
<groupId>com.acme</groupId>
will only match dependencies with that exactgroupId
, while<groupId>/com\.acme(\..*)?/</groupId>
will match "com.acme"groupId
or any "sub-groupId" thereof (e.g. "com.acme.utils", etc.) using a regular expression.- Since:
- 0.13.6
-
oldArtifacts
@Parameter(property="revapi.oldArtifacts", defaultValue="") protected String[] oldArtifacts
The coordinates of the old artifacts. Defaults to single artifact with the latest released version of the current project.If the this property is null, the
oldVersion
property is checked for a value of the old version of the artifact being built.- See Also:
oldVersion
-
oldVersion
@Parameter(property="revapi.oldVersion", defaultValue="RELEASE") protected String oldVersion
If you don't want to compare a different artifact than the one being built, specifying the just the old version is simpler way of specifying the old artifact.The default value is "RELEASE" meaning that the old version is the last released version of the artifact being built (either remote or found locally (to account for artifacts installed into the local repo that are not available in some public remote repository)). The version of the compared artifact will be strictly older than the version of the new artifact.
If you specify "LATEST", the old version will be resolved to the newest version available remotely, including snapshots (if found in one of the repositories active in the build). The version of the compared artifact will be either older or equal to the version of the new artifact in this case to account for comparing a locally built snapshot against the latest published snapshot.
-
oldPromotedDependencies
@Parameter(property="", defaultValue="") protected PromotedDependency[] oldPromotedDependencies
A list of dependencies of the old artifact(s) that should be considered part of the old API.- Since:
- 0.13.6
- See Also:
promotedDependencies
-
newArtifacts
@Parameter(property="revapi.newArtifacts", defaultValue="") protected String[] newArtifacts
The coordinates of the new artifacts. These are the full GAVs of the artifacts, which means that you can compare different artifacts than the one being built. If you merely want to specify the artifact being built, usenewVersion
property instead.
-
newVersion
@Parameter(property="revapi.newVersion", defaultValue="${project.version}") protected String newVersion
The new version of the artifact. Defaults to "${project.version}".
-
newPromotedDependencies
@Parameter(property="", defaultValue="") protected PromotedDependency[] newPromotedDependencies
A list of dependencies of the new artifact(s) that should be considered part of the new API.- Since:
- 0.13.6
- See Also:
promotedDependencies
-
skip
@Parameter(property="revapi.skip", defaultValue="false") protected boolean skip
Whether to skip the mojo execution.
-
failSeverity
@Parameter(property="revapi.failSeverity", defaultValue="potentiallyBreaking") @Deprecated protected FailSeverity failSeverity
Deprecated.use the newfailCriticality
The severity of found problems at which to break the build. Defaults to potentiallyBreaking. Possible values: equivalent, nonBreaking, potentiallyBreaking, breaking.
-
failCriticality
@Parameter(property="revapi.maximumCriticality") protected String failCriticality
The minimum criticality of the found differences at which to fail the build. This has to be one of the criticalities configured in the pipeline configuration (if the pipeline configuration doesn't define any, the following are the default ones:allowed
,documented
,highlight
,error
). If not defined, the value is derived fromfailSeverity
using the severity-to-criticality mapping (which is again configured in the pipeline configuration. If not defined in the pipeline configuration explicitly, the default mapping is the following:EQUIVALENT
=allowed
,NON_BREAKING
=documented
,POTENTIALLY_BREAKING
=error
,BREAKING
= error.- Since:
- 0.12.0
-
project
@Parameter(defaultValue="${project}", readonly=true) protected org.apache.maven.project.MavenProject project
-
repositorySystem
@Component protected org.eclipse.aether.RepositorySystem repositorySystem
-
repositorySystemSession
@Parameter(defaultValue="${repositorySystemSession}", readonly=true) protected org.eclipse.aether.RepositorySystemSession repositorySystemSession
-
alwaysCheckForReleaseVersion
@Parameter(property="revapi.alwaysCheckForReleaseVersion", defaultValue="true") protected boolean alwaysCheckForReleaseVersion
If true (the default) revapi will always download the information about the latest version from the remote repositories (instead of using locally cached info). This will respect the offline settings.
-
failBuildOnProblemsFound
@Parameter(property="revapi.failBuildOnProblemsFound", defaultValue="true") protected boolean failBuildOnProblemsFound
If true (the default), the maven plugin will fail the build when it finds API problems (e.g. problems with with the criticality at least equal tofailCriticality
).
-
failOnUnresolvedArtifacts
@Parameter(property="revapi.failOnUnresolvedArtifacts", defaultValue="false") protected boolean failOnUnresolvedArtifacts
If true, the build will fail if one of the old or new artifacts fails to be resolved. Defaults to false.
-
failOnUnresolvedDependencies
@Parameter(property="revapi.failOnUnresolvedDependencies", defaultValue="false") protected boolean failOnUnresolvedDependencies
If true, the build will fail if some of the dependencies of the old or new artifacts fail to be resolved. Defaults to false.
-
checkDependencies
@Parameter(property="revapi.checkDependencies", defaultValue="true") protected boolean checkDependencies
Whether to include the dependencies in the API checks. This is the default thing to do because your API might be exposing classes from the dependencies and thus classes from your dependencies could become part of your API.However, setting this to false might be useful in situations where you have checked your dependencies in another module and don't want do that again. In that case, you might want to configure Revapi to ignore missing classes because it might find the classes from your dependencies as used in your API and would complain that it could not find it. See the docs.
-
resolveProvidedDependencies
@Parameter(property="revapi.resolveProvidedDependencies", defaultValue="true") protected boolean resolveProvidedDependencies
When establishing the API classes, Revapi by default also looks through theprovided
dependencies. The reason for this is that even though such dependencies do not appear in the transitive dependency set established by maven, they need to be present both on the compilation and runtime classpath of the module. Therefore, the classes in the module are free to expose classes from a provided dependency as API elements.In rare circumstances this is not a desired behavior though. It is undesired if for example the classes from the provided dependency are used only for establishing desired build order or when they are used in some non-standard scenarios during the build and actually not needed at runtime.
Note that this property only influences the resolution of provided dependencies of the main artifacts, not the transitively reachable provided dependencies. For those, use the
resolveTransitiveProvidedDependencies
parameter.
-
resolveTransitiveProvidedDependencies
@Parameter(property="revapi.resolveTransitiveProvidedDependencies", defaultValue="false") protected boolean resolveTransitiveProvidedDependencies
In addition toresolveProvidedDependencies
this property further controls how provided dependencies are resolved. Using this property you can control how the indirect, transitively reachable, provided dependencies are treated. The default is to not consider them, which is almost always the right thing to do. It might be necessary to set this property totrue
in the rare circumstances where the API of the main artifacts includes types from such transitively included provided dependencies. Such occurrence will manifest itself by Revapi considering such types as missing (which is by default reported as a potentially breaking change). When you then resolve the transitive provided dependencies (by setting this parameter to true), Revapi will be able to find such types and do a proper analysis of them.
-
versionFormat
@Parameter(property="revapi.versionFormat", defaultValue="") protected String versionFormat
If set, this property demands a format of the version string when theoldVersion
ornewVersion
parameters are set toRELEASE
orLATEST
special version strings.Because Maven will report the newest non-snapshot version as the latest release, we might end up comparing a
.Beta
or other pre-release versions with the new version. This might not be what you want and setting the versionFormat will make sure that a newest version conforming to the version format is used instead of the one resolved by Maven by default.This parameter is a regular expression pattern that the version string needs to match in order to be considered a
RELEASE
.
-
disallowedExtensions
@Deprecated @Parameter(property="revapi.disallowedExtensions", defaultValue="") protected String disallowedExtensions
Deprecated.since 0.11.0, use thepipelineConfiguration
insteadA comma-separated list of extensions (fully-qualified class names thereof) that are not taken into account during API analysis. By default, all extensions that are found on the classpath are used.You can modify this set if you use another extensions that change the found differences in a way that the determined new version would not correspond to what it should be.
-
expandProperties
@Parameter(property="revapi.expandProperties", defaultValue="false") protected boolean expandProperties
If set to true, the Maven properties will be expanded in the configuration before it is supplied to Revapi. I.e. any${var}
appearing in the configuration values will be replaced with the value of thevar
property as known to Maven. If the property is not defined, the expansion doesn't take place.- Since:
- 0.11.6
-
-
Method Detail
-
doExecute
public void doExecute() throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
execute
public final void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
- Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
-
determineMaximumCriticality
protected org.revapi.Criticality determineMaximumCriticality(org.revapi.PipelineConfiguration pipelineConfiguration) throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
analyze
protected org.revapi.AnalysisResult analyze(Class<? extends org.revapi.Reporter> reporter, org.revapi.PipelineConfiguration.Builder pipelineConfiguration, Object... contextDataKeyValues) throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
- Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
-
prepareAnalyzer
protected Analyzer prepareAnalyzer(org.apache.maven.project.MavenProject project, org.revapi.PipelineConfiguration.Builder pipelineConfiguration, Class<? extends org.revapi.Reporter> reporter, Map<String,Object> contextData)
-
prepareAnalyzer
protected Analyzer prepareAnalyzer(org.apache.maven.project.MavenProject project, org.revapi.PipelineConfiguration.Builder pipelineConfiguration, Class<? extends org.revapi.Reporter> reporter, Map<String,Object> contextData, Map<String,Object> propertyOverrides)
-
initializeComparisonArtifacts
protected boolean initializeComparisonArtifacts()
- Returns:
- true if artifacts are initialized, false if not and the analysis should not proceed
-
-