Publish snapshots with revision instead of timestamp


(Alpár Török) #1

I was wondering, is it possible to push a snapshot replacing the -SNAPSHOT in the version with with something else ? Like SCM revision id ?

It would make more sense for the project I am working on.

If not possible already, would it be feasible to implement ? Can someone point me in the right direction as to how this could be implemented ?


(Peter Niederwieser) #2

It’s possible, but then it’s no longer a Maven snapshot. In other words, publisher will have to take care of setting the exact version when publishing, and clients will have to use a fixed version or version range when referring to the dependency.


(Alpár Török) #3

I would like to keep it a snapshot, just “fool” the maven repository around the value that is used for the -SNAPSHOT part.

In Gradle terminology I would like to keep it as a changing dependency and clients would reference it with -SNAPSHOT , but in the repository, and the downloaded artifacts need to have a SCM revision Id instead of timstamp.

I saw that Gradle is actually the one to that sets it when publishing, so I don’t see why it wouldn’t be doable. The question is how hard is it ? And where do I need to look in the sour code ?


(Peter Niederwieser) #4

According to my understanding, it isn’t doable. Maven dependencies whose version ends in ‘-SNAPSHOT’ are treated specially, and it isn’t possible to customize the timestamp conversion and snapshot resolution. These aren’t regular changing dependencies.


(Alpár Török) #5

When you say it isn’t doable, do you mean to say that the logic is deeply embedded in the maven publisher that Gradle uses and there is no way to alter it’s behavior from within Gradle ? From my understanding the logic that replaces -SNAPSHOT with the time stamp is on the client side, and I can’t think of a reason why it would matter what is being put there, other than some maven library enforcing conventions.


(Peter Niederwieser) #6

Yes, that’s what I mean. I think part of it is actually embedded in the Maven lib used by Gradle.