Class DefaultSession

java.lang.Object
org.apache.maven.internal.impl.AbstractSession
org.apache.maven.internal.impl.DefaultSession
All Implemented Interfaces:
Session, InternalSession

public class DefaultSession extends AbstractSession
  • Constructor Details

  • Method Details

    • getMavenSession

      public MavenSession getMavenSession()
    • getLocalRepository

      @Nonnull public LocalRepository getLocalRepository()
    • getRemoteRepositories

      @Nonnull public List<RemoteRepository> getRemoteRepositories()
    • getSettings

      @Nonnull public Settings getSettings()
    • getUserProperties

      @Nonnull public Map<String,String> getUserProperties()
      Description copied from interface: Session
      Returns immutable 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

      @Nonnull public Map<String,String> getSystemProperties()
      Description copied from interface: Session
      Returns immutable system properties to use for interpolation. The system properties are collected from the runtime environment such as System.getProperties() and environment variables (prefixed with env.).
      Returns:
      the system properties, never null
    • getEffectiveProperties

      @Nonnull public Map<String,String> getEffectiveProperties(@Nullable Project project)
      Description copied from interface: Session
      Each invocation computes a new map of effective properties. To be used in interpolation.

      Effective properties are computed from system, user and optionally project properties, layered with defined precedence onto each other to achieve proper precedence. Precedence is defined as:

      • System properties (lowest precedence)
      • Project properties (optional)
      • User properties (highest precedence)
      Note: Project properties contains properties injected from profiles, if applicable. Their precedence is profile > project, hence active profile property may override project property.

      The caller of this method should decide whether there is a project in scope (hence, a project instance needs to be passed) or not.

      Parameters:
      project - Project or null.
      Returns:
      the effective properties, never null
    • getMavenVersion

      @Nonnull public Version getMavenVersion()
      Description copied from interface: Session
      Returns the current maven version
      Returns:
      the maven version, never null
    • getDegreeOfConcurrency

      public int getDegreeOfConcurrency()
    • getStartTime

      @Nonnull public Instant getStartTime()
    • getRootDirectory

      public Path getRootDirectory()
      Description copied from interface: Session
      Gets the root directory of the session, which is the root directory for the top directory project.
      See Also:
    • getTopDirectory

      public Path getTopDirectory()
      Description copied from interface: Session
      Gets the directory of the topmost project being built, usually the current directory or the directory pointed at by the -f/--file command line argument.
    • getProjects

      @Nonnull public List<Project> getProjects()
    • getPluginContext

      @Nonnull public Map<String,Object> getPluginContext(Project project)
      Description copied from interface: Session
      Returns the plugin context for mojo being executed and the specified Project, never returns null as if context not present, creates it. Implementation note: while this method return type is Map, the returned map instance implements ConcurrentMap as well.
    • getData

      @Nonnull public SessionData getData()
    • withLocalRepository

      @Nonnull public Session withLocalRepository(@Nonnull LocalRepository localRepository)
      Description copied from interface: Session
      Creates a derived session using the given local repository.
      Parameters:
      localRepository - the new local repository
      Returns:
      the derived session
    • withRemoteRepositories

      @Nonnull public Session withRemoteRepositories(@Nonnull List<RemoteRepository> repositories)
      Description copied from interface: Session
      Creates a derived session using the given remote repositories.
      Parameters:
      repositories - the new list of remote repositories
      Returns:
      the derived session
    • getService

      @Nonnull public <T extends Service> T getService(Class<T> clazz) throws NoSuchElementException
      Description copied from interface: Session
      Retrieves the service for the interface
      Throws:
      NoSuchElementException - if the service could not be found
    • getSession

      @Nonnull public org.eclipse.aether.RepositorySystemSession getSession()
    • getRepositorySystem

      @Nonnull public org.eclipse.aether.RepositorySystem getRepositorySystem()
    • toArtifactRepository

      public ArtifactRepository toArtifactRepository(RemoteRepository repository)
      Specified by:
      toArtifactRepository in interface InternalSession
      Specified by:
      toArtifactRepository in class AbstractSession
    • toDependency

      public org.eclipse.aether.graph.Dependency toDependency(DependencyCoordinate dependency, boolean managed)
      Specified by:
      toDependency in interface InternalSession
      Specified by:
      toDependency in class AbstractSession