Package org.codehaus.mojo.versions.api
Interface VersionsHelper
- All Known Implementing Classes:
DefaultVersionsHelper
public interface VersionsHelper
Helper class that provides common functionality required by both the mojos and the reports.
- Since:
- 1.0-alpha-3
- Author:
- Stephen Connolly
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classArgument builder class forgetVersionPropertiesMap(VersionPropertiesMapRequest). -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.maven.artifact.versioning.ArtifactVersioncreateArtifactVersion(String version) Creates anArtifactVersioninstance from a string.org.apache.maven.artifact.ArtifactcreateDependencyArtifact(String groupId, String artifactId, String version, String type, String classifier, String scope, boolean optional) Shorthand method forrepositorySystem.createDependencyArtifact(...).org.apache.maven.artifact.ArtifactcreateDependencyArtifact(org.apache.maven.model.Dependency dependency) Shorthand method forrepositorySystem.createDependencyArtifact(...)which extracts the parameters from the Dependency instance.org.apache.maven.artifact.ArtifactcreatePluginArtifact(String groupId, String artifactId, String version) Shorthand method forrepositorySystem.createPluginArtifact(...).Set<org.apache.maven.artifact.Artifact> extractArtifacts(Collection<org.apache.maven.project.MavenProject> mavenProjects) org.codehaus.plexus.component.configurator.expression.ExpressionEvaluatorgetExpressionEvaluator(org.apache.maven.project.MavenProject project) Returns anExpressionEvaluatorfor the specified project.org.apache.maven.plugin.logging.LoggetLog()Gets the logger used by this helper.getVersionComparator(String groupId, String artifactId) Returns the version comparator to use for the specified groupId and artifactId.getVersionComparator(org.apache.maven.artifact.Artifact artifact) Returns the version comparator to use for the specified artifact.Returns a map ofPropertyVersionsvalues keyed byPropertyinstances consisting of the properties defined in the project which are associated with version information.lookupArtifactVersions(org.apache.maven.artifact.Artifact artifact, boolean usePluginRepositories) Looks up the versions of the specified artifact that are available in either the local repository, or the appropriate remote repositories.lookupArtifactVersions(org.apache.maven.artifact.Artifact artifact, org.apache.maven.artifact.versioning.VersionRange versionRange, boolean usePluginRepositories) Looks up the versions of the specified artifact that are available in either the local repository, or the appropriate remote repositories.lookupArtifactVersions(org.apache.maven.artifact.Artifact artifact, org.apache.maven.artifact.versioning.VersionRange versionRange, boolean usePluginRepositories, boolean useProjectRepositories) Looks up the versions of the specified artifact that are available in either the local repository, or the appropriate remote repositories.Map<org.apache.maven.model.Dependency, ArtifactVersions> lookupDependenciesUpdates(Stream<org.apache.maven.model.Dependency> dependencyStream, boolean usePluginRepositories, boolean allowSnapshots) Returns a map of all possible updates per dependency.Map<org.apache.maven.model.Dependency, ArtifactVersions> lookupDependenciesUpdates(Stream<org.apache.maven.model.Dependency> dependencies, boolean usePluginRepositories, boolean useProjectRepositories, boolean allowSnapshots) Returns a map of all possible updates per dependency.lookupDependencyUpdates(org.apache.maven.model.Dependency dependency, boolean usePluginRepositories, boolean useProjectRepositories, boolean allowSnapshots) Creates anArtifactVersionsinstance from a dependency.Map<org.apache.maven.model.Plugin, PluginUpdatesDetails> lookupPluginsUpdates(Stream<org.apache.maven.model.Plugin> plugins, boolean allowSnapshots) Looks up the updates for a set of plugins.lookupPluginUpdates(org.apache.maven.model.Plugin plugin, boolean allowSnapshots) Looks up the updates for a plugin.voidresolveArtifact(org.apache.maven.artifact.Artifact artifact, boolean usePluginRepositories) Attempts to resolve the artifact.
-
Method Details
-
getLog
org.apache.maven.plugin.logging.Log getLog()Gets the logger used by this helper.- Returns:
- the logger used by this helper.
-
getVersionComparator
Returns the version comparator to use for the specified artifact.- Parameters:
artifact- the artifact.- Returns:
- the version comparator to use.
- Since:
- 1.0-alpha-3
-
getVersionComparator
Returns the version comparator to use for the specified groupId and artifactId.- Parameters:
groupId- the groupId.artifactId- the artifactId.- Returns:
- the version comparator to use.
- Since:
- 1.0-alpha-3
-
createPluginArtifact
org.apache.maven.artifact.Artifact createPluginArtifact(String groupId, String artifactId, String version) Shorthand method forrepositorySystem.createPluginArtifact(...).- Parameters:
groupId- The group Id.artifactId- The artifact Id.version- The version range.- Returns:
- the corresponding plugin artifact.
- Since:
- 1.0-alpha-3
-
createDependencyArtifact
org.apache.maven.artifact.Artifact createDependencyArtifact(String groupId, String artifactId, String version, String type, String classifier, String scope, boolean optional) Shorthand method forrepositorySystem.createDependencyArtifact(...).- Parameters:
groupId- The group id.artifactId- The artifact id.version- The version (possibly a range)type- The type.classifier- The classifier.scope- The scope.optional- If optional or not.- Returns:
- The corresponding dependency artifact.
- Since:
- 1.0-alpha-3
-
createDependencyArtifact
org.apache.maven.artifact.Artifact createDependencyArtifact(org.apache.maven.model.Dependency dependency) Shorthand method forrepositorySystem.createDependencyArtifact(...)which extracts the parameters from the Dependency instance.- Parameters:
dependency- The dependency to create the artifact for.- Returns:
- The corresponding dependency artifact.
- Since:
- 1.0-alpha-3
-
extractArtifacts
Set<org.apache.maven.artifact.Artifact> extractArtifacts(Collection<org.apache.maven.project.MavenProject> mavenProjects) -
createArtifactVersion
Creates anArtifactVersioninstance from a string.- Parameters:
version- the string representation of the version.- Returns:
- The artifact version.
- Since:
- 1.0-beta-1
-
lookupArtifactVersions
ArtifactVersions lookupArtifactVersions(org.apache.maven.artifact.Artifact artifact, boolean usePluginRepositories) throws VersionRetrievalException Looks up the versions of the specified artifact that are available in either the local repository, or the appropriate remote repositories. The resultingArtifactVersionsinstance will contain all versions, including snapshots.- Parameters:
artifact- The artifact to look for versions of.usePluginRepositories-truewill consult the pluginRepositories, whilefalsewill consult the repositories for normal dependencies.- Returns:
- The details of the available artifact versions.
- Throws:
VersionRetrievalException- thrown if version resolution fails- Since:
- 1.0-alpha-3
-
lookupArtifactVersions
ArtifactVersions lookupArtifactVersions(org.apache.maven.artifact.Artifact artifact, org.apache.maven.artifact.versioning.VersionRange versionRange, boolean usePluginRepositories, boolean useProjectRepositories) throws VersionRetrievalException Looks up the versions of the specified artifact that are available in either the local repository, or the appropriate remote repositories. The resultingArtifactVersionsinstance will contain all versions, including snapshots.- Parameters:
artifact- The artifact to look for versions of.versionRange- versionRange to restrict the search, may benullusePluginRepositories-truewill consult the pluginRepositoriesuseProjectRepositories-truewill consult regular project repositories- Returns:
- The details of the available artifact versions.
- Throws:
VersionRetrievalException- thrown if version resolution fails- Since:
- 2.15.0
-
lookupArtifactVersions
ArtifactVersions lookupArtifactVersions(org.apache.maven.artifact.Artifact artifact, org.apache.maven.artifact.versioning.VersionRange versionRange, boolean usePluginRepositories) throws VersionRetrievalException Looks up the versions of the specified artifact that are available in either the local repository, or the appropriate remote repositories. The resultingArtifactVersionsinstance will contain all versions, including snapshots.- Parameters:
artifact- The artifact to look for versions of.versionRange- versionRange to restrict the search, may benullusePluginRepositories-truewill consult the pluginRepositories, whilefalsewill consult the repositories for normal dependencies.- Returns:
- The details of the available artifact versions.
- Throws:
VersionRetrievalException- thrown if version resolution fails- Since:
- 1.0-alpha-3
-
lookupDependenciesUpdates
Map<org.apache.maven.model.Dependency,ArtifactVersions> lookupDependenciesUpdates(Stream<org.apache.maven.model.Dependency> dependencyStream, boolean usePluginRepositories, boolean allowSnapshots) throws VersionRetrievalException Returns a map of all possible updates per dependency. The lookup is done in parallel usingLOOKUP_PARALLEL_THREADSthreads.- Parameters:
dependencyStream- a stream ofDependencyinstances to look up.usePluginRepositories- Search the plugin repositories.allowSnapshots- whether snapshots should be included- Returns:
- map containing the ArtifactVersions object per dependency
- Throws:
VersionRetrievalException- thrown if a version cannot be retrieved
-
lookupDependenciesUpdates
Map<org.apache.maven.model.Dependency,ArtifactVersions> lookupDependenciesUpdates(Stream<org.apache.maven.model.Dependency> dependencies, boolean usePluginRepositories, boolean useProjectRepositories, boolean allowSnapshots) throws VersionRetrievalException Returns a map of all possible updates per dependency. The lookup is done in parallel usingLOOKUP_PARALLEL_THREADSthreads.- Parameters:
dependencies- stream ofDependencyinstances to look up.usePluginRepositories- Search the plugin repositories.useProjectRepositories- whether to use regular project repositoriesallowSnapshots- whether snapshots should be included- Returns:
- map containing the ArtifactVersions object per dependency
- Throws:
VersionRetrievalException- thrown if a version cannot be retrieved
-
lookupDependencyUpdates
ArtifactVersions lookupDependencyUpdates(org.apache.maven.model.Dependency dependency, boolean usePluginRepositories, boolean useProjectRepositories, boolean allowSnapshots) throws VersionRetrievalException Creates anArtifactVersionsinstance from a dependency.- Parameters:
dependency- The dependency.usePluginRepositories- Search the plugin repositories.useProjectRepositories- whether to use regular project repositoriesallowSnapshots- whether snapshots should be included- Returns:
- The details of updates to the dependency.
- Throws:
VersionRetrievalException- thrown if version resolution fails- Since:
- 1.0-beta-1
-
lookupPluginsUpdates
Map<org.apache.maven.model.Plugin,PluginUpdatesDetails> lookupPluginsUpdates(Stream<org.apache.maven.model.Plugin> plugins, boolean allowSnapshots) throws VersionRetrievalException Looks up the updates for a set of plugins.- Parameters:
plugins- A stream ofPlugininstances to look up.allowSnapshots- Include snapshots in the list of updates.- Returns:
- A map, keyed by plugin, with values of type
PluginUpdatesDetails. - Throws:
VersionRetrievalException- thrown if version resolution fails- Since:
- 1.0-beta-1
-
lookupPluginUpdates
PluginUpdatesDetails lookupPluginUpdates(org.apache.maven.model.Plugin plugin, boolean allowSnapshots) throws VersionRetrievalException Looks up the updates for a plugin.- Parameters:
plugin- ThePlugininstance to look up.allowSnapshots- Include snapshots in the list of updates.- Returns:
- The plugin update details.
- Throws:
VersionRetrievalException- thrown if version resolution fails- Since:
- 1.0-beta-1
-
getExpressionEvaluator
org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator getExpressionEvaluator(org.apache.maven.project.MavenProject project) Returns anExpressionEvaluatorfor the specified project.- Parameters:
project- The project.- Returns:
- an
ExpressionEvaluatorfor the specified project. - Since:
- 1.0-beta-1
-
getVersionPropertiesMap
Map<Property,PropertyVersions> getVersionPropertiesMap(VersionsHelper.VersionPropertiesMapRequest request) throws org.apache.maven.plugin.MojoExecutionException Returns a map ofPropertyVersionsvalues keyed byPropertyinstances consisting of the properties defined in the project which are associated with version information.- Parameters:
request-VersionsHelper.VersionPropertiesMapRequestinstance containing the arguments- Returns:
- a map of
PropertyVersionsvalues keyed byPropertyinstances. - Throws:
org.apache.maven.plugin.MojoExecutionException- if something goes wrong.
-
resolveArtifact
void resolveArtifact(org.apache.maven.artifact.Artifact artifact, boolean usePluginRepositories) throws org.apache.maven.artifact.resolver.ArtifactResolutionException Attempts to resolve the artifact.- Parameters:
artifact- The artifact to resolve.usePluginRepositories- whether to resolve from the plugin repositories or the regular repositories.- Throws:
org.apache.maven.artifact.resolver.ArtifactResolutionException- if resolution is unsuccessful- Since:
- 1.3
-