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 provides lists of RemoteRepositorys from profiles in settings.xml.
  • Method Details

    • repositorySystem

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

      public static org.eclipse.aether.impl.RepositoryConnectorProvider repositoryConnectorProvider()
      Connector provider.
      Returns:
      the repository connector provider
    • 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
    • mavenCentral

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

      public static org.eclipse.aether.repository.RemoteRepository jdbldDistribution()
      Returns the RemoteRepository for the JDrupes Builder distribution repository.
      Returns:
      the remote repository
    • repositories

      public static Stream<org.eclipse.aether.repository.RemoteRepository> repositories(String profileId)
      Return the RemoteRepositorys from the specified profile.
      Parameters:
      profileId - the profile id
      Returns:
      the repositories
    • repositories

      public static Stream<org.eclipse.aether.repository.RemoteRepository> repositories(Settings settings, String profileId)
      Return the RemoteRepositorys from the specified settings and profile.
      Parameters:
      settings - the settings
      profileId - the profile id
      Returns:
      the repositories
    • createRepository

      public static org.eclipse.aether.repository.RemoteRepository createRepository(String id, URI uri, MvnVersionType... supported)

      Creates a RemoteRepository from the specified id and URI that supports lookup for the specified version types.

      The repository uses default policies as returned by createDefaultPolicy(org.jdrupes.builder.mvnrepo.MvnVersionType,boolean).

      Parameters:
      id - the id
      uri - the uri
      supported - the supported
      Returns:
      the remote repository
    • createDefaultPolicy

      public static org.eclipse.aether.repository.RepositoryPolicy createDefaultPolicy(MvnVersionType type, boolean enabled)
      Creates a policy for the specified type with reasonable defaults. See createPolicy(org.jdrupes.builder.mvnrepo.MvnVersionType,boolean,java.lang.String,java.lang.String).
      Parameters:
      type - the type
      enabled - the enabled
      Returns:
      the repository policy
    • createPolicy

      public static org.eclipse.aether.repository.RepositoryPolicy createPolicy(MvnVersionType type, RepositoryPolicy policy)
      Creates a policy from settings data. Fills in reasonable defaults if necessary.
      Parameters:
      type - the type
      policy - the policy data from settings
      Returns:
      the repository policy
    • createPolicy

      public static org.eclipse.aether.repository.RepositoryPolicy createPolicy(MvnVersionType type, boolean enabled, String updatePolicy, String checksumPolicy)
      Creates a policy from settings data with the given details. Fills in reasonable defaults for null values.
      Parameters:
      type - the type
      enabled - the enabled
      updatePolicy - the update policy. Defaults to "daily" for snapshots and "always" for releases
      checksumPolicy - the checksum policy. Defaults to "warn"
      Returns:
      the repository policy