1

Is it any way to run Maven as if you were in another date?

My problem is I have a pom that worked with a large amount of "RELEASE" versions a month ago, but now some changes in the packages makes my project unable to run (support for some features has been discontinued). Unfortunately this dependencies are quite a lot and I don't know the version they were at that time, is there any way to run maven and tell to download the packages that were "RELEASE" version as of a specified date?

I'm editing because I feel I explained my problem poorly.

Assume I have the following dependency in my pom.xml

    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>RELEASE</version>
    </dependency>

If I run "mvn something" today it will fetch commons-io 2.4 but if I were to run two years ago it would have fetched commons-io 2.2

I'd like to run maven and tell him to fetch the package being the RELEASE version at some time in the past.

Qualsiasi
  • 51
  • 2
  • 6
  • AFAIK, Maven can't help with this. SCM can help – Keerthivasan Jan 10 '14 at 10:23
  • So somebody thrashed the "release" versions of your dependent artifacts? – Gyro Gearless Jan 10 '14 at 10:25
  • I hope you have a versioning system in which you have tags/snapshots of all those versions you are talking about. Maven is not a magic hammer which solves all your problems, only your brain is such a tool. – Gimby Jan 10 '14 at 10:26
  • I think I explained poorly my problem, I improved question. Of course I'm using versioning but I don't see how this could help me in this case. – Qualsiasi Jan 10 '14 at 10:52
  • Not an answer to the question, but rather than using `RELEASE` as the version number in your pom, you should look at something like the [versions plugin](http://stackoverflow.com/a/1172805/592139) so you can have fixed version numbers in the pom but easily update those to new releases as necessary. That way you get the benefit of keeping up with the latest versions of your libraries without losing the ability to reproduce old builds. – Ian Roberts Jan 10 '14 at 11:31
  • 1
    This is _exactly_ the reason why you never ever should omit version number of artifact! This is not problem of Maven, but improper use. – Jakub Jirutka Jan 10 '14 at 13:30

3 Answers3

1

No, it's not possible to resolve versions "as if" at a particular time in the past, and for this reason it is almost always preferable to use explicit versions rather than LATEST or RELEASE.

If you have a specific date in mind, you can check Central (e.g., for commons-io) and see the latest version deployed before that date. You would then need to edit your pom to use that version.

Central has an API (e.g, those same commons-io results as JSON) which would allow you to automate this.

Joe
  • 29,416
  • 12
  • 68
  • 88
0

This might not be possible with maven,to revert the pom file as per a specific date,i think to overcome this type of problems and to have more advantages we use SVN , GIT .

Maven is just a build tool,its not like or provide any of the function for version control or can keep track for the changes in dependencies.

Charles Stevens
  • 1,568
  • 15
  • 30
  • yes it can but i dont think,it can revert back the versions of your dependencies as previously used,if it can please let me know,it might be helpful for me too. – Charles Stevens Jan 10 '14 at 10:33
0

I don't know maven well and I'm not sure this will work, but it might give you some ideas:

1: Back up your pom.xml file (so you can recover if the following doesn't work)
2: Remove all dependancy tags in the pom.xml file.
3: Insert just the major dependancy tags for major jar files (example: hibernate or spring) (and no others) and specify their (old) versions in the tag.
4: Compile.
5: I believe maven will download the appropriate versions of any supporting jar files (such as commons-io) that those versions of hibernate and spring needs.
6: Repeat step 3 through 5 for any other major jar files after going to their web pages and seeing what version was in existance in the past that you need.

user2810910
  • 279
  • 1
  • 2