Class MavenDependencyResolverService
- java.lang.Object
- 
- jadex.platform.service.dependency.maven.MavenDependencyResolverService
 
- 
- All Implemented Interfaces:
- IDependencyService
 
 public class MavenDependencyResolverService extends java.lang.Object implements IDependencyService Handler for retrieving dependency information from maven artifacts.
- 
- 
Field SummaryFields Modifier and Type Field Description protected IComponentIdentifiercidThe component identifier to use for creating local resource IDs.protected IInternalAccesscomponentThe service providing component.protected java.util.logging.LoggerloggerThe logger.protected java.util.List<org.sonatype.aether.repository.RemoteRepository>repositoriesRemote repositories as specified in settings.protected org.apache.maven.repository.internal.MavenRepositorySystemSessionsessionThe shared repository system session.protected org.sonatype.aether.RepositorySystemsystemAccess to the aether repository system.
 - 
Constructor SummaryConstructors Constructor Description MavenDependencyResolverService()Bean constructor for service creation.MavenDependencyResolverService(IComponentIdentifier cid)Constructor for testing
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static java.io.FilefindBasedir(java.io.File dir)Find the base directorystatic java.lang.StringgetCoordinates(java.lang.String groupid, java.lang.String id, java.lang.String version)Get the coordinates (global identifier) for an artifact.IFuture<IResourceIdentifier>getResourceIdentifier(java.net.URL url)Get the resource identifier for a url.static java.net.URLgetUrl(java.io.File file)Get the URL for a file.protected voidinit()Initialize maven and aether repository system.IFuture<Tuple2<IResourceIdentifier,java.util.Map<IResourceIdentifier,java.util.List<IResourceIdentifier>>>>loadDependencies(IResourceIdentifier rid, boolean workspace)Load dependencies from a resource identifier.protected IResourceIdentifierloadDependencies(IResourceIdentifier rid, java.util.Map<IResourceIdentifier,java.util.List<IResourceIdentifier>> rids, boolean workspace)Load dependencies from a resource identifier.protected IResourceIdentifierloadDependenciesWithAether(IResourceIdentifier rid, java.util.Map<IResourceIdentifier,java.util.List<IResourceIdentifier>> rids)Load dependencies using aether repository access only, because no other context information (e.g.protected org.apache.maven.model.ModelloadModelSource(java.net.URL url)Find the model source (i.e.protected org.apache.maven.model.ModelloadPom(org.apache.maven.model.building.ModelSource pom)Load a POM from a source.protected voidprocessAetherDependencies(IResourceIdentifier rid, java.util.Map<IResourceIdentifier,java.util.List<IResourceIdentifier>> rids, org.sonatype.aether.graph.DependencyNode node)Recursively process the dependency graph produced by aether.IFuture<java.lang.Void>startService()Start the service.
 
- 
- 
- 
Field Detail- 
componentprotected IInternalAccess component The service providing component.
 - 
loggerprotected java.util.logging.Logger logger The logger.
 - 
cidprotected IComponentIdentifier cid The component identifier to use for creating local resource IDs. The assumption is that URLs are only valid on the local platform.
 - 
systemprotected org.sonatype.aether.RepositorySystem system Access to the aether repository system.
 - 
sessionprotected org.apache.maven.repository.internal.MavenRepositorySystemSession session The shared repository system session.
 - 
repositoriesprotected java.util.List<org.sonatype.aether.repository.RemoteRepository> repositories Remote repositories as specified in settings.
 
- 
 - 
Constructor Detail- 
MavenDependencyResolverServicepublic MavenDependencyResolverService() Bean constructor for service creation.
 - 
MavenDependencyResolverServicepublic MavenDependencyResolverService(IComponentIdentifier cid) throws java.lang.Exception Constructor for testing- Throws:
- java.lang.Exception
 
 
- 
 - 
Method Detail- 
startServicepublic IFuture<java.lang.Void> startService() Start the service.
 - 
initprotected void init() throws java.lang.ExceptionInitialize maven and aether repository system.- Throws:
- java.lang.Exception
 
 - 
loadDependenciespublic IFuture<Tuple2<IResourceIdentifier,java.util.Map<IResourceIdentifier,java.util.List<IResourceIdentifier>>>> loadDependencies(IResourceIdentifier rid, boolean workspace) Load dependencies from a resource identifier.- Specified by:
- loadDependenciesin interface- IDependencyService
- Parameters:
- rid- A local or global resource identifier. If both local and global ids are present, local takes precedence, e.g. resolving to workspace urls before fetching an older snapshot from a repository.
- Returns:
- A map containing the dependencies as mapping (parent RID -> list of children RIDs).
 
 - 
getResourceIdentifierpublic IFuture<IResourceIdentifier> getResourceIdentifier(java.net.URL url) Get the resource identifier for a url.- Specified by:
- getResourceIdentifierin interface- IDependencyService
- Parameters:
- url- The url.
- Returns:
- The resource identifier including local RID and potentially global RID if available.
 
 - 
loadDependenciesprotected IResourceIdentifier loadDependencies(IResourceIdentifier rid, java.util.Map<IResourceIdentifier,java.util.List<IResourceIdentifier>> rids, boolean workspace) throws java.lang.Exception Load dependencies from a resource identifier.- Parameters:
- rid- A local or global resource identifier. If both local and global ids are present, local takes precedence, e.g. resolving to workspace urls before fetching an older snapshot from a repository.
- rids- A map for inserting the dependencies as mapping (parent RID -> list of children RIDs).
- Throws:
- java.lang.Exception
 
 - 
loadDependenciesWithAetherprotected IResourceIdentifier loadDependenciesWithAether(IResourceIdentifier rid, java.util.Map<IResourceIdentifier,java.util.List<IResourceIdentifier>> rids) throws java.lang.Exception Load dependencies using aether repository access only, because no other context information (e.g. workspace) is available.- Parameters:
- rid- The resource identifier containing only a global resource id.
- rids- A map for inserting the dependencies as mapping (parent RID -> list of children RIDs).
- Throws:
- java.lang.Exception
 
 - 
processAetherDependenciesprotected void processAetherDependencies(IResourceIdentifier rid, java.util.Map<IResourceIdentifier,java.util.List<IResourceIdentifier>> rids, org.sonatype.aether.graph.DependencyNode node) throws java.lang.Exception Recursively process the dependency graph produced by aether.- Parameters:
- rid- The resource identifier containing only a global resource id.
- rids- A map for inserting the dependencies as mapping (parent RID -> list of children RIDs).
- node- The dependency node.
- Throws:
- java.lang.Exception
 
 - 
loadPomprotected org.apache.maven.model.Model loadPom(org.apache.maven.model.building.ModelSource pom) Load a POM from a source.- Parameters:
- pom- The source.
- Returns:
- The loaded model.
 
 - 
loadModelSourceprotected org.apache.maven.model.Model loadModelSource(java.net.URL url) Find the model source (i.e. POM location) for a URL.- Parameters:
- url- The url to a maven artifact (e.g. jar or classes directory).
 
 - 
findBasedirprotected static java.io.File findBasedir(java.io.File dir) Find the base directory- Parameters:
- uri-
- Returns:
 
 - 
getUrlpublic static java.net.URL getUrl(java.io.File file) Get the URL for a file.- Parameters:
- file- The file.
- Returns:
- The file
 
 - 
getCoordinatespublic static java.lang.String getCoordinates(java.lang.String groupid, java.lang.String id, java.lang.String version)Get the coordinates (global identifier) for an artifact.- Parameters:
- groupid- The group identifier.
- id- The artifact id.
- version- The artifact version.
- Returns:
- The coordinates as string ('groupid:id:version').
 
 
- 
 
-