1

Is there a way to tell maven to pick the latest version of a jar as long as major version remains the same? For example, instead of the following:

    <dependency>
        <groupId>com.example</groupId>
        <artifactId>example-java-sdk</artifactId>
        <version>1.0.1</version>
    </dependency>

I'd like to use the following:

    <dependency>
        <groupId>com.example</groupId>
        <artifactId>example-java-sdk</artifactId>
        <version>1.*</version>
    </dependency>

Or:

    <dependency>
        <groupId>com.example</groupId>
        <artifactId>example-java-sdk</artifactId>
        <version>1</version>
    </dependency>

That way, I can update the minor version or revision without having to ask everyone to change their dependencies. The latest jar (with the same major version) will be picked up the next time they rebuild their application.

Satyen Rai
  • 1,073
  • 1
  • 10
  • 17
  • It depends what you like achieve with this? Is your pom consumed by others? So it might be possible to use a `provided` And others can decide what to use? – khmarbaise Sep 08 '15 at 07:15
  • 1
    You can specify excluded interval bounds, i.e. `[1.0, 2.0)`, meaning *from and including 1.0 and up to but excluding 2.0*. Is this sufficient? – dhke Sep 08 '15 at 07:19
  • 1
    I think this entry pretty much sums it up: http://stackoverflow.com/questions/30571/how-do-i-tell-maven-to-use-the-latest-version-of-a-dependency – Daniel Sep 08 '15 at 07:22
  • @khmarbaise: Yes, I am writing an SDK for my application - and I don't want my users to manually choose a particular version every time I fix a bug or refactor my code while keeping the interface the same. – Satyen Rai Sep 08 '15 at 07:26
  • Then you should use the provided scope which makes it easier. In your own environment you can select a particular version and your users can choose what they like to use. The version range is not a good choice in this case. – khmarbaise Sep 08 '15 at 07:29
  • @Daniel: Thanks. Not sure why it didn't turn up in search for me. – Satyen Rai Sep 08 '15 at 07:29
  • @khmarbaise: Would it be possible to provide an example? I am afraid, I am very new to Maven - and Java in general. Even a link to a simple tutorial would be very helpful. > The version range is not a good choice in this case. Can you please elaborate a bit? – Satyen Rai Sep 08 '15 at 07:35

0 Answers0