In my ivysettings.xml I have configured some cache which avoid having the resolver use the common .ivy2 cache. If on the resolve task I set useCacheOnly="true", then my artifacts in the cache won't be found.
I'll attach a complete test case for the different scenario:
- defaultResolver="ibiblio", useCacheOnly="false", dependency on common-logging-1.1: nominal behaviour, everything works fine, artifacts get downloaded into .ivy2
- defaultResolver="ibiblio", useCacheOnly="true", dependency on common-logging-1.1: there is a bug in the CacheResolver, artifacts are not "downloaded", they not found. It was a missing ensuredConfigured(). I'll commit that as I am quite confident in that fix. With the fix, everything goes well.
- defaultResolver="chain", useCacheOnly="false", dependency on common-logging-1.2: it should be not be found in the ibiblio resolver but in the local one. Everything works fine, it get cached correctly from the local repo.
- defaultResolver="chain", useCacheOnly="true", dependency on common-logging-1.2: it is not found. As I was debugging it, in fact the CacheResolver isn't configured with the proper cache manager, so it uses the default one. So it looks in the wrong cache.
My proposal as the last fix is to not use the cache resolver as a dictator resolver when we want useCacheOnly. I don't see any obvious way to make cache resolver aware of the cache it should look into, further more when there is chaining. I suggest to move this logic in the configured resolvers. I tried a very simple patch and it seems to work nicely. See the attached patch. I am not confident enough to commit it without review as it might be quite incomplete or have some side effect. At least it works with some chaining and even if there is some useOrigin=true