Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
692 views
in Technique[技术] by (71.8m points)

ant - Proxy settings with ivy

I have an issue where in I have defined dependancies in ivy.xml on our internal corporate svn. I am able to access this svn site without any proxy task in ant. While my dependencies resides on ibiblio, that’s something outside our corporate, and needs proxy inorder to download something. I am facing problem using ivy here.

I have following in 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>

Following is the excerpt from 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>
.  
.  
.  

So as can be seen here for getting ivy.xml, I don’t need any proxy as its within our own network which cant be accesses when I set proxy. But on the other hand I am using ibiblio as well which is external to our network and works only with proxy. So above build.xml wont work in that case. Can somebody help here.

I don’t need proxy while getting ivy.xml (as if I have proxy, ivy wont be able to find ivy file behind proxy from within the network), and I just need it when my resolver goes to public url.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

ANT proxy settings

Far as I know, proxy settings cannot be set within the ANT file. The documentation states that you need to set the following environment variable

export ANT_OPTS="-Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080"

These are system properties (as opposed to a normal ANT property).

Update: I stand corrected. I see you're using the setproxy method of setting the proxy. I've never used it. Setting the system parameters has always worked for me and had the advantage of being outside of the build file (for example when I'm working from home with no proxies).

To configure "no proxy" options

I don't know how to exclude local hosts using the ANT proxy mechanism. All I can suggest is trying to configure the JRE directly

http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/proxie_config.html

Maven resolver

For maven central dependencies you need a resolver that looks like this

<ibiblio name="maven2" m2compatible="true"/>

This will automatically go to the Maven central URL "http://repo1.maven.org/maven2". According to the doco this resolver will use the module POMs in Maven to determine transient dependencies.

Finally a word of warning. Unless you're using a modules section in your ivysettings file, make sure that your resolvers are declared within a chain resolver so that ivy will search both repositories for each module

<chain name="defaultResolver" returnFirst="true">
    <url name="privateFS">
        <ivy pattern="http://xyz.svn.com/ivyRepository/ [organisation]/ivy/ivy.xml"/>
    </url>
    <ibiblio name="maven2" m2compatible="true"/>
</chain>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...