Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use public maven repository with ivy

I have an ivy.xml containing

<dependencies>   <dependency org="commons-lang" name="commons-lang" rev="2.4"/>   <dependency org="foo-bar" name="superwidgets" rev="1.5"/> </dependencies> 

The whole superwidget stuff is hosted in a maven repository at http://example.com/m2/. The ivy documentation mentions resolvers, but it seems to assume an ivy repository. How can I add a single unofficial maven repository to my ivy settings to be used only by a single module? (Or put another way, what corresponds to maven's <repository> tag in ivy?) Nothing fancy, so I'd expect a one-liner in my ivy.xml.

like image 432
Adam Schmideg Avatar asked Jan 29 '11 09:01

Adam Schmideg


People also ask

Does ivy use maven?

Apache Ivy is compatible with maven 2 metadata, the default public repository used is also the maven 2 repository, which is fine for a good out of the box experience.

What is public maven repository?

Public repositories store software artifacts that are free for the entire world to download. Maven and other build tools connect to public repositories to download dependencies used in software projects. Dependencies are downloaded to the local maven repository, which defaults to the ~/.

Which is the most popular public maven repository?

Maven Central, a.k.a. the Central Repository, is the default repository for Maven, SBT, Leiningen, and many other JVM based build tools. It has been around since 2002, and serves many terabytes of assets every year.

How do I use maven repository?

Maven local repository by default get created by Maven in %USER_HOME% directory. To override the default location, mention another path in Maven settings. xml file available at %M2_HOME%\conf directory. When you run Maven command, Maven will download dependencies to your custom path.


1 Answers

You need to add an ivysettings.xml file with the following repositories listed (resolvers in ivy speak)

<ivysettings>     <settings defaultResolver="chain"/>     <resolvers>         <chain name="chain">             <ibiblio name="central" m2compatible="true"/>             <ibiblio name="example" m2compatible="true" root="http://example.com/m2/"/>         </chain>     </resolvers> </ivysettings> 

In my opinion it makes more sense to separate the dependency declaration (ivy.xml) from the mechanism of retrieval (settings.xml). This is not needed in Maven because it only supports one type of repository.

If you want to get really fancy you can control which respository serves up a particular module:

<ivysettings>     <settings defaultResolver="central"/>     <resolvers>         <ibiblio name="central" m2compatible="true"/>         <ibiblio name="example" m2compatible="true" root="http://example.com/m2/"/>     </resolvers>     <modules>         <module organisation="foo-bar" name="superwidgets" resolver="example"/>     </modules> </ivysettings> 
like image 100
Mark O'Connor Avatar answered Sep 28 '22 00:09

Mark O'Connor