Class MavenContext

java.lang.Object
org.jdrupes.builder.mvnrepo.MavenContext

public final class MavenContext extends Object

Manages a global instance of RepositorySystem and RepositorySystemSession and a list of RemoteRepositorys for use by all instances of MvnRepoLookup and others.

The remote repositories are evaluated by looking up the repositories from the profiles in settings.xml selected with useProfiles and the repositories added with addRepository(org.eclipse.aether.repository.RemoteRepository).

  • Method Details

    • repositorySystem

      public static org.eclipse.aether.RepositorySystem repositorySystem()
      Repository system.
      Returns:
      the repository system
    • repositorySession

      public static org.eclipse.aether.RepositorySystemSession repositorySession()
      Repository session.
      Returns:
      the repository system session
    • lookupCredentials

      public static boolean lookupCredentials(String serverId, BiConsumer<String,String> consumer)
      Looks up the credentials for the specified server in settings.xml. Invokes the consumer with the username and password if found.
      Parameters:
      serverId - the server id
      consumer - the consumer
      Returns:
      true, if found
    • useProfiles

      public static Class<MavenContext> useProfiles(String... profiles)
      Include repositories from the specified profiles in settings.xml in the result of remoteRepositories().
      Parameters:
      profiles - the profiles
      Returns:
      the Maven context
    • addRepository

      public static Class<MavenContext> addRepository(org.eclipse.aether.repository.RemoteRepository repository)
      Include the given repository in the result of remoteRepositories().
      Parameters:
      repository - the repository
      Returns:
      the Maven context
    • addRepository

      public static Class<MavenContext> addRepository(String id, URI uri, MvnVersionType... supported)
      Include the repository created from the given values in the result of remoteRepositories().
      Parameters:
      id - the repository id
      uri - the repository uri
      supported - the supported version types
      Returns:
      the Maven context
    • mavenCentral

      public static org.eclipse.aether.repository.RemoteRepository mavenCentral()
      Returns the RemoteRepository for Maven Central.
      Returns:
      the remote repository