How to publish native libraries with Ivy?

佐手、 提交于 2019-12-01 01:05:49
Nicolas Lalevée

The best way with Ivy to manage many "same" artifact which only difference is the architecture, is to use extra attributes.

So in your module you would declare:

<publications xmlns:e="http://ant.apache.org/ivy/extra">
    <artifact name="MyLib" type="jar" ext="jar" />
    <artifact name="libStuff" type="native" ext="so" e:arch="armeabi" />
    <artifact name="libStuff" type="native" ext="so" e:arch="armeabi-v7a" />
    <artifact name="libStuff" type="native" ext="so" e:arch="mips" />
    <artifact name="libStuff" type="native" ext="so" e:arch="x86" />
</publications>

The drawbacks is that your entire chain around Ivy would have to take that extra attribute into account. For instance, you should be able to configure your repository so it would accept a custom pattern like this one:

${repository.dir}/[organisation]/[module]/[arch]/[revision]/[artifact].[ext]

Another solution, as you mentioned, is to work with a zip folder. And this may be a good timing since Ivy 2.4 which is just about to be released, is supporting zipped folder via packaging.

For instance you could declare:

<publications xmlns:e="http://ant.apache.org/ivy/extra">
    <artifact name="MyLib" type="jar" ext="jar" />
    <artifact name="libStuff" type="natives" ext="zip" packaging="zip" />
</publications>

Then Ivy will download a libStuff-1.2.3.zip into its cache and will automatically unzip it into the cache to libStuff-1.2.3, folder in which you could find your several natives libraries.

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