Reputation: 187399
I have a Maven project with <packaging>jar</packaging>
and <version>0.0.11-SNAPSHOT</version>
. When I run mvn clean install
, it deploys the following to my local repository
~/.m2/repository/com/example/myproject/0.0.11-SNAPSHOT/Commons-0.0.11-SNAPSHOT.jar
I expected that the name of the generated artifact would have -SNAPSHOT
replaced by a timestamp of when the JAR was built, something like:
~/.m2/repository/com/example/myproject/0.0.11-SNAPSHOT/Commons-0.0.11-20110217011633.jar
Why is this replacement not happening?
Upvotes: 3
Views: 2889
Reputation: 55886
I reread the question, seem like you're talking about your local machine. I doubt that you could store Unique version in local repository
refer this: Repository - SNAPSHOT Handling, it says
When installing an artifact in the local repository during a build, the version.txt file is not updated. This is because the local last modification time of that file is used to determine when the next check should occur.
Instead, the file is stored using the format such as 0.15-SNAPSHOT. On future attempts, the filesystem timestamp on this file is compared to the filesystem timestamp on the version.txt to determine which is newer (where version.txt only has its timestamp updated when its contents have been updated).
Also,
This means that every time a new remote snapshot is published, it will overwrite a local snapshot regardless of age. This is the only way to provide consistent behaviour and avoid clock skew - for example, while it might make sense to honour a local snapshot if it were newer than the remote snapshot, it may be that the local one was built from older sources and so is, in fact, older.
The description below is for private repository.
In a private repositiry:
You need to configure your local repository to store unique SNAPSHOT versions. AFAIK, there is a setting in Artifactory and Nexus to do this.
See here: http://wiki.jfrog.org/confluence/display/RTF/Local+Repositories
You can choose between:
- Non-unique snapshots.
- Unique snapshots - with unique time-stamp and build number suffix.
- Deployer-respecting behavior - Artifactory will respect the user snapshot policy, i.e. act as a standard, non-smart, repository.
I havn't used Nexus, but seems like by default it stores unique snapshot and you can define how many days you want to keep the SNAPSHOT. I didn't get an article but you may look into http://www.sonatype.com/books/nexus-book/reference/config-sect-scheduled-services.html
Also, you may explicitely indicate uniqueVersion as true in distribution management blocl. But, I guess that true by default. may be give it a chance,
<distributionManagement>
...
<repository>
...
<uniqueVersion>true</uniqueVersion>
</repository>
...
</distributionManagement>
Upvotes: 5
Reputation: 17898
I think what you wrote (replacing SNAPSHOT
token) is true when you deploy
the artifact to snapshot repository. But install
works (at least for me) as you udescribed - so it doesn't replace the SNAPSHOT
with timestamp.
Upvotes: 4