开发者

Ivy publish to repository doesn't update local cache

开发者 https://www.devze.com 2023-02-02 22:31 出处:网络
Given: Building using Hudson/Ant. Ivy cache timeout is set to 5 min. Ivy repository contains has Project A version 2.2.2 and Project B version 1.1.1.

Given:

  • Building using Hudson/Ant.
  • Ivy cache timeout is set to 5 min.
  • Ivy repository contains has Project A version 2.2.2 and Project B version 1.1.1.
  • Project B relies on Project A.

Events:

  1. API change is made to Project A.
  2. Related changes are made to Project B.
  3. Project A version 2.2.3 is built and published to the repository.
  4. Under 5 minutes later, Project B version 1.1.2 is built.
  5. Project B fails, still pulling in Project A version 2.2.2 from开发者_如何转开发 the Ivy Cache.
  6. After 5 minutes, Project B will build correctly, with Project A version 2.2.3

I've looked but don't see an obvious solution (except not caching?). Is there a setting on publish that will update the local cache and the repo? Do you need to explicitly publish to both?


Just speculation: if A and B are built on the same machine, would doing an <ivy:resolve refresh="true"> at the end of A's build refresh the cache? That doesn't help if A and B build on separate machines, of course...


One solution, similar to (but not as bad as) not caching is to decrease the time things live in the cache via setting the following ivy property:

ivy.cache.ttl.default                 = 30s

Maybe that would fix your problem, for now. Although, it's not much better than not caching.

Off the top of my head, another thing I might try is to turn off caching but then re-implement caching manually by creating a filesystem resolver in your ivy settings file that points to the cache and placing it lower on the chain. That would look something like this:

<ivysettings>
    <settings defaultResolver="all-repositories" />
    <include file="ivysettings-common.xml" />
    <resolvers>
        <chain name="all-repositories" returnFirst="true" >
            ...
            <ibiblio name="ibiblio" m2compatible="true" />
            <filesystem name="manual-cache">
                <ivy pattern="${ivy.default.ivy.user.dir}/cache/${ivy.local.default.ivy.pattern}" />
                <artifact pattern="${ivy.default.ivy.user.dir}/cache/${ivy.local.default.artifact.pattern}" />
            </filesystem>
            ...
        </chain>    
    </resolvers>
</ivysettings>

Note: that ivy.default.ivy.user.dir, ivy.local.default.ivy.pattern and ivy.local.default.artifact.pattern are built-in properties that are set by default. I'm referencing them here in this example but I wouldn't need to make any other special effort to set them (they contain proper default values, already).

I hope one of these approaches can address your issue. Those are the only two possible solutions that come to mind, right now.


In the ivy file of project B you need to set the changing attribute to true on the dependency.

  <dependency org="org.example" name="A" revision="latest.integration" changing="true" />

See the ivy documentation

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号