how do you download files via ant though proxy [du

2019-02-19 11:46发布

问题:

This question already has an answer here:

  • Ant GET task and proxy 2 answers

I am using ant which uses an build.xml file. This is the command:

java version : 1.8.0 ant version: 1.7.1

CLASSPATH=/app/hbase-0.94.27/lib/hadoop-core-1.0.4.jar CFLAGS=-m64 CXXFLAGS=-m64 ant compile-native tar

it hangs here:

Buildfile: build.xml

ivy-download:
      [get] Getting: http://repo2.maven.org/maven2/org/apache/ivy/ivy/2.2.0/ivy-2.2.0.jar
      [get] To: /app/hadoop-lzo/ivy/ivy-2.2.0.jar

I get connection time out error:

BUILD FAILED
java.net.ConnectException: Connection timed out
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)

Ant also make a call to get some files from maven repository, part of build.xml file is this:

<property name="ivy.dir" location="ivy" />
  <loadproperties srcfile="${ivy.dir}/libraries.properties"/>
  <property name="ivy.jar" location="${ivy.dir}/ivy-${ivy.version}.jar"/>
  <property name="ivy_repo_url" value="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar"/>
  <property name="ivysettings.xml" location="${ivy.dir}/ivysettings.xml" />
  <property name="ivy.org" value="com.hadoop.compression"/>
  <property name="build.dir" location="build" />
  <property name="dist.dir" value="${build.dir}/${final.name}"/>
  <property name="build.ivy.dir" location="${build.dir}/ivy" />
  <property name="build.ivy.lib.dir" location="${build.ivy.dir}/lib" />

I've placed these lines into build.xml file:

   <target name="probe-proxy" depends="init">
        <condition property="proxy.enabled">
          <and>
            <isset property="192.168.101.1"/>
            <isreachable host="${proxy.host}"/>
          </and>
        </condition>
      </target>

  <target name="proxy" depends="probe-proxy" if="proxy.enabled">
    <property name="proxy.port" value="8080"/>
    <property name="proxy.user" value="smithJ"/>
    <property name="proxy.pass" value="Basketball123"/>
    <setproxy proxyhost="${proxy.host}" proxyport="${proxy.port}"
      proxyuser="${proxy.user}" proxypassword="${proxy.pass}"/>
  </target>

Still ant connection to maven to get some jar files via http hanging. Am I doing this right? Thanks.

回答1:

You're mixing technologies. ANT does not use "settings.xml" files, that is a configuration file for Maven.

I would suggest looking at the ANT documentation on how to configure proxies

https://ant.apache.org/manual/proxy.html