开发者

Retrieving dependencies with empty type

开发者 https://www.devze.com 2023-03-12 18:37 出处:网络
I\'m trying to figure out how to omit the [type] part in an Ivy retrieve pattern for artifacts that don\'t have type declared. I use the following ant statement:

I'm trying to figure out how to omit the [type] part in an Ivy retrieve pattern for artifacts that don't have type declared. I use the following ant statement:

<ivy:retrieve pattern="${lib.dir}/[artifact](-[type]).[ext]" conf="compile" />

Despite the parentheses, Ivy produces files like

  • junit-jar.jar
  • junit-javadoc.jar
  • junit-source.jar

The latter two ones are as expected but the first one should开发者_StackOverflow社区 be "junit.jar" instead.

The result is the same as when I omit the parentheses.

Edit:

What I'm doing up to now to work around the problem: I have multiple retrieve statements in the build.xml:

<ivy:retrieve pattern="${lib.dir}/[artifact]-[type].[ext]" type="source" /> <ivy:retrieve pattern="${lib.dir}/[artifact].[ext]" type="jar" />

(The "conf" attribute in the original post is not related to this topic.)

But that looks rather silly when there's the feature of optional tokens.


The type defaults to jar, it can't be ommited. See Documentation So this (-[type]) does not have an affect.

Perhaps you could do something like this in the build.xml (if you control the ivy.xml).

<ivy:retrieve pattern="${lib.dir}/[artifact].[ext]" conf="compile" />
<ivy:retrieve pattern="${lib.dir}/[artifact](-[type]).[ext]" conf="extras" />

You'd have to publish the jar in the compile config and the other jars in the extra config.

Or just name the other ones junit-javadoc and junit-source in the ivy.xml:

<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0">
    <info organisation="junit"
        module="jnuit"
        revision="4.8.2"
        status="release"
        publication="20110531150115"
        default="true"
    />
    <configurations>
        <conf name="default" visibility="public"/>
    </configurations>
    <publications>
      <artifact name="junit"      type="jar" />
      <artifact name="junit-sources"      type="jar" />
      <artifact name="junit-javadoc"      type="jar" />
    </publications>
</ivy-module>
0

精彩评论

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

关注公众号