61

i would like to release a snapshot project 'foo-1.0-SNAPSHOT' using the maven release plugin. The project depends on a 3rd party module 'bar-1.0-SNAPSHOT' which is not released yet. I use the option 'allowTimestampedSnapshots' in my project's pom.xml to allow timestamped snapshots but i assume that the 3rd party module (bar) is not timestamped unless i build it myself as maven still complains about unresolved SNAPSHOT dependencies.

Is there a way to release the project foo regardless of dependent SNAPSHOT projects and if not how could i add a timestamp to the 3rd party project?

OhadR
  • 8,276
  • 3
  • 47
  • 53
Christian
  • 683
  • 1
  • 5
  • 6

5 Answers5

165

Problem is with the allowTimestampedSnapshots parameter name, it's in the documentation but the plugin's source uses a different parameter name in expression - ignoreSnapshots.

So just use -DignoreSnapshots=true and the prepare goal of the release plugin will ignore snapshot dependencies.

chappjc
  • 30,359
  • 6
  • 75
  • 132
Stevo Slavić
  • 2,298
  • 2
  • 24
  • 32
  • 9
    This works and I believe its the correct answer (the one the OP is looking for). Shame this doesn't have enough up-votes to be no. 1! Of course, you don't really want to publish artifacts that have snapshot dependencies, cos you your consumers will also need to find that snapshot. If you're just using the snapshot in your test suite (or similar) then "-DignoreSnapshots=true" is definitely a good workaround. – joelittlejohn Feb 22 '11 at 22:37
  • 1
    I almost gave up until I stumbled upon this! Thanks! – Kenny Cason Jul 28 '15 at 07:18
26

Using the maven-release-plugin option

-DignoreSnapshots=true

instead of

-DallowTimestampedSnapshots=true

helped in my case, this will allow to use dependencies with snapshot version to prepare and perform a release.

This option should be handled very carefully, because using snapshot versions in a release can later break your release, if the snapshot dependency is updated, which in normal case is not what you want.

nwinkler
  • 52,665
  • 21
  • 154
  • 168
Oleg Mayevskiy
  • 261
  • 3
  • 2
10

The short answer is see the following answer.... the long answer is you can work around it.

The only way I have coped in the past is to effectively fork the 3rd party library and cut a release myself. This of course is easier said than done and is just plain difficult if the library is large and complex and impossible if the 3rd party library is closed source. An easier route maybe to approach the 3rd party and ask them to cut a release.

Another option may be to copy their pom (ensure that it has no snapshots) change the version information and manually install the pom and artifact in your repository.

Community
  • 1
  • 1
Gareth Davis
  • 27,701
  • 12
  • 73
  • 106
  • 8
    Not exactly right, see the other answers, you can tell maven via `-DignoreSnapshots=true` to release even with snapshot dependencies. That you should avoid doing that and only do if there is absolutely no other choice, is another story. – Alexander Klimetschek Nov 22 '13 at 01:14
  • 1
    Sonatype advice is to deploy to a local repository http://blog.sonatype.com/2009/01/best-practices-for-releasing-with-3rd-party-snapshot-dependencies/#.UstQinlq5t0 – Joseph Earl Jan 07 '14 at 00:59
6

The previous answer suggested changing the group and artifact id...don't do this as maven won't recognize it as the same artifact later when this dependency is released and you'll end up with two copies on the classpath. My preferred method is to change only the version and I'll do something like : [original version]-[my org name]-[svn version i pulled it from] so i get something like 1.0-SONATYPE-3425. By using the svn rev, i can always pull the source again and patch it if needed and know exactly what i'm using without pulling the whole source into my own svn.

Update - I blogged about this a while back.

Brian Fox
  • 6,782
  • 4
  • 27
  • 31
-2

Just install the jar with a pom you own. I generally change the group and artifact id to make it clear that this is not the official version, but that's generally the best work around for your problem.

Mike Deck
  • 18,045
  • 16
  • 68
  • 92