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

public class Proxy extends org.apache.tools.ant.types.DataType
Defines a proxy configuration for Maven artifact resolution.

This Ant data type allows specification of a proxy host, port, type (e.g., HTTP), non-proxy hosts, and optional authentication credentials. Once declared, it is automatically registered with the project's repository system.

A proxy definition can also be referenced by refid, allowing reuse and modular build files. When defined as a reference, no other attributes or nested elements may be set.

See Also:
  • 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 the proxy with no settings.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Allow Ant to add an <authentication> child element to configure credentials for the proxy.
    Returns the Authentication settings associated with this proxy.
    Returns the proxy host name or IP address.
    Returns the non-proxy hosts setting, typically a pipe-delimited list.
    int
    Returns the proxy port number.
    protected Proxy
    Resolves this object if defined as a reference and verifies that it is a Proxy instance.
    Returns the proxy type, such as http.
    void
    setAuthRef(org.apache.tools.ant.types.Reference ref)
    Sets a reference to an existing Authentication element to be used for this proxy.
    void
    Sets the proxy host name or IP address.
    void
    setNonProxyHosts(String nonProxyHosts)
    Sets the non-proxy hosts — hosts that should bypass the proxy.
    void
    setPort(int port)
    Sets the proxy port number.
    void
    setProject(org.apache.tools.ant.Project project)
    Sets the associated Ant Project and registers this proxy instance with the repository system.
    void
    setRefid(org.apache.tools.ant.types.Reference ref)
    Sets this proxy as a reference to another defined proxy.
    void
    Sets the proxy type (e.g., http).

    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

    • Proxy

      public Proxy()
      Default constructor initializes the proxy with no settings. This allows attributes to be set before the project is assigned.
  • Method Details

    • setProject

      public void setProject(org.apache.tools.ant.Project project)
      Sets the associated Ant Project and registers this proxy instance with the repository system.
      Overrides:
      setProject in class org.apache.tools.ant.ProjectComponent
      Parameters:
      project - the Ant project
    • getRef

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

      public void setRefid(org.apache.tools.ant.types.Reference ref)
      Sets this proxy as a reference to another defined proxy.

      This method must not be used in combination with any other attributes or nested <authentication> elements.

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

      public String getHost()
      Returns the proxy host name or IP address.
      Returns:
      the proxy host
    • setHost

      public void setHost(String host)
      Sets the proxy host name or IP address.
      Parameters:
      host - the proxy host to use
      Throws:
      org.apache.tools.ant.BuildException - if this object is a reference
    • getPort

      public int getPort()
      Returns the proxy port number.
      Returns:
      the port number
    • setPort

      public void setPort(int port)
      Sets the proxy port number. Must be within the range 1 to 65535.
      Parameters:
      port - the port number
      Throws:
      org.apache.tools.ant.BuildException - if the port is out of range or attributes are not allowed
    • getType

      public String getType()
      Returns the proxy type, such as http.
      Returns:
      the proxy type, or null if not set
    • setType

      public void setType(String type)
      Sets the proxy type (e.g., http).
      Parameters:
      type - the proxy protocol type
      Throws:
      org.apache.tools.ant.BuildException - if this object is a reference
    • getNonProxyHosts

      public String getNonProxyHosts()
      Returns the non-proxy hosts setting, typically a pipe-delimited list.
      Returns:
      the non-proxy hosts
    • setNonProxyHosts

      public void setNonProxyHosts(String nonProxyHosts)
      Sets the non-proxy hosts — hosts that should bypass the proxy. The format is usually a pipe-separated list (e.g., localhost|*.example.com).
      Parameters:
      nonProxyHosts - the non-proxy hosts pattern
      Throws:
      org.apache.tools.ant.BuildException - if this object is a reference
    • getAuthentication

      public Authentication getAuthentication()
      Returns the Authentication settings associated with this proxy.
      Returns:
      the authentication configuration, or null if none
    • addAuthentication

      public void addAuthentication(Authentication authentication)
      Allow Ant to add an <authentication> child element to configure credentials for the proxy.
      Parameters:
      authentication - the authentication element
      Throws:
      org.apache.tools.ant.BuildException - if multiple authentications are specified or children are not allowed
    • setAuthRef

      public void setAuthRef(org.apache.tools.ant.types.Reference ref)
      Sets a reference to an existing Authentication element to be used for this proxy.

      This allows the proxy to reuse a separately defined <authentication> element via Ant's refid mechanism, enabling modular and reusable configuration. If no authentication has been previously configured, a new Authentication instance is created and associated with the project.

      Parameters:
      ref - the Ant reference pointing to an existing Authentication instance
      See Also: