org.apache.maven.shared.test.plugin
Class RepositoryTool

java.lang.Object
  extended by org.apache.maven.shared.test.plugin.RepositoryTool
All Implemented Interfaces:
org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable

public class RepositoryTool
extends java.lang.Object
implements org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable

Tools to access and manage Maven repositories for test builds, including construction of a local repository directory structure.

WARNING: Currently, the createLocalRepositoryFromPlugin method will not resolve parent POMs that exist only in your normal local repository, and are not reachable using the relativePath element. This may result in failed test builds, as one or more of the plugin's ancestor POMs cannot be resolved.

Author:
jdcasey

Field Summary
private  org.apache.maven.artifact.factory.ArtifactFactory artifactFactory
           
private  org.apache.maven.artifact.installer.ArtifactInstaller artifactInstaller
           
private  org.codehaus.plexus.PlexusContainer container
           
private  org.apache.maven.artifact.repository.ArtifactRepositoryFactory repositoryFactory
           
static java.lang.String ROLE
           
private  org.apache.maven.settings.MavenSettingsBuilder settingsBuilder
           
 
Constructor Summary
RepositoryTool()
           
 
Method Summary
 void contextualize(org.codehaus.plexus.context.Context context)
          Retrieve the PlexusContainer instance used to instantiate this component.
 org.apache.maven.artifact.repository.ArtifactRepository createLocalArtifactRepositoryInstance()
          Construct an ArtifactRepository instance that refers to the normal Maven local repository.
 org.apache.maven.artifact.repository.ArtifactRepository createLocalArtifactRepositoryInstance(java.io.File localRepositoryDirectory)
          Construct an ArtifactRepository instance that refers to the test-time Maven local repository.
 void createLocalRepositoryFromComponentProject(org.apache.maven.project.MavenProject project, java.io.File realPomFile, java.io.File targetLocalRepoBasedir)
          Install a test version of a plugin - along with its POM, and as many ancestor POMs as can be reached using the <relativePath/> element - to a clean local repository directory for use in test builds.
 java.io.File findLocalRepositoryDirectory()
          Lookup and return the location of the normal Maven local repository.
private  void installLocallyReachableAncestorPoms(java.io.File realPomFile, org.apache.maven.artifact.repository.ArtifactRepository localRepo)
          Traverse <relativePath/> links for successive POMs in the plugin's ancestry, installing each one into the test-time local repository.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROLE

public static final java.lang.String ROLE

repositoryFactory

private org.apache.maven.artifact.repository.ArtifactRepositoryFactory repositoryFactory

settingsBuilder

private org.apache.maven.settings.MavenSettingsBuilder settingsBuilder

artifactFactory

private org.apache.maven.artifact.factory.ArtifactFactory artifactFactory

artifactInstaller

private org.apache.maven.artifact.installer.ArtifactInstaller artifactInstaller

container

private org.codehaus.plexus.PlexusContainer container
Constructor Detail

RepositoryTool

public RepositoryTool()
Method Detail

findLocalRepositoryDirectory

public java.io.File findLocalRepositoryDirectory()
                                          throws TestToolsException
Lookup and return the location of the normal Maven local repository.

Throws:
TestToolsException

createLocalArtifactRepositoryInstance

public org.apache.maven.artifact.repository.ArtifactRepository createLocalArtifactRepositoryInstance()
                                                                                              throws TestToolsException
Construct an ArtifactRepository instance that refers to the normal Maven local repository.

Throws:
TestToolsException

createLocalArtifactRepositoryInstance

public org.apache.maven.artifact.repository.ArtifactRepository createLocalArtifactRepositoryInstance(java.io.File localRepositoryDirectory)
                                                                                              throws TestToolsException
Construct an ArtifactRepository instance that refers to the test-time Maven local repository.

Parameters:
localRepositoryDirectory - The location of the local repository to be used for test builds.
Throws:
TestToolsException

createLocalRepositoryFromComponentProject

public void createLocalRepositoryFromComponentProject(org.apache.maven.project.MavenProject project,
                                                      java.io.File realPomFile,
                                                      java.io.File targetLocalRepoBasedir)
                                               throws TestToolsException
Install a test version of a plugin - along with its POM, and as many ancestor POMs as can be reached using the <relativePath/> element - to a clean local repository directory for use in test builds.

WARNING: Currently, this method will not resolve parent POMs that exist only in your normal local repository, and are not reachable using the relativePath element. This may result in failed test builds, as one or more of the plugin's ancestor POMs cannot be resolved.

Parameters:
project -
targetLocalRepoBasedir -
Throws:
TestToolsException

installLocallyReachableAncestorPoms

private void installLocallyReachableAncestorPoms(java.io.File realPomFile,
                                                 org.apache.maven.artifact.repository.ArtifactRepository localRepo)
                                          throws TestToolsException
Traverse <relativePath/> links for successive POMs in the plugin's ancestry, installing each one into the test-time local repository.

Parameters:
realPomFile - The real plugin POM; a starting point, but the POM is already installed, so we won't actually install this file, only use it to locate parents.
localRepo - The test-time local repository instance
Throws:
TestToolsException

contextualize

public void contextualize(org.codehaus.plexus.context.Context context)
                   throws org.codehaus.plexus.context.ContextException
Retrieve the PlexusContainer instance used to instantiate this component. The container is used to retrieve the default ArtifactRepositoryLayout component, for use in constructing instances of ArtifactRepository that can be used to access local repositories.

Specified by:
contextualize in interface org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
Throws:
org.codehaus.plexus.context.ContextException