18

Is there any way to make maven look for new versions of dependencies?

for example, i have commons-lang commons-lang 2.3

version 2.4 could be out, I dont know. i'd rather not check is manually(by writting 2.4 in this case), because i have many dependencies. I think i saw some trick to make maven use latest version.

tshepang
  • 12,111
  • 21
  • 91
  • 136
IAdapter
  • 62,595
  • 73
  • 179
  • 242
  • 1
    see also: http://stackoverflow.com/questions/30571/how-do-i-tell-maven-to-use-the-latest-version-of-a-dependency – gnat Nov 18 '11 at 09:48

4 Answers4

29

mvn versions:display-dependency-updates

Will show dependency updates

Read more here: display-dependency-updates

Efthymis
  • 1,326
  • 11
  • 13
Wouter Lievens
  • 4,019
  • 5
  • 41
  • 66
8

I think i saw some trick to make maven use latest version.

Yes, there are special version numbers to handle this:

When you depend on a plugin or a dependency, you can use the a version value of LATEST or RELEASE. LATEST refers to the latest released or snapshot version of a particular artifact, the most recently deployed artifact in a particular repository. RELEASE refers to the last non-snapshot release in the repository.

(Excerpt from Maven, the definitive guide)

PS: although the book also mentions this as a "not-so-best" practice...

Olivier
  • 1,232
  • 6
  • 10
  • 5
    It's better to use the "versions" plugin and upgrade your dependencies in a controlled manner, rather than _always_ having the latest version. – Dominic Mitchell Jul 15 '10 at 19:34
  • The link to http://books.sonatype.com/maven-book/reference/pom-relationships-sect-pom-syntax.html#pom-relationships-sect-latest-release is dead. – James Moore Sep 20 '11 at 17:01
  • Using LATEST is fine for developer builds. However, to ensure repeatable builds after checking-in, use the versions plugin, and get the CI job to check those pom files into a branch. That way, you'll always have locked-down dependencies in your pom.xml files (providing they're not SNAPSHOTs of course!), should you ever need to patch/fix that precise build in production. – KRK Owner May 21 '14 at 23:15
7
mvn versions:display-dependency-updates

Don't change versions automatically. Dependency updates show also beta/alfa releases eg. for hibernate

Additionally use the following command for plugin updates:

mvn versions:display-plugin-updates
Michal Zmuda
  • 5,381
  • 3
  • 43
  • 39
0

Yah you can't make it look for newer versions of dependencies. What you can do is look at the repo, try a search at http://www.mvnrepository.com/

Really you shouldn't want Maven doing this. It could cause a lot of nasty issues. Sometimes backwards compatibility can break even in point releases.

Rob Ottaway
  • 614
  • 5
  • 9