How to publish native libraries with Ivy?

后端 未结 1 328
孤独总比滥情好
孤独总比滥情好 2021-01-07 06:38

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 publi

相关标签:
1条回答
  • 2021-01-07 07:09

    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.

    0 讨论(0)
提交回复
热议问题