tags:

views:

591

answers:

1

Hi,

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]"/&gt;  
                                </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.

A: 

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>
Mark O'Connor
i think you missed this 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.I dont need proxy while using ivy.xml from within corporate accessible svn, while i need proxy for downloading the jars.
Ivy is able to get: 1) Artifacts listed in an ivy.xml file (ivy repository) 2) Retrieve artifacts listed in a pom.xml file (maven repository) 3) Artifacts on their own. ANALYSIS: The first part of my post provided a soln that has worked for me (setting ANT_OPTS). The second part of my post pointed out a better mechanism for Maven download (when you finally solve your proxy issue). RECOMMENDATION: I suggest you run ANT in verbose (and maybe debug) mode in order to diagnose exactly what is going on. There is not enough information provided to perform any further analysis
Mark O'Connor
To selectively choose which URL is subject to proxying would appear to be outside the scope of ivy. This would be an ANT question.
Mark O'Connor