Package org.apache.maven.api
Interface Session
- All Known Subinterfaces:
- InternalSession
- All Known Implementing Classes:
- AbstractSession,- DefaultSession
The session to install / deploy / resolve artifacts and dependencies.
- Since:
- 4.0.0
- 
Method SummaryModifier and TypeMethodDescriptioncollectDependencies(Artifact artifact) Shortcut forgetService(DependencyCollector.class).collect(...)collectDependencies(DependencyCoordinate dependency) Collects the transitive dependencies of some artifacts and builds a dependency graph.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 coordString) Creates a coordinate out of string that is formatted like:<groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>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(...).createDependencyCoordinate(Dependency dependency) 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(...).voiddeployArtifact(RemoteRepository repository, Artifact... artifacts) Shortcut forgetService(ArtifactDeployer.class).deploy(...).flattenDependencies(Node node, ResolutionScope scope) Shortcut forgetService(DependencyResolver.class).flatten(...).getArtifactPath(Artifact artifact) Shortcut forgetService(ArtifactManager.class).getPath(...).getData()intReturns the list of registered listeners.Returns the current maven versiongetPathForLocalArtifact(Artifact artifact) Gets the relative path for a locally installed artifact.getPathForRemoteArtifact(RemoteRepository remote, Artifact artifact) Gets the relative path for an artifact cached from a remote repository.getPluginContext(Project project) Returns the plugin context for mojo being executed and the specifiedProject, never returnsnullas if context not present, creates it.Gets the root directory of the session, which is the root directory for the top directory project.<T extends Service>
 TgetService(Class<T> clazz) Retrieves the service for the interfaceGets the system properties to use for interpolation.Gets the directory of the topmost project being built, usually the current directory or the directory pointed at by the-f/--filecommand line argument.Gets the user properties to use for interpolation.voidinstallArtifacts(Collection<Artifact> artifacts) Shortcut forgetService(ArtifactInstaller.class).install(...).voidinstallArtifacts(Artifact... artifacts) Shortcut forgetService(ArtifactInstaller.class).install(...).booleanisVersionSnapshot(String version) Checks whether a given artifact version is considered aSNAPSHOTor not.parseVersion(String version) Parses the specified version string, for example "1.0".parseVersionRange(String versionRange) Parses the specified version range specification, for example "[1.0,2.0)".voidregisterListener(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(...).resolveDependencies(List<DependencyCoordinate> dependencyCoordinates) resolveDependencies(DependencyCoordinate dependencyCoordinate) resolveDependencies(Project project, ResolutionScope scope) resolveVersion(ArtifactCoordinate artifact) Resolves an artifact's meta version (if any) to a concrete version.resolveVersionRange(ArtifactCoordinate artifact) Expands a version range to a list of matching versions, in ascending order.voidsetArtifactPath(Artifact artifact, Path path) Shortcut forgetService(ArtifactManager.class).setPath(...).voidunregisterListener(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
- 
getUserPropertiesGets the user properties to use for interpolation. The user properties have been configured directly by the user, e.g. via the-Dkey=valueparameter on the command line.- Returns:
- the user properties, never null
 
- 
getSystemPropertiesGets 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
 
- 
getMavenVersionReturns the current maven version- Returns:
- the maven version, never null
 
- 
getDegreeOfConcurrencyint getDegreeOfConcurrency()
- 
getStartTime
- 
getTopDirectoryGets the directory of the topmost project being built, usually the current directory or the directory pointed at by the-f/--filecommand line argument.
- 
getRootDirectoryGets the root directory of the session, which is the root directory for the top directory project.- Throws:
- IllegalStateException- if the root directory could not be found
- See Also:
 
- 
getProjects
- 
getPluginContextReturns the plugin context for mojo being executed and the specifiedProject, never returnsnullas if context not present, creates it. Implementation note: while this method return type isMap, the returned map instance implementsConcurrentMapas well.- Throws:
- MavenException- if not called from the within a mojo execution
 
- 
getServiceRetrieves the service for the interface- Throws:
- NoSuchElementException- if the service could not be found
 
- 
withLocalRepositoryCreates a derived session using the given local repository.- Parameters:
- localRepository- the new local repository
- Returns:
- the derived session
- Throws:
- NullPointerException- if- localRepositoryis null
 
- 
withRemoteRepositoriesCreates a derived session using the given remote repositories.- Parameters:
- repositories- the new list of remote repositories
- Returns:
- the derived session
- Throws:
- NullPointerException- if- repositoriesis null
 
- 
registerListenerRegister the given listener which will receive all events.- Parameters:
- listener- the listener to register
- Throws:
- NullPointerException- if- listeneris null
 
- 
unregisterListenerUnregisters a previously registered listener.- Parameters:
- listener- the listener to unregister
- Throws:
- NullPointerException- if- listeneris null
 
- 
getListenersReturns the list of registered listeners.- Returns:
- an immutable collection of listeners, never null
 
- 
createLocalRepositoryShortcut forgetService(RepositoryFactory.class).createLocal(...).- See Also:
 
- 
createRemoteRepositoryShortcut forgetService(RepositoryFactory.class).createRemote(...).
- 
createRemoteRepositoryShortcut forgetService(RepositoryFactory.class).createRemote(...).
- 
createArtifactCoordinateArtifactCoordinate createArtifactCoordinate(String groupId, String artifactId, String version, String extension) Shortcut forgetService(ArtifactFactory.class).create(...).
- 
createArtifactCoordinateCreates a coordinate out of string that is formatted like:<groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>Shortcut for getService(ArtifactFactory.class).create(...).- Parameters:
- coordString- the string having "standard" coordinate.
- Returns:
- an ArtifactCoordinate, nevernull
- See Also:
 
- 
createArtifactCoordinateArtifactCoordinate createArtifactCoordinate(String groupId, String artifactId, String version, String classifier, String extension, String type) Shortcut forgetService(ArtifactFactory.class).create(...).
- 
createArtifactCoordinateShortcut forgetService(ArtifactFactory.class).create(...).
- 
createDependencyCoordinateShortcut forgetService(DependencyFactory.class).create(...).
- 
createDependencyCoordinateShortcut forgetService(DependencyFactory.class).create(...).
- 
createArtifactShortcut forgetService(ArtifactFactory.class).create(...).
- 
createArtifactArtifact createArtifact(String groupId, String artifactId, String version, String classifier, String extension, String type) Shortcut forgetService(ArtifactFactory.class).create(...).
- 
resolveArtifactShortcut forgetService(ArtifactResolver.class).resolve(...).- Throws:
- ArtifactResolverException- if the artifact resolution failed
- See Also:
 
- 
resolveArtifactsShortcut forgetService(ArtifactResolver.class).resolve(...).- Throws:
- ArtifactResolverException- if the artifact resolution failed
- See Also:
 
- 
resolveArtifactsShortcut forgetService(ArtifactResolver.class).resolve(...).- Throws:
- ArtifactResolverException- if the artifact resolution failed
- See Also:
 
- 
resolveArtifactShortcut forgetService(ArtifactResolver.class).resolve(...).- Throws:
- ArtifactResolverException- if the artifact resolution failed
- See Also:
 
- 
resolveArtifactsShortcut forgetService(ArtifactResolver.class).resolve(...).- Throws:
- ArtifactResolverException- if the artifact resolution failed
- See Also:
 
- 
installArtifactsShortcut forgetService(ArtifactInstaller.class).install(...).- Throws:
- ArtifactInstallerException- if the artifacts installation failed
- See Also:
 
- 
installArtifactsShortcut forgetService(ArtifactInstaller.class).install(...).- Throws:
- ArtifactInstallerException- if the artifacts installation failed
- See Also:
 
- 
deployArtifactShortcut forgetService(ArtifactDeployer.class).deploy(...).- Throws:
- ArtifactDeployerException- if the artifacts deployment failed
- See Also:
 
- 
setArtifactPathShortcut forgetService(ArtifactManager.class).setPath(...).- See Also:
 
- 
getArtifactPathShortcut forgetService(ArtifactManager.class).getPath(...).- See Also:
 
- 
getPathForLocalArtifactGets the relative path for a locally installed artifact. Note that the artifact need not actually exist yet at the returned location, the path merely indicates where the artifact would eventually be stored.Shortcut for getService(LocalArtifactManager.class).getPathForLocalArtitact(...).
- 
getPathForRemoteArtifact@Nonnull Path getPathForRemoteArtifact(@Nonnull RemoteRepository remote, @Nonnull Artifact artifact) Gets the relative path for an artifact cached from a remote repository. Note that the artifact need not actually exist yet at the returned location, the path merely indicates where the artifact would eventually be stored.Shortcut for getService(LocalArtifactManager.class).getPathForRemoteArtifact(...).
- 
isVersionSnapshotChecks whether a given artifact version is considered aSNAPSHOTor not.Shortcut for getService(ArtifactManager.class).isSnapshot(...).- See Also:
 
- 
collectDependenciesShortcut forgetService(DependencyCollector.class).collect(...)- Throws:
- DependencyCollectorException- if the dependency collection failed
- See Also:
 
- 
collectDependenciesShortcut forgetService(DependencyCollector.class).collect(...)- Throws:
- DependencyCollectorException- if the dependency collection failed
- See Also:
 
- 
collectDependenciesCollects the transitive dependencies of some artifacts and builds a dependency graph. Note that this operation is only concerned about determining the coordinates of the transitive dependencies and does not actually resolve the artifact files.Shortcut for getService(DependencyCollector.class).resolve(...)- Throws:
- DependencyCollectorException- if the dependency collection failed
- See Also:
 
- 
flattenDependenciesShortcut forgetService(DependencyResolver.class).flatten(...).- Throws:
- DependencyResolverException- if the dependency flattening failed
- See Also:
 
- 
resolveDependencies
- 
resolveDependencies
- 
resolveDependencies
- 
resolveVersionResolves an artifact's meta version (if any) to a concrete version. For example, resolves "1.0-SNAPSHOT" to "1.0-20090208.132618-23" or "RELEASE"/"LATEST" to "2.0".Shortcut for getService(VersionResolver.class).resolve(...)- Throws:
- VersionResolverException- if the resolution failed
- See Also:
 
- 
resolveVersionRangeExpands a version range to a list of matching versions, in ascending order. For example, resolves "[3.8,4.0)" to "3.8", "3.8.1", "3.8.2". The returned list of versions is only dependent on the configured repositories and their contents. The supplied request may also refer to a single concrete version rather than a version range. In this case though, the result contains simply the (parsed) input version, regardless of the repositories and their contents.- Returns:
- a list of resolved Versions.
- Throws:
- VersionRangeResolverException- if the resolution failed
- See Also:
 
- 
parseVersionParses the specified version string, for example "1.0".Shortcut for getService(VersionParser.class).parseVersion(...).- Throws:
- VersionParserException- if the parsing failed
- See Also:
 
- 
parseVersionRangeParses the specified version range specification, for example "[1.0,2.0)".Shortcut for getService(VersionParser.class).parseVersionRange(...).- Throws:
- VersionParserException- if the parsing failed
- See Also:
 
 
-