aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes how's Maven keep the old version of jar files ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "how Watch "how New topic
Author

how's Maven keep the old version of jar files ?

Nakataa Kokuyo
Ranch Hand

Joined: Jul 24, 2011
Posts: 189
Good day,

Just started to learn maven and I have a general question.

- if i have following spring-core jar file version in 3.0.5.RELEASE, in future if 3.0.5.RELEASE is too old after sometimes, how could maven still able to reference the old jar file? does it required us to keep updating the version?

Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2448
    
  28

Yes, if you want to upgrade to new version of spring, you have to change the version number in the Pom.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31074
    
232

If you have a version # hardcoded (like in this example) and don't have any other info in the pom conflicting with it, Maven will use 3.0.5 forever. It is stored in Maven Central and Maven can pull it down years from now. It is also stored in your local .m2 cache so Maven doesn't have to keep downloading it from the internet. You can see the list of Spring core versions Maven has available. If you page through, you can see there are 62 versions going all the way back to 1.0.

If you want Maven to pull a later version, you need to update your file. Or you can specify a more generic version like LATEST and have Maven take care of that automatically.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Nakataa Kokuyo
Ranch Hand

Joined: Jul 24, 2011
Posts: 189
Thanks Jeanne for pointing out!

if user put in wrong version, would maven take the closer jar file from m2 cache folder? the existing jar file will be remove from LIB folder if it no longer mentioned in pom.xml ?
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31074
    
232

Nakataa Kokuyo wrote:if user put in wrong version, would maven take the closer jar file from m2 cache folder?

Not sure what you mean by "closer jar."

Nakataa Kokuyo wrote: the existing jar file will be remove from LIB folder if it no longer mentioned in pom.xml ?

The jar would still be in the .m2 cache, but not in your application when you take it out of the pom.xml.
Nakataa Kokuyo
Ranch Hand

Joined: Jul 24, 2011
Posts: 189
Nakataa Kokuyo wrote:if user put in wrong version, would maven take the closer jar file from m2 cache folder?

Jeanne Boyarsky wrote:Not sure what you mean by "closer jar."


Sorry,might be stupid question

I means if the version suppose 3.0.5.RELEASE and user enter the version wrongly to 3.0.x.RELEASE and assume the version doesn't exist, would it scan and download the closer version or probably get the latest based on <artifactid> ?
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31074
    
232

Ah. If you specify a version that doesn't exist, Maven will complain at build time. It will not infer something else or get the latest.

You can specify a range of version of "LATEST" which behave that way - and do infer the latest. But an actual incorrect version will not build. Which is nice - Maven is notifying you about a typo.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how's Maven keep the old version of jar files ?