Class RemoteRepository

java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.types.DataType
org.apache.maven.resolver.internal.ant.types.RemoteRepository
All Implemented Interfaces:
Cloneable, RemoteRepositoryContainer

public class RemoteRepository extends org.apache.tools.ant.types.DataType implements RemoteRepositoryContainer
Represents a single remote repository used for dependency resolution or deployment.

Supports configuration of release and snapshot policies, authentication, checksum and update strategies, and type-specific behaviors.

May be defined inline in Ant build scripts or referenced via refid.

See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Represents a repository policy configuration for either snapshot or release handling.
  • Field Summary

    Fields inherited from class org.apache.tools.ant.types.DataType

    checked, ref

    Fields inherited from class org.apache.tools.ant.ProjectComponent

    description, location, project
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor initializes a new RemoteRepository instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Allow Ant to add an Authentication element to this repository.
    void
    Allows Ant to add a release policy to this repository.
    void
    Adds a snapshot policy to this repository.
    protected static void
    Validates that the given checksum policy string is one of the permitted values.
    protected static void
    Validates that the given update policy string is one of the permitted values.
    Gets the Authentication credentials configured for this repository.
    Gets the checksum policy for this repository.
    Gets the unique identifier for this repository.
    Resolves this object if defined as a reference and verifies that it is a RemoteRepository instance.
    Gets the release policy configured for this repository.
    Returns a singleton list containing this repository.
    Gets the snapshot policy configured for this repository.
    Gets the layout type of this repository (e.g., default, legacy).
    Gets the update policy for this repository.
    Gets the URL of this repository.
    boolean
    Indicates whether releases are enabled for this repository.
    boolean
    Indicates whether snapshots are enabled for this repository.
    void
    setAuthRef(org.apache.tools.ant.types.Reference ref)
    Sets a reference to an existing Authentication element.
    void
    setChecksums(String checksums)
    Sets the checksum policy for this repository.
    void
    Sets the unique identifier for this repository.
    void
    setProject(org.apache.tools.ant.Project project)
     
    void
    setRefid(org.apache.tools.ant.types.Reference ref)
    Marks this repository as a reference to another RemoteRepository instance.
    void
    setReleases(boolean releases)
    Sets whether releases are enabled for this repository.
    void
    setSnapshots(boolean snapshots)
    Sets whether snapshots are enabled for this repository.
    void
    Sets the layout type of this repository.
    void
    setUpdates(String updates)
    Sets the update policy for this repository.
    void
    Sets the URL of this repository.
    void
    validate(org.apache.tools.ant.Task task)
    Validates this repository's configuration.

    Methods inherited from class org.apache.tools.ant.types.DataType

    checkAttributesAllowed, checkChildrenAllowed, circularReference, clone, dieOnCircularReference, dieOnCircularReference, dieOnCircularReference, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getDataTypeName, getRefid, invokeCircularReferenceCheck, isChecked, isReference, noChildrenAllowed, pushAndInvokeCircularReferenceCheck, setChecked, tooManyAttributes, toString

    Methods inherited from class org.apache.tools.ant.ProjectComponent

    getDescription, getLocation, getProject, log, log, setDescription, setLocation

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • RemoteRepository

      public RemoteRepository()
      Default constructor initializes a new RemoteRepository instance.
  • Method Details

    • setProject

      public void setProject(org.apache.tools.ant.Project project)
      Overrides:
      setProject in class org.apache.tools.ant.ProjectComponent
    • getRef

      protected RemoteRepository getRef()
      Resolves this object if defined as a reference and verifies that it is a RemoteRepository instance.
      Returns:
      the referenced RemoteRepository instance
      Throws:
      org.apache.tools.ant.BuildException - if the reference is invalid
    • validate

      public void validate(org.apache.tools.ant.Task task)
      Validates this repository's configuration. Ensures that both id and url are specified unless this is a reference.
      Specified by:
      validate in interface RemoteRepositoryContainer
      Parameters:
      task - the Ant task requesting validation, used for error reporting
      Throws:
      org.apache.tools.ant.BuildException - if required attributes are missing
    • setRefid

      public void setRefid(org.apache.tools.ant.types.Reference ref)
      Marks this repository as a reference to another RemoteRepository instance.

      Once set, this instance must not define other attributes or child elements.

      Overrides:
      setRefid in class org.apache.tools.ant.types.DataType
      Parameters:
      ref - the Ant reference to another RemoteRepository
      Throws:
      org.apache.tools.ant.BuildException - if conflicting attributes or children are already set
    • getId

      public String getId()
      Gets the unique identifier for this repository.
      Returns:
      the repository ID
    • setId

      public void setId(String id)
      Sets the unique identifier for this repository.
      Parameters:
      id - the repository ID
    • getUrl

      public String getUrl()
      Gets the URL of this repository.
      Returns:
      the base URL of the repository
    • setUrl

      public void setUrl(String url)
      Sets the URL of this repository.
      Parameters:
      url - the base URL of the repository
      Throws:
      org.apache.tools.ant.BuildException - if attributes are not allowed due to refid
    • getType

      public String getType()
      Gets the layout type of this repository (e.g., default, legacy).
      Returns:
      the type of repository layout
    • setType

      public void setType(String type)
      Sets the layout type of this repository.
      Parameters:
      type - the repository layout type
    • getReleasePolicy

      public RemoteRepository.Policy getReleasePolicy()
      Gets the release policy configured for this repository.
      Returns:
      the release policy or null if none is set
    • addReleases

      public void addReleases(RemoteRepository.Policy policy)
      Allows Ant to add a release policy to this repository.
      Parameters:
      policy - the policy to apply to release artifacts
      Throws:
      org.apache.tools.ant.BuildException - if a release policy was already defined
    • getSnapshotPolicy

      public RemoteRepository.Policy getSnapshotPolicy()
      Gets the snapshot policy configured for this repository.
      Returns:
      the snapshot policy or null if none is set
    • addSnapshots

      public void addSnapshots(RemoteRepository.Policy policy)
      Adds a snapshot policy to this repository.
      Parameters:
      policy - the policy to apply to snapshot artifacts
      Throws:
      org.apache.tools.ant.BuildException - if a snapshot policy was already defined
    • isReleases

      public boolean isReleases()
      Indicates whether releases are enabled for this repository.
      Returns:
      true if releases are enabled, false otherwise
    • setReleases

      public void setReleases(boolean releases)
      Sets whether releases are enabled for this repository.
      Parameters:
      releases - true to enable release artifacts
    • isSnapshots

      public boolean isSnapshots()
      Indicates whether snapshots are enabled for this repository.
      Returns:
      true if snapshots are enabled, false otherwise
    • setSnapshots

      public void setSnapshots(boolean snapshots)
      Sets whether snapshots are enabled for this repository.
      Parameters:
      snapshots - true to enable snapshot artifacts
    • getUpdates

      public String getUpdates()
      Gets the update policy for this repository.
      Returns:
      the update policy (e.g., daily, always, never)
    • setUpdates

      public void setUpdates(String updates)
      Sets the update policy for this repository.
      Parameters:
      updates - the update policy string
      Throws:
      org.apache.tools.ant.BuildException - if the policy is not valid
    • checkUpdates

      protected static void checkUpdates(String updates)
      Validates that the given update policy string is one of the permitted values.
      Parameters:
      updates - the update policy string to validate
      Throws:
      org.apache.tools.ant.BuildException - if the policy is not permitted
    • getChecksums

      public String getChecksums()
      Gets the checksum policy for this repository.
      Returns:
      the checksum policy (e.g., fail, warn, ignore)
    • setChecksums

      public void setChecksums(String checksums)
      Sets the checksum policy for this repository.
      Parameters:
      checksums - the checksum policy
      Throws:
      org.apache.tools.ant.BuildException - if the policy is not valid
    • checkChecksums

      protected static void checkChecksums(String checksums)
      Validates that the given checksum policy string is one of the permitted values.
      Parameters:
      checksums - the checksum policy string to validate
      Throws:
      org.apache.tools.ant.BuildException - if the policy is not permitted
    • getAuthentication

      public Authentication getAuthentication()
      Gets the Authentication credentials configured for this repository.
      Returns:
      the authentication element, or null if none
    • addAuthentication

      public void addAuthentication(Authentication authentication)
      Allow Ant to add an Authentication element to this repository.
      Parameters:
      authentication - the authentication credentials
      Throws:
      org.apache.tools.ant.BuildException - if multiple authentications are specified
    • setAuthRef

      public void setAuthRef(org.apache.tools.ant.types.Reference ref)
      Sets a reference to an existing Authentication element.
      Parameters:
      ref - the reference to an Authentication definition
    • getRepositories

      public List<RemoteRepository> getRepositories()
      Returns a singleton list containing this repository. This allows RemoteRepository to be treated as a RemoteRepositoryContainer.
      Specified by:
      getRepositories in interface RemoteRepositoryContainer
      Returns:
      a singleton list with this repository