你怎么通过ant通过代理下载文件

时间:2015-06-13 01:18:12

标签: java maven ant proxy

我使用的是使用build.xml文件的ant。这是命令:

java版本:1.8.0 蚂蚁版:1.7.1

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

它挂在这里:

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

我收到连接超时错误:

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也调用从maven存储库获取一些文件,build.xml文件的一部分是:

<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" />

我已将这些行放入build.xml文件中:

   <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>

仍然与maven连接,通过http挂起获取一些jar文件。我这样做了吗?感谢。

1 个答案:

答案 0 :(得分:0)

你正在混合技术。 ANT不使用“settings.xml”文件,即Maven的配置文件。

我建议查看有关如何配置代理的ANT文档

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