You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Robert Scholte <ap...@sourcegrounds.com> on 2012/02/28 00:41:19 UTC
Artifact.isSnapshot definition
A couple of issues of the release-plugin have to do with SNAPSHOTs,
because it uses its own definition, borrowed from (an old)
DefaultArtifact.
However, it seems like there are 2 definitions:
In DefaultArtifact:
public boolean isSnapshot()
{
return getBaseVersion() != null
&& ( getBaseVersion().endsWith( SNAPSHOT_VERSION ) ||
getBaseVersion().equals( LATEST_VERSION ) );
}
In ArtifactUtils:
public static boolean isSnapshot( String version )
{
if ( version != null )
{
if ( version.regionMatches( true, version.length() -
Artifact.SNAPSHOT_VERSION.length(),
Artifact.SNAPSHOT_VERSION, 0,
Artifact.SNAPSHOT_VERSION.length() ) )
{
return true;
}
else if ( Artifact.VERSION_FILE_PATTERN.matcher( version
).matches() )
{
return true;
}
}
return false;
}
It looks to me there should only be one. Do I really have to check both
definitions or can we merge them somehow?
-Robert
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
Re: Artifact.isSnapshot definition
Posted by Brian Fox <br...@infinity.nu>.
The second one looks right to me, this is what I've always used as reference[1]
[1] http://www.sonatype.com/people/2008/05/maven-code-how-to-detect-if-you-have-a-snapshot-version/
On Mon, Feb 27, 2012 at 6:41 PM, Robert Scholte
<ap...@sourcegrounds.com> wrote:
> A couple of issues of the release-plugin have to do with SNAPSHOTs, because
> it uses its own definition, borrowed from (an old) DefaultArtifact.
>
> However, it seems like there are 2 definitions:
> In DefaultArtifact:
> public boolean isSnapshot()
> {
> return getBaseVersion() != null
> && ( getBaseVersion().endsWith( SNAPSHOT_VERSION ) ||
> getBaseVersion().equals( LATEST_VERSION ) );
> }
>
> In ArtifactUtils:
> public static boolean isSnapshot( String version )
> {
> if ( version != null )
> {
> if ( version.regionMatches( true, version.length() -
> Artifact.SNAPSHOT_VERSION.length(),
> Artifact.SNAPSHOT_VERSION, 0,
> Artifact.SNAPSHOT_VERSION.length() ) )
> {
> return true;
> }
> else if ( Artifact.VERSION_FILE_PATTERN.matcher( version
> ).matches() )
> {
> return true;
> }
> }
> return false;
> }
>
>
> It looks to me there should only be one. Do I really have to check both
> definitions or can we merge them somehow?
>
> -Robert
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org