Ivy - Add repository, get from specific repository
Asked Answered
H

2

6

I'm pretty new to IVY. I'm trying to do the following:

I wanted to add http://mvnrepository.com to the repository list. I'm not sure if I have to define the correct pattern based on how it is defined under mvnrepository.

Also I want a specific library to be downloaded from there instead of from another repository.

This is my ivysettings file:

<ivysettings>
    <properties file="build.properties" />
    <settings defaultResolver="local-chain"/>
    <resolvers>
        <ibiblio name="ibiblio-maven2" m2compatible="true"/>
        <ibiblio name="java-net-maven2" root="http://download.java.net/maven/2/" m2compatible="true" />
        <ibiblio name="maven" root="http://mvnrepository.com/artifact/" m2compatible="true" />
        <filesystem name="project-built" checksums="">
            <ivy pattern="${repository.dir}/[module]-ivy.xml" />
            <artifact pattern="${repository.dir}/[artifact].[ext]" />
        </filesystem>
        <chain name="local-chain">
            <resolver ref="maven"/>
            <resolver ref="ibiblio-maven2"/>
            <resolver ref="java-net-maven2"/>
            <resolver ref="project-built"/>
        </chain>
    </resolvers>

And this is my ivy file:

<ivy-module version="1.0">
<info organisation="project" module="com.project.test.framework" />
<dependencies>
    <dependency org="commons-collections" name="commons-collections" rev="3.2"/>
    <dependency org="commons-configuration" name="commons-configuration" rev="1.6"/>
    <dependency org="commons-lang" name="commons-lang" rev="2.6"/>
    <dependency org="commons-logging" name="commons-logging" rev="1.1"/>
    <dependency org="junit" name="junit" rev="4.8"/>
    <dependency org="org.seleniumhq.selenium" name="selenium" rev="2.0rc2"/>    
    <dependency org="net.sf.json-lib" name="json-lib" rev="2.4" conf="default->compile"/>   
    <dependency org="com.sun.jersey" name="jersey-core" rev="1.8" conf="default->compile"/> 
    <dependency org="com.sun.jersey" name="jersey-client" rev="1.8" conf="default->compile"/>   
</dependencies>

Basically I want JSON to be downloaded from MAVEN mvnrepository. I thought that when I put maven into the first place it will get it from there and that's that. But it doesn't seem to be using mvnrep at all.

I do think it's configured the wrong way.. But I'm not sure how to do it right.

I did read a lot of posts about it, and I still don't feel that I know the solution.

Thanks for any kind of help!!

Haggadah answered 4/8, 2011 at 8:21 Comment(0)
B
9

To force specific resolver for a module use something like this in your ivysettings.xml:

<ivysettings>
    <properties file="build.properties" />
    <settings defaultResolver="local-chain"/>
    <resolvers>
        <ibiblio name="ibiblio-maven2" m2compatible="true"/>
        <ibiblio name="java-net-maven2" root="http://download.java.net/maven/2/" m2compatible="true" />
        <ibiblio name="maven" root="http://mvnrepository.com/artifact/" m2compatible="true" />
        <filesystem name="project-built" checksums="">
            <ivy pattern="${repository.dir}/[module]-ivy.xml" />
            <artifact pattern="${repository.dir}/[artifact].[ext]" />
        </filesystem>
        <chain name="local-chain">
            <resolver ref="maven"/>
            <resolver ref="ibiblio-maven2"/>
            <resolver ref="java-net-maven2"/>
            <resolver ref="project-built"/>
        </chain>
    </resolvers>
    <modules>
      <module organisation="json" resolver="maven"/>
    </modules>
</ivysettings>

See the documentation for details.

Bridgeman answered 4/8, 2011 at 8:55 Comment(3)
where do I configure modules?Haggadah
Ahh nice. Thanks. Now I see that there is something wrong with the way it tries to find the module... It looks for: mvnrepository.com/net/sf/json-lib/json-lib/2.4/json-lib-2.4.pom but that's not where it is. :) Finally a step closer.. THANKS!Haggadah
You wont believe this. I set the correct name for the artifact and it STILL uses ibiblio-maven2.. And it DID use maven when it was wrong but once I fixed it, it doesn't use it anymore. :DHaggadah
P
0

Perhaps you are missing the returnFirst="true" attribute from your chain.

Pons answered 4/8, 2011 at 8:44 Comment(1)
To what do I add returnFirst="true?"Haggadah

© 2022 - 2024 — McMap. All rights reserved.