问题
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?
回答1:
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.
回答2:
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
来源:https://stackoverflow.com/questions/5314433/unable-to-add-jar-file-to-ivy-cache-manually