I answer this question often enough that I decided to burn it to a blog so I don't have to dig it out of the source anymore... and maybe save someone else the time along the way.
Here is the relevant code that Maven uses to determine if an artifact is a snapshot or not:
<span style="font-family: arial;">String LATEST_VERSION = "LATEST"; String SNAPSHOT_VERSION = "SNAPSHOT"; Pattern VERSION_FILE_PATTERN = Pattern.compile( "^(.*)-([0-9]{8}.[0-9]{6})-([0-9]+)$" ); public boolean isSnapshot() { if ( version != null || baseVersion != null ) { Matcher m = VERSION_FILE_PATTERN.matcher( getBaseVersion() ); if ( m.matches() ) { setBaseVersion( m.group( 1 ) + "-" + SNAPSHOT_VERSION ); return true; } else { return getBaseVersion().endsWith( SNAPSHOT_VERSION ) || getBaseVersion().equals( LATEST_VERSION ); } } else { return false; } } </span>
Essentially this regex ( regular expression ) is checking if the version ends with Snapshot or if the pattern matches a timestamped version such as "2.0.10-20080415.233129-15."
.jpg?width=150&height=150&name=fox-2016-1-sq%20(1).jpg)
Brian Fox, CTO and co-founder of Sonatype, is a Governing Board Member for the Open Source Security Foundation (OpenSSF), a Governing Board Member for the Fintech Open Source Foundation (FINOS), a member of the Monetary Authority of Singapore Cyber and Technology Resilience Experts (CTREX) Panel, a ...
Explore All Posts by Brian FoxTry Nexus Repository Free Today
Sonatype Nexus Repository is the world’s most trusted artifact repository manager. Experience the difference and download Community Edition for free.