开发者

How can I create a maven artifact that is compatible with exactly two versions of another artifact?

I need to create a maven artifact (org.foo.bar:blarb:1.0.0) that is dependent on exactly two versions of another artifact (org.blab.har:har:1.7.0 and org.blab.har:har:1.8.0, 1.7.1 and 1.8.1 are not allowed).

Others will be consuming my artifact downstr开发者_高级运维eam. Unless they explicitly specify, I want the default har artifact used to be 1.7.0. But, there can be something added to the pom to specify 1.8.0. (If it is not possible to specify a lower version as the default, I can live with 1.8.0 being the default, but would prefer not to.)

Can you show me a snippet that I would place in the blarb pom so that this can happen?


One possibility is to use version ranges.

You could try specifying the following in the dependency for org.blab.har:har

<version>[1.7.0],[1.8.0]</version>

This will indicate to maven to pick either 1.7.0 or 1.8.0. I guess the default would 1.8.0 (the higher version)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜