18

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

我在 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 时我只需要它。

4

1 回答 1

14

使用 时setproxy,使用该nonproxyhosts属性指定不应使用代理的主机(管道分隔)。例如,setproxy将示例中的任务修改为

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

有关更多详细信息,请参阅http://ant.apache.org/manual/Tasks/setproxy.html

于 2011-03-14T01:26:44.023 回答