Package org.apache.maven.api
Interface Session
- All Known Implementing Classes:
AbstractSession
,DefaultSession
The session to install / deploy / resolve artifacts and dependencies.
- Since:
- 4.0
-
Method Summary
Modifier and TypeMethodDescriptioncollectDependencies
(Artifact artifact) Shortcut forgetService(DependencyCollector.class).collect(...)
collectDependencies
(DependencyCoordinate dependency) Shortcut forgetService(DependencyResolver.class).resolve(...)
collectDependencies
(Project project) Shortcut forgetService(DependencyCollector.class).collect(...)
createArtifact
(String groupId, String artifactId, String version, String extension) Shortcut forgetService(ArtifactFactory.class).create(...)
createArtifact
(String groupId, String artifactId, String version, String classifier, String extension, String type) Shortcut forgetService(ArtifactFactory.class).create(...)
createArtifactCoordinate
(String groupId, String artifactId, String version, String extension) Shortcut forgetService(ArtifactFactory.class).create(...)
createArtifactCoordinate
(String groupId, String artifactId, String version, String classifier, String extension, String type) Shortcut forgetService(ArtifactFactory.class).create(...)
createArtifactCoordinate
(Artifact artifact) Shortcut forgetService(ArtifactFactory.class).create(...)
createDependencyCoordinate
(ArtifactCoordinate coordinate) Shortcut forgetService(DependencyFactory.class).create(...)
createLocalRepository
(Path path) Shortcut forgetService(RepositoryFactory.class).createLocal(...)
createRemoteRepository
(String id, String url) Shortcut forgetService(RepositoryFactory.class).createRemote(...)
createRemoteRepository
(Repository repository) Shortcut forgetService(RepositoryFactory.class).createRemote(...)
void
deployArtifact
(RemoteRepository repository, Artifact... artifacts) Shortcut forgetService(ArtifactDeployer.class).deploy(...)
getArtifactPath
(Artifact artifact) Shortcut forgetService(ArtifactManager.class).getPath(...)
getData()
int
Returns the list of registered listeners.Returns the current maven versiongetPathForLocalArtifact
(Artifact artifact) getPathForRemoteArtifact
(RemoteRepository remote, Artifact artifact) getPluginContext
(Project project) Returns the plugin context for mojo being executed and the specifiedProject
, never returnsnull
as if context not present, creates it.<T extends Service>
TgetService
(Class<T> clazz) Retrieves the service for the interfaceGets the system properties to use for interpolation.Gets the user properties to use for interpolation.void
installArtifacts
(Collection<Artifact> artifacts) Shortcut forgetService(ArtifactInstaller.class).install(...)
void
installArtifacts
(Artifact... artifacts) Shortcut forgetService(ArtifactInstaller.class).install(...)
boolean
isVersionSnapshot
(String version) Shortcut forgetService(ArtifactManager.class).isSnapshot(...)
parseVersion
(String version) Shortcut forgetService(VersionParser.class).parseVersion(...)
parseVersionRange
(String versionRange) Shortcut forgetService(VersionParser.class).parseVersionRange(...)
void
registerListener
(Listener listener) Register the given listener which will receive all events.resolveArtifact
(Artifact artifact) Shortcut forgetService(ArtifactResolver.class).resolve(...)
resolveArtifact
(ArtifactCoordinate coordinate) Shortcut forgetService(ArtifactResolver.class).resolve(...)
resolveArtifacts
(Collection<? extends ArtifactCoordinate> coordinates) Shortcut forgetService(ArtifactResolver.class).resolve(...)
resolveArtifacts
(Artifact... artifacts) Shortcut forgetService(ArtifactResolver.class).resolve(...)
resolveArtifacts
(ArtifactCoordinate... coordinates) Shortcut forgetService(ArtifactResolver.class).resolve(...)
void
setArtifactPath
(Artifact artifact, Path path) Shortcut forgetService(ArtifactManager.class).setPath(...)
void
unregisterListener
(Listener listener) Unregisters a previously registered listener.withLocalRepository
(LocalRepository localRepository) Creates a derived session using the given local repository.withRemoteRepositories
(List<RemoteRepository> repositories) Creates a derived session using the given remote repositories.
-
Method Details
-
getSettings
-
getLocalRepository
-
getRemoteRepositories
-
getData
-
getUserProperties
Gets the user properties to use for interpolation. The user properties have been configured directly by the user, e.g. via the-Dkey=value
parameter on the command line.- Returns:
- the user properties, never
null
-
getSystemProperties
Gets the system properties to use for interpolation. The system properties are collected from the runtime environment such asSystem.getProperties()
and environment variables.- Returns:
- the system properties, never
null
-
getMavenVersion
Returns the current maven version- Returns:
- the maven version, never
null
-
getDegreeOfConcurrency
int getDegreeOfConcurrency() -
getStartTime
-
getMultiModuleProjectDirectory
-
getExecutionRootDirectory
-
getProjects
-
getPluginContext
Returns the plugin context for mojo being executed and the specifiedProject
, never returnsnull
as if context not present, creates it. Implementation note: while this method return type isMap
, the returned map instance implementsConcurrentMap
as well.- Throws:
MavenException
- if not called from the within a mojo execution
-
getService
Retrieves the service for the interface- Throws:
NoSuchElementException
- if the service could not be found
-
withLocalRepository
Creates a derived session using the given local repository.- Parameters:
localRepository
- the new local repository- Returns:
- the derived session
- Throws:
NullPointerException
- iflocalRepository
is null
-
withRemoteRepositories
Creates a derived session using the given remote repositories.- Parameters:
repositories
- the new list of remote repositories- Returns:
- the derived session
- Throws:
NullPointerException
- ifrepositories
is null
-
registerListener
Register the given listener which will receive all events.- Parameters:
listener
- the listener to register- Throws:
NullPointerException
- iflistener
is null
-
unregisterListener
Unregisters a previously registered listener.- Parameters:
listener
- the listener to unregister- Throws:
NullPointerException
- iflistener
is null
-
getListeners
Returns the list of registered listeners.- Returns:
- an immutable collection of listeners, never
null
-
createLocalRepository
Shortcut forgetService(RepositoryFactory.class).createLocal(...)
- See Also:
-
createRemoteRepository
Shortcut forgetService(RepositoryFactory.class).createRemote(...)
-
createRemoteRepository
Shortcut forgetService(RepositoryFactory.class).createRemote(...)
-
createArtifactCoordinate
ArtifactCoordinate createArtifactCoordinate(String groupId, String artifactId, String version, String extension) Shortcut forgetService(ArtifactFactory.class).create(...)
-
createArtifactCoordinate
ArtifactCoordinate createArtifactCoordinate(String groupId, String artifactId, String version, String classifier, String extension, String type) Shortcut forgetService(ArtifactFactory.class).create(...)
-
createArtifactCoordinate
Shortcut forgetService(ArtifactFactory.class).create(...)
-
createDependencyCoordinate
Shortcut forgetService(DependencyFactory.class).create(...)
-
createArtifact
Shortcut forgetService(ArtifactFactory.class).create(...)
-
createArtifact
Artifact createArtifact(String groupId, String artifactId, String version, String classifier, String extension, String type) Shortcut forgetService(ArtifactFactory.class).create(...)
-
resolveArtifact
Shortcut forgetService(ArtifactResolver.class).resolve(...)
- Throws:
ArtifactResolverException
- if the artifact resolution failed- See Also:
-
resolveArtifacts
Shortcut forgetService(ArtifactResolver.class).resolve(...)
- Throws:
ArtifactResolverException
- if the artifact resolution failed- See Also:
-
resolveArtifacts
Shortcut forgetService(ArtifactResolver.class).resolve(...)
- Throws:
ArtifactResolverException
- if the artifact resolution failed- See Also:
-
resolveArtifact
Shortcut forgetService(ArtifactResolver.class).resolve(...)
- Throws:
ArtifactResolverException
- if the artifact resolution failed- See Also:
-
resolveArtifacts
Shortcut forgetService(ArtifactResolver.class).resolve(...)
- Throws:
ArtifactResolverException
- if the artifact resolution failed- See Also:
-
installArtifacts
Shortcut forgetService(ArtifactInstaller.class).install(...)
- Throws:
ArtifactInstallerException
- if the artifacts installation failed- See Also:
-
installArtifacts
Shortcut forgetService(ArtifactInstaller.class).install(...)
- Throws:
ArtifactInstallerException
- if the artifacts installation failed- See Also:
-
deployArtifact
Shortcut forgetService(ArtifactDeployer.class).deploy(...)
- Throws:
ArtifactDeployerException
- if the artifacts deployment failed- See Also:
-
setArtifactPath
Shortcut forgetService(ArtifactManager.class).setPath(...)
- See Also:
-
getArtifactPath
Shortcut forgetService(ArtifactManager.class).getPath(...)
- See Also:
-
isVersionSnapshot
Shortcut forgetService(ArtifactManager.class).isSnapshot(...)
- See Also:
-
collectDependencies
Shortcut forgetService(DependencyCollector.class).collect(...)
- Throws:
DependencyCollectorException
- if the dependency collection failed- See Also:
-
collectDependencies
Shortcut forgetService(DependencyCollector.class).collect(...)
- Throws:
DependencyCollectorException
- if the dependency collection failed- See Also:
-
collectDependencies
Shortcut forgetService(DependencyResolver.class).resolve(...)
- Throws:
DependencyCollectorException
- if the dependency collection failed- See Also:
-
getPathForLocalArtifact
-
getPathForRemoteArtifact
-
parseVersion
Shortcut forgetService(VersionParser.class).parseVersion(...)
- Throws:
VersionParserException
- if the parsing failed- See Also:
-
parseVersionRange
Shortcut forgetService(VersionParser.class).parseVersionRange(...)
- Throws:
VersionParserException
- if the parsing failed- See Also:
-