如何使用Ivy发布本地库? [英] How to publish native libraries with Ivy?

查看:131
本文介绍了如何使用Ivy发布本地库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于Java库项目,发布的工件很简单,因为输出是单个jar文件。然而,我还有一个项目需要发布以下内容:


  • MyLib.jar

  • armeabi / libStuff.so

  • armeabi-v7a / libStuff.so

  • mips / libStuff.so

  • x86 / libStuff.so


我无法将所有这些.so文件设置为工件,因为它们都具有相同的名称。推荐的路线是什么?把所有内容放在一个zip文件中,并让用户在构建之前使用gradle(或ant或其他)来解压缩它?我应该把Jar文件放在拉链之外吗?是否有这样的工件惯例?

解决方案

常春藤管理许多相同神器的最佳方式,只有不同架构,是使用额外属性



所以在你的模块中,你需要声明:

 < publications xmlns: E = http://ant.apache.org/ivy/extra > 
< artifact name =MyLibtype =jarext =jar/>
< / publications>

缺点是您的整个Ivy链需要考虑额外的属性。例如,您应该能够配置您的存储库,以便接受像这样的自定义模式: dir} / [organization] / [module] / [arch] / [revision] / [artifact]。[ext]






另外一个解决方案,就像你提到的那样,就是使用zip文件夹。这可能是一个很好的时机,因为即将发布的Ivy 2.4,通过

<$ p $ rel =nofollow noreferrer> packaging>

p> < publications xmlns:e =http://ant.apache.org/ivy/extra>
< artifact name =MyLibtype =jarext =jar/>
< artifact name =libStufftype =nativesext =zippackaging =zip/>
< / publications>

然后Ivy会下载一个 libStuff-1.2.3.zip 放到它的缓存中,并自动将它解压缩到 libStuff-1.2.3 ,这个文件夹中你可以找到你的几个本地库。


For Java library projects, the artifact to publish is straightforward since the output is a single jar file. However, I also have a project with the following stuff to publish:

  • MyLib.jar
  • armeabi/libStuff.so
  • armeabi-v7a/libStuff.so
  • mips/libStuff.so
  • x86/libStuff.so

I cannot setup all those .so files as artifacts, since they all have the same name. What is the recommended way to go? Put everything in a zip and let users use gradle (or ant or whatever) to unzip it prior to the build? Should I put the Jar file aside from the zip? Is there a convention for such artifacts?

解决方案

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.

这篇关于如何使用Ivy发布本地库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆