Resolve Ivy dependency version order

倾然丶 夕夏残阳落幕 提交于 2019-12-11 10:11:49

问题


In my build artifact repository, I have builds from both a branch and a trunk.

I have tested that my resolve works to the branch, and grabs the correct item.

But this doesn't work if the dependency is also in the trunk repo. In this case it grabs the dependency from the trunk and not my branch.

I need resolve to pull a dependency from the trunk repo if it's not in the branch, but if the dependency is in the branch, I need the branch version, not the trunk version.

How can I do this in Ivy? I'd prefer it to just find the branch version, then stop looking for it. That way if it's missing from the branch, it "falls through" to the trunk version.

Is it possible the way I am using build numbers is incorrect for this situation?

Here is an example:

trunkbuild - version = "1.0.4" branchbuild - version = "1.0-SNAPSHOT"

Should my branches be "1.1-SNAPSHOT" instead?

The code in my branches should always be a version AHEAD, not behind the trunk.


回答1:


I think it's dynamic revisions is what you're looking for:

<dependency org="mygroup" name="myartifact" revision="latest.release"/>
<dependency org="mygroup" name="myartifact" revision="latest.integration"/>

Maven repositories supports two basic types of repository:

  • Release
  • Snapshot

Only artifacts built on my trunk branch are published to the Release repository.

So the following ivy resolver setup should be enough to get it working, with "latest.integration" resolving to artifacts in the snapshots repo.

<ivysettings>
    <settings defaultResolver="default"/>
    <resolvers>
        <chain name="default">
            <ibiblio name="nexus-central" root="http://myhost/nexus/content/repositories/central" m2compatible="true"/>
            <ibiblio name="nexus-releases" root="http://myhost/nexus/content/repositories/releases" m2compatible="true"/>
            <ibiblio name="nexus-snapshots" root="http://myhost/nexus/content/repositories/snapshots" m2compatible="true"/>
        </chain>
    </resolvers>
</ivysettings>

Note:

You could create a repository group within your repository manager and simplify the ivy setup to a single URL.



来源:https://stackoverflow.com/questions/8524755/resolve-ivy-dependency-version-order

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!