You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Simone Gianni <si...@apache.org> on 2009/01/18 17:33:57 UTC

Artifact.getVersion()

Hi all,
I already posted this on the users list some weeks ago, but got no 
answer, so I'm asking here.

I'm writing a Maven plugin in which I'm using Artifact.getVersion on 
dependencies. When applied to a dependency which is a snapshot, 
sometimes the returned version is 0.0.1-SNAPSHOT (which is the version 
declared both in the dependency in the pom and in the version of the 
artifact pom), other times it returns the complete snapshot version, 
like 0.0.1-20090107-etcetc .  Since this behavior is not consistent, I 
think it is related to some kind of "timeout". When the snapshot is 
timed out (and maven checks the repository for new versions) then 
getVersion returns the timestamped version, otherwise it returns the 
0.0.1-SNAPSHOT version.

Since I'm generating some files based on the artifact group, name AND 
version, this random behavior causes malfunctions.

Is there a way to always retrieve either the generic "0.0.1-SNAPSHOT" or 
the "0.0.1-etcetc" version? I can see a number of getXVersion methods on 
Artifact, but have no idea which one will remain stable, are them 
documented somewhere?

Thanks in advance,
Simone

-- 
Simone Gianni            CEO Semeru s.r.l.           Apache Committer
http://www.simonegianni.it/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


RE: Artifact.getVersion()

Posted by "Brian E. Fox" <br...@reply.infinity.nu>.
That was fixed back in 2.0.8:
http://jira.codehaus.org/browse/MNG-2961


-----Original Message-----
From: Simone Gianni [mailto:simoneg@apache.org] 
Sent: Tuesday, January 27, 2009 8:35 AM
To: Maven Developers List
Subject: Re: Artifact.getVersion()

I found the solution casually looking at the source code of the surefile

plugin :

[quote]
        surefireArtifact.isSnapshot(); // TODO: this is ridiculous, but 
it fixes getBaseVersion to be -SNAPSHOT if needed
[/quote]

And yes, it seems to work! :)

Simone

Brian E. Fox wrote:
> It's SNAPSHOT when resolved from the local repo and timestamped when
it
> comes from the remote. There's a method to get SNAPSHOT, I think it's
> something like getBaseVersion(). I had to deal with this also in the
> dependency and enforcer plugins.
>
> -----Original Message-----
> From: Simone Gianni [mailto:simoneg@apache.org] 
> Sent: Sunday, January 18, 2009 11:34 AM
> To: Maven Developers List
> Subject: Artifact.getVersion()
>
> Hi all,
> I already posted this on the users list some weeks ago, but got no 
> answer, so I'm asking here.
>
> I'm writing a Maven plugin in which I'm using Artifact.getVersion on 
> dependencies. When applied to a dependency which is a snapshot, 
> sometimes the returned version is 0.0.1-SNAPSHOT (which is the version

> declared both in the dependency in the pom and in the version of the 
> artifact pom), other times it returns the complete snapshot version, 
> like 0.0.1-20090107-etcetc .  Since this behavior is not consistent, I

> think it is related to some kind of "timeout". When the snapshot is 
> timed out (and maven checks the repository for new versions) then 
> getVersion returns the timestamped version, otherwise it returns the 
> 0.0.1-SNAPSHOT version.
>
> Since I'm generating some files based on the artifact group, name AND 
> version, this random behavior causes malfunctions.
>
> Is there a way to always retrieve either the generic "0.0.1-SNAPSHOT"
or
>
> the "0.0.1-etcetc" version? I can see a number of getXVersion methods
on
>
> Artifact, but have no idea which one will remain stable, are them 
> documented somewhere?
>
> Thanks in advance,
> Simone
>
>   


-- 
Simone Gianni            CEO Semeru s.r.l.           Apache Committer
http://www.simonegianni.it/


---------------------------------------------------------------------
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


Re: Artifact.getVersion()

Posted by Simone Gianni <si...@apache.org>.
I found the solution casually looking at the source code of the surefile 
plugin :

[quote]
        surefireArtifact.isSnapshot(); // TODO: this is ridiculous, but 
it fixes getBaseVersion to be -SNAPSHOT if needed
[/quote]

And yes, it seems to work! :)

Simone

Brian E. Fox wrote:
> It's SNAPSHOT when resolved from the local repo and timestamped when it
> comes from the remote. There's a method to get SNAPSHOT, I think it's
> something like getBaseVersion(). I had to deal with this also in the
> dependency and enforcer plugins.
>
> -----Original Message-----
> From: Simone Gianni [mailto:simoneg@apache.org] 
> Sent: Sunday, January 18, 2009 11:34 AM
> To: Maven Developers List
> Subject: Artifact.getVersion()
>
> Hi all,
> I already posted this on the users list some weeks ago, but got no 
> answer, so I'm asking here.
>
> I'm writing a Maven plugin in which I'm using Artifact.getVersion on 
> dependencies. When applied to a dependency which is a snapshot, 
> sometimes the returned version is 0.0.1-SNAPSHOT (which is the version 
> declared both in the dependency in the pom and in the version of the 
> artifact pom), other times it returns the complete snapshot version, 
> like 0.0.1-20090107-etcetc .  Since this behavior is not consistent, I 
> think it is related to some kind of "timeout". When the snapshot is 
> timed out (and maven checks the repository for new versions) then 
> getVersion returns the timestamped version, otherwise it returns the 
> 0.0.1-SNAPSHOT version.
>
> Since I'm generating some files based on the artifact group, name AND 
> version, this random behavior causes malfunctions.
>
> Is there a way to always retrieve either the generic "0.0.1-SNAPSHOT" or
>
> the "0.0.1-etcetc" version? I can see a number of getXVersion methods on
>
> Artifact, but have no idea which one will remain stable, are them 
> documented somewhere?
>
> Thanks in advance,
> Simone
>
>   


-- 
Simone Gianni            CEO Semeru s.r.l.           Apache Committer
http://www.simonegianni.it/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


RE: Artifact.getVersion()

Posted by "Brian E. Fox" <br...@reply.infinity.nu>.
It's SNAPSHOT when resolved from the local repo and timestamped when it
comes from the remote. There's a method to get SNAPSHOT, I think it's
something like getBaseVersion(). I had to deal with this also in the
dependency and enforcer plugins.

-----Original Message-----
From: Simone Gianni [mailto:simoneg@apache.org] 
Sent: Sunday, January 18, 2009 11:34 AM
To: Maven Developers List
Subject: Artifact.getVersion()

Hi all,
I already posted this on the users list some weeks ago, but got no 
answer, so I'm asking here.

I'm writing a Maven plugin in which I'm using Artifact.getVersion on 
dependencies. When applied to a dependency which is a snapshot, 
sometimes the returned version is 0.0.1-SNAPSHOT (which is the version 
declared both in the dependency in the pom and in the version of the 
artifact pom), other times it returns the complete snapshot version, 
like 0.0.1-20090107-etcetc .  Since this behavior is not consistent, I 
think it is related to some kind of "timeout". When the snapshot is 
timed out (and maven checks the repository for new versions) then 
getVersion returns the timestamped version, otherwise it returns the 
0.0.1-SNAPSHOT version.

Since I'm generating some files based on the artifact group, name AND 
version, this random behavior causes malfunctions.

Is there a way to always retrieve either the generic "0.0.1-SNAPSHOT" or

the "0.0.1-etcetc" version? I can see a number of getXVersion methods on

Artifact, but have no idea which one will remain stable, are them 
documented somewhere?

Thanks in advance,
Simone

-- 
Simone Gianni            CEO Semeru s.r.l.           Apache Committer
http://www.simonegianni.it/


---------------------------------------------------------------------
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