1

Extreme edit to question to have it make more sense:

Let's assume that I need to use a local version of httpclient rather than one that I can just pull from an online repo (due to signing reasons). The way that I want to handle this is like so...

ivy.xml


<dependencies>  
    ...Other dependencies here
    <dependency org="com.apache" name="httpclient" rev="4.2.2" conf="compile->default" ext="jar" />
</dependencies>

ivysettings.xml


<settings defaultResolver="central"/>

<resolvers>
<url name="repo">
    <ivy pattern="http://myServer:8080/Repo/[organisation]/[artifact]/[revision]/ivy.xml" />
    <artifact pattern="http://myServer:8080/Repo/[organisation]/[artifact]/[revision]/[artifact].[ext]"/>
</url>

<url name="httpclient">
    <artifact pattern="http://myServer:8080/Repo/com.apache/httpclient/4.2.2/[artifact].[ext]"/>
</url>



<modules>
    <module organisation="com.apache" resolver="repo" />
    <module organisation="com.httpclient" resolver="httpclient" />
</modules>

Now what I'm hoping for here (and haven't been having much luck with) is the com.apache resolver looking for myServer:8080/Repo/com.apache/httpclient/4.2.2/ivy.xml and reading that, here's the contents of that file:

ivy.xml (in myServer:8080/repo/... directory)


    <dependency org="com.httpclient" name="commons-codec" rev="1.6" />
    <dependency org="com.httpclient" name="commons-logging" rev="1.1.1" />
    <dependency org="com.httpclient" name="fluent-hc" rev="4.2.2" />
    <dependency org="com.httpclient" name="httpclient" rev="4.2.2" />
    <dependency org="com.httpclient" name="httpclient-cache" rev="4.2.2" />
    <dependency org="com.httpclient" name="httpcore" rev="4.2.2" />
    <dependency org="com.httpclient" name="httpmime" rev="4.2.2"/>

The reasoning behind wanting to read the second xml file rather than including the markup in my first file is pretty obvious when you consider how many LOC that would add to something that we include frequently. It also makes all future includes easier as well.

Right now the error that I'm getting is:

Some projects fail to be resolved Impossible to resolve dependencies of com.myCompany#myProgramt;working@CompName unresolved dependency: com.apache#httpclient;4.2.2: not found


Thanks for your help on this matter.

A_Elric
  • 3,508
  • 13
  • 52
  • 85

3 Answers3

1

When you configure your build to use the following resolver

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

You are telling ivy to download its dependencis from Maven Central

What is your objective here? To create a local ivy repo that functionally works like Maven Central? In that case the simplest solution would be to setup a Maven repository manager like: Nexus, Artifactory or Archiva. A maven repository manager can act like a smart cache and "proxy" jars stored in the Central Maven repo.

Configuring your build to use a local Maven Repository is easy:

 <ibiblio name="central" m2compatible="true" root="http://hostname:portnum/MavenRepo/>
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • Unfortunately I can't do it this way due to signing restrictions on jnlp files. The jars that I pull from central are signed by apache and I can't seem to unsign them at the time of compilation, therefore I've been adding them into a personal repo and unsigning them then signing them when we deploy... it's wacky and I hate it... You are actually the exact person that I was hoping would answer this though. – A_Elric Nov 27 '12 at 13:56
  • My goal is to have an ivy.xml file go to resolve something like com.apache, and then have com.apache have a custom resolver. That resolver will point to an area in my repo that will have another ivy.xml file that outlines all the things in httpclient. So in essence: Ivy.xml > ivysettings.xml > url resolver > Ivy pattern="my2ndIvy.xml" which contains all the dependencies of httpclient.... is that even possible? – A_Elric Nov 27 '12 at 14:10
  • Rewrote the whole question. – A_Elric Nov 27 '12 at 16:56
  • @Damien.Bell You're repackaging someone else's software.... I'd suggest a simpler scheme: Use a single ivy module, and use it to publish all the revised jars. – Mark O'Connor Nov 28 '12 at 03:29
  • How would I go about that? Just a giant dependencies thing? – A_Elric Nov 28 '12 at 13:56
  • Yup, one ivy file publishing all the altered jars. See: http://stackoverflow.com/questions/1200762/good-ivy-tutorial-for-local-repository/2279596#2279596 – Mark O'Connor Nov 28 '12 at 18:35
1

Ivy expects to find all the dependencies of a given artifact in the same resolver. So, it finds the artifacts for com.apache in your repo resolver, and expects to find com.httpclient in there as well.

Ivy also will roll through your <ivy pattern.../> and <artifact pattern.../> statements in order within the same resolver declaration. You can use this to your advantage to create a single resolver which hits both repositories in the order you want:

<url name="amalgamation">
    <ivy pattern="http://myServer:8080/Repo/[organisation]/[artifact]/[revision]/ivy.xml" />
    <artifact pattern="http://myServer:8080/Repo/[organisation]/[artifact]/[revision]/[artifact].[ext]"/>
    <artifact pattern="http://myServer:8080/Repo/com.apache/httpclient/4.2.2/[artifact].[ext]"/>
</url>
David
  • 2,602
  • 1
  • 18
  • 32
  • So, tell me, assuming that the ivy pattern is found, and it contained entries like in the last code block above, could it resolve those? That way I could make a single ivy file for any folder full of jars that I needed to include, then I could just point to that ivy.xml file. – A_Elric Nov 29 '12 at 06:13
  • Right... you can have artifact patterns that point to locations on your local file system, you'll want to define the URLs like `file:///some/folder/of/jars`, or use the filesystem resolver. Most of my projects have a local folder of jars that are most commonly required for the project to build, or aren't available "in the wild", and then resolve everything else from either ibiblio or another remote repository. It's easiest to manage that with [a resolver chain](http://ant.apache.org/ivy/history/latest-milestone/resolver/chain.html) – David Nov 29 '12 at 13:51
  • David, all the files are located at http://myServer:8080/Repo/com.apache/httpclient/4.2.2/[artifact].[ext], I just don't know what to put into the second ivy file. Do I need a second ivysettings file too? – A_Elric Nov 29 '12 at 13:52
  • You only need one ivysettings file with the resolver declaration like I posted above. Your project that needs the artifacts should have one ivy.xml that just asks for the artifacts it needs. The artifacts in your repository will need an ivy.xml that describes their publications and transitive dependencies, and that ivy.xml has to live at the location you specify in the `` in your ivysettings.xml. – David Nov 29 '12 at 14:00
  • Can you perhaps post a secondary ivy file so I can see it? – A_Elric Nov 29 '12 at 14:02
  • If you'd like we can have a chat about this: http://chat.stackoverflow.com/rooms/20333/ivy-help I think I understand, but I'm a little lost. – A_Elric Nov 29 '12 at 14:18
0

What server are you using for your remote JAR repository?

Both Nexus and Artifactory can be setup to pull jars stored locally on themselves before puling ones from the remote repository. This way, you don't have to munge your ivysettings.xml. Instead, you simply download your preferred versions of the jars on Artifactory/Nexus. And, both are free, open source, downloads. It's way easier to do what you want with Artifactory/Nexus than futzing with your Ivy settings.

By the way, I have a Ivy project in Github you might want to look at. You simply attach this project to your Ant project, and it has everything automatically configured for Ivy. This way, an entire site can use Ivy for all of their projects, and everything is centrally controlled.

David W.
  • 105,218
  • 39
  • 216
  • 337