org.codehaus.mojo.versions.api
Class DefaultVersionsHelper

java.lang.Object
  extended by org.codehaus.mojo.versions.api.DefaultVersionsHelper
All Implemented Interfaces:
VersionsHelper

public class DefaultVersionsHelper
extends Object
implements VersionsHelper

Helper class that provides common functionality required by both the mojos and the reports.

Since:
1.0-alpha-3
Author:
Stephen Connolly

Constructor Summary
DefaultVersionsHelper(ArtifactFactory artifactFactory, ArtifactMetadataSource artifactMetadataSource, List remoteArtifactRepositories, List remotePluginRepositories, ArtifactRepository localRepository, WagonManager wagonManager, Settings settings, String serverId, String rulesUri, String comparisonMethod, Log log)
          Constructs a new DefaultVersionsHelper.
 
Method Summary
 Artifact createDependencyArtifact(Dependency dependency)
          Shorthand method for getArtifactFactory().createDependencyArtifact(...) which extracts the parameters from the Dependency instance.
 Artifact createDependencyArtifact(String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, boolean optional)
          Shorthand method for getArtifactFactory().createDependencyArtifact(...).
 Artifact createPluginArtifact(String groupId, String artifactId, VersionRange versionRange)
          Shorthand method for getArtifactFactory().createPluginArtifact(...).
 Set extractArtifacts(Collection mavenProjects)
          Takes a List of MavenProject instances and converts it into a Set of Artifact instances.
 ArtifactFactory getArtifactFactory()
          Returns the artifact factory to use.
 Log getLog()
          Gets the logger used by this helper.
 Comparator getVersionComparator(Artifact artifact)
          Returns the version comparator to use for the specified artifact.
 Comparator getVersionComparator(String groupId, String artifactId)
          Returns the version comparator to use for the specified groupId and artifactId.
 ArtifactVersions lookupArtifactVersions(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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultVersionsHelper

public DefaultVersionsHelper(ArtifactFactory artifactFactory,
                             ArtifactMetadataSource artifactMetadataSource,
                             List remoteArtifactRepositories,
                             List remotePluginRepositories,
                             ArtifactRepository localRepository,
                             WagonManager wagonManager,
                             Settings settings,
                             String serverId,
                             String rulesUri,
                             String comparisonMethod,
                             Log log)
                      throws MojoExecutionException
Constructs a new DefaultVersionsHelper.

Parameters:
artifactFactory - The artifact factory.
artifactMetadataSource - The artifact metadata source to use.
remoteArtifactRepositories - The remote artifact repositories to consult.
remotePluginRepositories - The remote plugin repositories to consult.
localRepository - The local repository to consult.
wagonManager - The wagon manager (used if rules need to be retrieved).
settings - The settings (used to provide proxy information to the wagon manager).
serverId - The serverId hint for the wagon manager.
rulesUri - The URL to retrieve the versioning rules from.
comparisonMethod - The default comparison method.
log - The Log to send log messages to. @since 1.0-alpha-3
Throws:
MojoExecutionException - If things go wrong.
Method Detail

getArtifactFactory

public ArtifactFactory getArtifactFactory()
Description copied from interface: VersionsHelper
Returns the artifact factory to use.

Specified by:
getArtifactFactory in interface VersionsHelper
Returns:
the artifact factory to use.

getLog

public Log getLog()
Description copied from interface: VersionsHelper
Gets the logger used by this helper.

Specified by:
getLog in interface VersionsHelper
Returns:
the logger used by this helper.

lookupArtifactVersions

public ArtifactVersions lookupArtifactVersions(Artifact artifact,
                                               boolean usePluginRepositories)
                                        throws MojoExecutionException
Description copied from interface: VersionsHelper
Looks up the versions of the specified artifact that are available in either the local repository, or the appropriate remote repositories.

Specified by:
lookupArtifactVersions in interface VersionsHelper
Parameters:
artifact - The artifact to look for versions of.
usePluginRepositories - true will consult the pluginRepositories, while false will consult the repositories for normal dependencies.
Returns:
The details of the available artifact versions.
Throws:
MojoExecutionException - When things go wrong.

getVersionComparator

public Comparator getVersionComparator(Artifact artifact)
Description copied from interface: VersionsHelper
Returns the version comparator to use for the specified artifact.

Specified by:
getVersionComparator in interface VersionsHelper
Parameters:
artifact - the artifact.
Returns:
the version comparator to use.

getVersionComparator

public Comparator getVersionComparator(String groupId,
                                       String artifactId)
Description copied from interface: VersionsHelper
Returns the version comparator to use for the specified groupId and artifactId.

Specified by:
getVersionComparator in interface VersionsHelper
Parameters:
groupId - the groupId.
artifactId - the artifactId.
Returns:
the version comparator to use.

createPluginArtifact

public Artifact createPluginArtifact(String groupId,
                                     String artifactId,
                                     VersionRange versionRange)
Description copied from interface: VersionsHelper
Shorthand method for getArtifactFactory().createPluginArtifact(...).

Specified by:
createPluginArtifact in interface VersionsHelper
Parameters:
groupId - The group Id.
artifactId - The artifact Id.
versionRange - The version range.
Returns:
the corresponding plugin artifact.

createDependencyArtifact

public Artifact createDependencyArtifact(String groupId,
                                         String artifactId,
                                         VersionRange versionRange,
                                         String type,
                                         String classifier,
                                         String scope,
                                         boolean optional)
Description copied from interface: VersionsHelper
Shorthand method for getArtifactFactory().createDependencyArtifact(...).

Specified by:
createDependencyArtifact in interface VersionsHelper
Parameters:
groupId - The group id.
artifactId - The artifact id.
versionRange - 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 Artifact createDependencyArtifact(Dependency dependency)
                                  throws InvalidVersionSpecificationException
Description copied from interface: VersionsHelper
Shorthand method for getArtifactFactory().createDependencyArtifact(...) which extracts the parameters from the Dependency instance.

Specified by:
createDependencyArtifact in interface VersionsHelper
Parameters:
dependency - The dependency to create the artifact for.
Returns:
The corresponding dependency artifact.
Throws:
InvalidVersionSpecificationException - if the version specified in the dependency is invalid.

extractArtifacts

public Set extractArtifacts(Collection mavenProjects)
Takes a List of MavenProject instances and converts it into a Set of Artifact instances.

Specified by:
extractArtifacts in interface VersionsHelper
Parameters:
mavenProjects - the List of MavenProject instances.
Returns:
a Set of Artifact instances.
Throws:
InvalidVersionSpecificationException - if any of the MavenProject versions are invalid (should never happen).
Since:
1.0-alpha-3


Copyright © 2008-2009 Codehaus. All Rights Reserved.