Unable to add jar file to .ivy cache manually
Asked Answered
L

2

8

I am trying to manually add lucene jar file to my local ivy repository. I have other apache jars so under the existing folder .ivy2\cache\apache.org\ I've created a folder called lucene and inside it a folder called jars. I then placed the jar named lucene-3.0.3.jar in the jars folder. Next step I've created the following ivy-3.0.3.xml in the lucene folder:

<?xml version="1.0" encoding="UTF-8"?>

<ivy-module version="1.0">
    <info organisation="apache.org" module="lucene" revision="3.0.3" status="release" publication="20090416105712">
   </info>
   <publications>
      <artifact name="lucene-3.0.3" type="jar" ext="jar"/>
   </publications>
</ivy-module>

I then try to reference it from a project like that:

<dependency org="apache.org" name="lucene" rev="3.0.3"/>

But I get an error: "unresolved dependency: apache.org#lucene;3.0.3: not found"

I am able to find other dependencies from my .ivy2 cache folders, just this one that I've created manually is giving problems.

Anything I have missed?

Landers answered 15/3, 2011 at 15:59 Comment(0)
A
2

I agree with Mark, you should put the file in your local repository instead of your cache. Especially since the expectation is that the cache could be (and often is) deleted at any time.

However, to address your question, the most likely reason for your error is that your folder hierarchy does not match the expected pattern. By default, the cache is laid out as follows:

[organisation]/[module]/[revision]/[type]s/[artifact].[ext]

So you'd have to move your file to the following directory to eliminate that error:

.ivy2\cache\apache.org\lucene\3.0.3\jars\lucene.jar

Sometimes, the default pattern gets changed based on settings files so the only way to be certain of the expected pattern is to look at other jars in your cache (for example, right now, my cache has the [revision] portion at the end of the file name, otherwise, all else is the same).

However, I agree with Mark though, you really don't want to manually add things to the cache. Instead, add them to the default local repository OR better yet, create your own basic repository.

Annabell answered 16/3, 2011 at 19:23 Comment(2)
Thanks. I probably should have mentioned that I am doing this in order to self tutor myself on how ivy works and for experiment only. I am aware that ivy takes the jars from repository based on its resolvers but thought I'd try and mimic what it is doing :) thanksLanders
glad I could help with that understanding in some way. Incidentally, I want to mention that Ivy is one of the best documented tools I have ever seen. Fish around on that site I linked above and you will find every functionality of Ivy as well as extremely useful examples for each command. I know Ivy backward and forward and EVERYTHING I know, I learned from that site.Annabell
L
1

The ivy cache is not a repository, it's a cache (Different to Maven). The cache contains metadata files that record what ivy has previously downloaded.

I suggest you place files into ivy's local repository location which stored (by default) alongside the cache:

$HOME/.ivy2/local

So in your example the jar needs to be stored here:

$HOME/.ivy2/local/org.apache/lucene/3.0.3/jars/lucene.jar
Lateen answered 15/3, 2011 at 19:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.