|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.modeshape.maven.MavenRepository
public class MavenRepository
A Maven 2 repository that can be used to store and access artifacts like JARs and source archives within a running application.
This class understands Maven 2 Project Object Model (POM) files, and thus is able to analyze dependencies and provide a
class loader
that accesses libraries using these transitive dependencies.
Instances are initialized with an authenticated Maven URL provider
, which is typically a
JcrMavenUrlProvider
instance configured with a JCR Repository
and path to the root of the repository
subtree in that workspace. The repository can either already exist and contain the required artifacts, or it will be created as
artifacts are loaded. Then to use libraries that are in the repository, simply obtain the
class loader
by specifying the artifact identifiers
for the
libraries used directly by your code. This class loader will add any libraries that are required by those you supply.
Constructor Summary | |
---|---|
MavenRepository(MavenUrlProvider urlProvider)
|
Method Summary | |
---|---|
boolean |
exists(MavenId mavenId)
Determine whether the identified library exists in this Maven repository. |
Set<MavenId> |
exists(MavenId firstId,
MavenId... mavenIds)
Determine which of the identified libraries exist in this Maven repository. |
ClassLoader |
getClassLoader(ClassLoader parent,
MavenId... mavenIds)
Get a class loader that has as its classpath the JARs for the libraries identified by the supplied IDs. |
ClassLoader |
getClassLoader(ClassLoader parent,
String... coordinates)
Get a class loader that has as its classpath the JARs for the libraries identified by the supplied IDs. |
ClassLoader |
getClassLoader(String... coordinates)
Get a class loader that has as its classpath the JARs for the libraries identified by the supplied IDs. |
List<MavenDependency> |
getDependencies(MavenId mavenId)
Get the dependencies for the Maven project with the specified ID. |
URL |
getUrl(MavenId mavenId,
ArtifactType artifactType,
SignatureType signatureType)
Get the URL for the artifact with the specified type in the given Maven project. |
URL |
getUrl(MavenId mavenId,
ArtifactType artifactType,
SignatureType signatureType,
boolean createIfRequired)
Get the URL for the artifact with the specified type in the given Maven project. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MavenRepository(MavenUrlProvider urlProvider)
Method Detail |
---|
public ClassLoader getClassLoader(ClassLoader parent, MavenId... mavenIds)
exist
in this repository.
parent
- the parent class loader that will be consulted before any project class loaders; may be null if the
current thread's context class loader
or the class loader that loaded this
class should be usedmavenIds
- the IDs of the libraries in this Maven repository
IllegalArgumentException
- if no Maven IDs are passed in or if any of the IDs are nullexists(MavenId)
,
exists(MavenId,MavenId...)
public ClassLoader getClassLoader(String... coordinates)
exist
in this repository.
getClassLoader
in interface ClassLoaderFactory
coordinates
- the IDs of the libraries in this Maven repository
IllegalArgumentException
- if no coordinates are passed in or if any of the coordinate references is nullpublic ClassLoader getClassLoader(ClassLoader parent, String... coordinates)
exist
in this repository.
parent
- the parent class loader that will be consulted before any project class loaders; may be null if the
current thread's context class loader
or the class loader that loaded this
class should be usedcoordinates
- the IDs of the libraries in this Maven repository
IllegalArgumentException
- if no coordinates are passed in or if any of the coordinate references is nullpublic boolean exists(MavenId mavenId) throws MavenRepositoryException
mavenId
- the ID of the library
MavenRepositoryException
- if there is a problem connecting to or using the Maven repository, as configuredexists(MavenId,MavenId...)
public Set<MavenId> exists(MavenId firstId, MavenId... mavenIds) throws MavenRepositoryException
firstId
- the first ID of the library to checkmavenIds
- the IDs of the libraries; any null IDs will be ignored
MavenRepositoryException
- if there is a problem connecting to or using the Maven repository, as configuredexists(MavenId)
public List<MavenDependency> getDependencies(MavenId mavenId)
This implementation downloads the POM file for the specified project to extract the dependencies and exclusions.
mavenId
- the ID of the project; may not be null
IllegalArgumentException
- if the MavenId reference is null
MavenRepositoryException
- if there is a problem finding or reading the POM file given the MavenIdpublic URL getUrl(MavenId mavenId, ArtifactType artifactType, SignatureType signatureType) throws MalformedURLException
connect
to the repository to read
or
write
the artifact's content.
mavenId
- the ID of the Maven project; may not be nullartifactType
- the type of artifact; may be null, but the URL will not be able to be read or written tosignatureType
- the type of signature; may be null if the signature file is not desired
MalformedURLException
- if the supplied information cannot be turned into a valid URLpublic URL getUrl(MavenId mavenId, ArtifactType artifactType, SignatureType signatureType, boolean createIfRequired) throws MalformedURLException
connect
to the repository to read
or
write
the artifact's content.
mavenId
- the ID of the Maven project; may not be nullartifactType
- the type of artifact; may be null, but the URL will not be able to be read or written tosignatureType
- the type of signature; may be null if the signature file is not desiredcreateIfRequired
- true if the node structure should be created if any part of it does not exist; this always expects
that the path to the top of the repository tree exists.
MalformedURLException
- if the supplied information cannot be turned into a valid URL
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |