开发者

Published artifact patterns in Ivy

开发者 https://www.devze.com 2023-03-17 04:10 出处:网络
When I resolve artifacts from my repository (e.g. filesystem), I use two artifact patterns: <artifact pattern=\"${location}/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]\"/>

When I resolve artifacts from my repository (e.g. filesystem), I use two artifact patterns:

<artifact pattern="${location}/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"/>
<artifact pattern="${location}/[organisation]/[module]/[revision]/[artifact]-[revision]-[type]s.[ext]"/>

The first one is for jar files, and the second one is开发者_开发技巧 for sources or other types of artifacts. I'd like to be able to publish artifacts the same way, but I don't know how.

Using just the patterns above, the publish task seems to consider only the first one, thus removing the type. If multiple artifacts have the same name and extension, they will be overwritten.

If I just use the second pattern, then for jar artifacts it makes ${artifact}-${revision}-jars.jar which is really ugly.

Finally, it seems to be possible to have optional parts in patterns, such as:

<artifact pattern="${location}/[organisation]/[module]/[revision]/[artifact]-[revision](-[type]s).[ext]"/>

But the -[type]s part is omitted only if the type is null or empty, and I'd like the type to remain "jar", in which case the part is not omitted.

So is there any other way?


Why don't you use ivy.xml files for artifacts? You should need to create ivy.xml and place them to your module folder, near jar files. ivy.xml example:

<ivy-module version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
    <info organisation="com.organisation" module="foo" revision="1.0"/>
    <publications>
        <artifact name="foo"/>
        <artifact name="foo-sources" type="source" ext="zip"/>
    </publications>
</ivy-module>

Then you should define ivy pattern in your resolver:

<ivy pattern="${location}/[organisation]/[module]/[revision]/ivy.xml"/>

Now if you use <dependency org="com.organisation" name="foo" rev="1.0"/> you will get all artifacts described in ivy.xml. There is a way to select only the needed artifacts.


Not really a solution, but a slightly better way is:

<artifact pattern="${location}/[organisation]/[module]/[revision]/[type]s/[artifact]-[revision].[ext]"/>


I struggled with the same. I found the solution, you can use:

   [artifact](-[classifier]).[ext]

-classifier will be null/empty on the jar on sources/javadoc-jars it contains -sources/-javadoc.jar

I know its been a while, but I found this question by google. So for any future person it will be helpful I think.

0

精彩评论

暂无评论...
验证码 换一张
取 消