Package org.codehaus.mojo.versions.api
Class DefaultVersionsHelper
java.lang.Object
org.codehaus.mojo.versions.api.DefaultVersionsHelper
- All Implemented Interfaces:
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 ClassesNested classes/interfaces inherited from interface org.codehaus.mojo.versions.api.VersionsHelper
VersionsHelper.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) protected RulegetBestFitRule(String groupId, String artifactId) Find the rule, if any, which best fits the artifact details given.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> dependencies, 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
public org.apache.maven.plugin.logging.Log getLog()Description copied from interface:VersionsHelperGets the logger used by this helper.- Specified by:
getLogin interfaceVersionsHelper- Returns:
- the logger used by this helper.
-
lookupArtifactVersions
public ArtifactVersions lookupArtifactVersions(org.apache.maven.artifact.Artifact artifact, org.apache.maven.artifact.versioning.VersionRange versionRange, boolean usePluginRepositories) throws VersionRetrievalException Description copied from interface:VersionsHelperLooks 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.- Specified by:
lookupArtifactVersionsin interfaceVersionsHelper- 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
-
lookupArtifactVersions
public ArtifactVersions lookupArtifactVersions(org.apache.maven.artifact.Artifact artifact, org.apache.maven.artifact.versioning.VersionRange versionRange, boolean usePluginRepositories, boolean useProjectRepositories) throws VersionRetrievalException Description copied from interface:VersionsHelperLooks 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.- Specified by:
lookupArtifactVersionsin interfaceVersionsHelper- 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
-
lookupArtifactVersions
public ArtifactVersions lookupArtifactVersions(org.apache.maven.artifact.Artifact artifact, boolean usePluginRepositories) throws VersionRetrievalException Description copied from interface:VersionsHelperLooks 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.- Specified by:
lookupArtifactVersionsin interfaceVersionsHelper- 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
-
resolveArtifact
public void resolveArtifact(org.apache.maven.artifact.Artifact artifact, boolean usePluginRepositories) throws org.apache.maven.artifact.resolver.ArtifactResolutionException Description copied from interface:VersionsHelperAttempts to resolve the artifact.- Specified by:
resolveArtifactin interfaceVersionsHelper- 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
-
getVersionComparator
Description copied from interface:VersionsHelperReturns the version comparator to use for the specified artifact.- Specified by:
getVersionComparatorin interfaceVersionsHelper- Parameters:
artifact- the artifact.- Returns:
- the version comparator to use.
-
getVersionComparator
Description copied from interface:VersionsHelperReturns the version comparator to use for the specified groupId and artifactId.- Specified by:
getVersionComparatorin interfaceVersionsHelper- Parameters:
groupId- the groupId.artifactId- the artifactId.- Returns:
- the version comparator to use.
-
getBestFitRule
Find the rule, if any, which best fits the artifact details given.- Parameters:
groupId- Group id of the artifactartifactId- Artifact id of the artifact- Returns:
- Rule which best describes the given artifact
-
createPluginArtifact
public org.apache.maven.artifact.Artifact createPluginArtifact(String groupId, String artifactId, String version) Description copied from interface:VersionsHelperShorthand method forrepositorySystem.createPluginArtifact(...).- Specified by:
createPluginArtifactin interfaceVersionsHelper- Parameters:
groupId- The group Id.artifactId- The artifact Id.version- The version range.- Returns:
- the corresponding plugin artifact.
-
createDependencyArtifact
public org.apache.maven.artifact.Artifact createDependencyArtifact(String groupId, String artifactId, String version, String type, String classifier, String scope, boolean optional) Description copied from interface:VersionsHelperShorthand method forrepositorySystem.createDependencyArtifact(...).- Specified by:
createDependencyArtifactin interfaceVersionsHelper- 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.
-
createDependencyArtifact
public org.apache.maven.artifact.Artifact createDependencyArtifact(org.apache.maven.model.Dependency dependency) Description copied from interface:VersionsHelperShorthand method forrepositorySystem.createDependencyArtifact(...)which extracts the parameters from the Dependency instance.- Specified by:
createDependencyArtifactin interfaceVersionsHelper- Parameters:
dependency- The dependency to create the artifact for.- Returns:
- The corresponding dependency artifact.
-
extractArtifacts
public Set<org.apache.maven.artifact.Artifact> extractArtifacts(Collection<org.apache.maven.project.MavenProject> mavenProjects) Description copied from interface:VersionsHelper- Specified by:
extractArtifactsin interfaceVersionsHelper- Parameters:
mavenProjects- theListofMavenProjectinstances.- Returns:
- a
SetofArtifactinstances.
-
createArtifactVersion
Description copied from interface:VersionsHelperCreates anArtifactVersioninstance from a string.- Specified by:
createArtifactVersionin interfaceVersionsHelper- Parameters:
version- the string representation of the version.- Returns:
- The artifact version.
-
lookupDependenciesUpdates
public Map<org.apache.maven.model.Dependency,ArtifactVersions> lookupDependenciesUpdates(Stream<org.apache.maven.model.Dependency> dependencies, boolean usePluginRepositories, boolean useProjectRepositories, boolean allowSnapshots) throws VersionRetrievalException Description copied from interface:VersionsHelperReturns a map of all possible updates per dependency. The lookup is done in parallel usingLOOKUP_PARALLEL_THREADSthreads.- Specified by:
lookupDependenciesUpdatesin interfaceVersionsHelper- 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
-
lookupDependenciesUpdates
public Map<org.apache.maven.model.Dependency,ArtifactVersions> lookupDependenciesUpdates(Stream<org.apache.maven.model.Dependency> dependencies, boolean usePluginRepositories, boolean allowSnapshots) throws VersionRetrievalException Description copied from interface:VersionsHelperReturns a map of all possible updates per dependency. The lookup is done in parallel usingLOOKUP_PARALLEL_THREADSthreads.- Specified by:
lookupDependenciesUpdatesin interfaceVersionsHelper- Parameters:
dependencies- 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
-
lookupDependencyUpdates
public ArtifactVersions lookupDependencyUpdates(org.apache.maven.model.Dependency dependency, boolean usePluginRepositories, boolean useProjectRepositories, boolean allowSnapshots) throws VersionRetrievalException Description copied from interface:VersionsHelperCreates anArtifactVersionsinstance from a dependency.- Specified by:
lookupDependencyUpdatesin interfaceVersionsHelper- 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
-
lookupPluginsUpdates
public Map<org.apache.maven.model.Plugin,PluginUpdatesDetails> lookupPluginsUpdates(Stream<org.apache.maven.model.Plugin> plugins, boolean allowSnapshots) throws VersionRetrievalException Description copied from interface:VersionsHelperLooks up the updates for a set of plugins.- Specified by:
lookupPluginsUpdatesin interfaceVersionsHelper- 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
-
lookupPluginUpdates
public PluginUpdatesDetails lookupPluginUpdates(org.apache.maven.model.Plugin plugin, boolean allowSnapshots) throws VersionRetrievalException Description copied from interface:VersionsHelperLooks up the updates for a plugin.- Specified by:
lookupPluginUpdatesin interfaceVersionsHelper- 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
-
getExpressionEvaluator
public org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator getExpressionEvaluator(org.apache.maven.project.MavenProject project) Description copied from interface:VersionsHelperReturns anExpressionEvaluatorfor the specified project.- Specified by:
getExpressionEvaluatorin interfaceVersionsHelper- Parameters:
project- The project.- Returns:
- an
ExpressionEvaluatorfor the specified project.
-
getVersionPropertiesMap
public Map<Property,PropertyVersions> getVersionPropertiesMap(VersionsHelper.VersionPropertiesMapRequest request) throws org.apache.maven.plugin.MojoExecutionException Description copied from interface:VersionsHelperReturns a map ofPropertyVersionsvalues keyed byPropertyinstances consisting of the properties defined in the project which are associated with version information.- Specified by:
getVersionPropertiesMapin interfaceVersionsHelper- Parameters:
request-VersionsHelper.VersionPropertiesMapRequestinstance containing the arguments- Returns:
- a map of
PropertyVersionsvalues keyed byPropertyinstances. - Throws:
org.apache.maven.plugin.MojoExecutionException- if something goes wrong.
-