abc
abc

Reputation: 2381

Maven declare version range, avoid unnecessary libraries

I'm trying avoid following situation:

I have library A which depends on library B in version 1.1. Next I create new project where I depend on A and C which depends on library B in version 2.0. From what I understand I will have two libraries B in different versions. But what if actually A can also depends on B in version 2.0, so actually only one lib is needed? It would be nice if I could define that A works with certain interval, in this case: <1.1 - 2.0>.

Is there any way to do so?

Upvotes: 1

Views: 400

Answers (1)

Jigar Joshi
Jigar Joshi

Reputation: 240890

You can specify range in version something like

<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>[3.0, 3.8.2)</version>
</dependency>

but prior to build you would have to invoke

mvn versions:resolve-ranges

to resolve to actual version number


Upvotes: 1

Related Questions