代理设置与ivy

19

我遇到了一个问题,我在ivy.xml中对我们公司内部的svn定义了依赖项。我能够在ant中没有代理任务的情况下访问此svn站点。虽然我的依赖关系驻留在ibiblio上,但那是公司外部的,需要代理才能下载东西。我在这里使用ivy时遇到了问题。

我在build.xml中有以下内容

<target name="proxy">  
    <property name="proxy.host" value="xyz.proxy.net"/>  
    <property name="proxy.port" value="8443"/>  
    <setproxy proxyhost="${proxy.host}" proxyport="${proxy.port}"/>  
</target>  

<!-- resolve the dependencies of stratus -->
<target name="resolveTestDependency" depends="testResolve, proxy" description="retrieve test dependencies with ivy">
    <ivy:settings file="stratus-ivysettings.xml" />
    <ivy:retrieve conf="test" pattern="${jars}/[artifact]-[revision].[ext]"/><!--pattern here specifies where do you want to download lib to?-->                                          
</target>

<target name=" testResolve ">
    <ivy:settings file="stratus-ivysettings.xml" />
    <ivy:resolve conf="test" file="stratus-ivy.xml"/>
</target>

以下是从 stratus-ivysettings.xml 中摘录的内容

<resolvers>  
    <!-- here you define your file in private machine not on the repo (e.g. jPricer.jar or edgApi.jar)-->  
    <!-- This we will use a url nd not local file system.. -->  
    <url name="privateFS">  
        <ivy pattern="http://xyz.svn.com/ivyRepository/ [organisation]/ivy/ivy.xml"/>                                                    
    </url>  
.  
.  
.  
    <url name="public" m2compatible="true">     
        <artifact pattern="http://www.ibiblio.org/maven2/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"/>  
    </url>
.  
.  
.  

从这里可以看出,为了获取ivy.xml文件,我不需要任何代理,因为它位于我们自己的网络中,当我设置代理时无法访问。但另一方面,我也在使用外部的ibiblio,只能通过代理工作。所以上述build.xml在这种情况下将无法工作。有人能帮忙吗。

在获取ivy.xml文件时,我不需要代理(如果我使用代理,ivy无法从网络内部的代理后面找到ivy文件),只有当我的解析器前往公共URL时才需要代理。


你可以使用Intellij IDEA调试器来查找正在发生的事情,我正在这样做以了解Apache Spark如何下载JAR文件,发现有一个BasicURLHandler(https://github.com/apache/ant-ivy/blob/master/src/java/org/apache/ivy/util/url/BasicURLHandler.java),似乎不支持代理。 - Thomas Decaux
1个回答

15

当使用setproxy时,可以使用nonproxyhosts属性来指定不应该使用代理的主机(使用管道符分隔)。例如,在您的示例中修改setproxy任务:

<setproxy proxyhost="${proxy.host}"
          proxyport="${proxy.port}"
          nonproxyhosts="xyz.svn.com"/>

更多详细信息请参见http://ant.apache.org/manual/Tasks/setproxy.html


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接