Other Ivy Tokens Available?

偶尔善良 提交于 2019-12-24 15:13:44

问题


Is there a way when designating a resolver ivy pattern to be able to produce the following output?

C:/MyRepository/MyCompany/MyModule/1.2.3/4/ivy.xml

Currently, the [revision] token resolves to the full 4-digit version number. I'd like to be able to use the first three digits of the revision for a part of the pattern and use the last digit for a subfolder below that. Is this possible or would I have to write custom ant code to do this?

Something like this:

<resolvers>
    <filesystem name="myresolver">
        <ivy pattern="${my.dir}/[organisation]/[module]/[shortversion]/[rev]/ivy.xml" />
        <artifact pattern="${my.dir}/[organisation]/[module]/[shortversion]/[rev]/([target])[artifact].[ext]" />
    </filesystem>
</resolvers>

where:

${my.dir} = C:/MyRepository/

and the ivy tokens have these values:

[organisation] = MyCompany
[module] = MyModule
[shortversion] = 1.2.3
[rev] = 4

I realize I'm making up these fictitious tokens (shortrevision and rev), but what I'd like to be able to do is get at the revision number parts (major, minor, build, revision) so that I can use them in the pattern.


回答1:


ivy supports extra attributes which can attached to the dependency declaration as follows:

<ivy-module version="2.0" xmlns:e="http://ant.apache.org/ivy/extra">
    ..
    <dependency org="MyCompany" name="MyCompany" rev="1.2.3" e:buildnum="4"/>

The extra attributes are used as normal within your resolver patterns as follows:

<resolvers>
    <filesystem name="myresolver">
        <ivy pattern="${my.dir}/[organisation]/[module]/[revision]/[buildnum]/ivy.xml" />
        <artifact pattern="${my.dir}/[organisation]/[module]/[revision]/[buildnum]/[artifact].[ext]" />
    </filesystem>
</resolvers>


来源:https://stackoverflow.com/questions/10354666/other-ivy-tokens-available

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