You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by pjungwir <ma...@9stmaryrd.com> on 2006/10/14 18:26:51 UTC

getting a plugin's own version?

Hello,

Is there an easy way for a plugin to get its own version? I can't just do a
property set to ${project.version}, because that will get the version of the
user's project. So far, the easiest thing I've come up with is to write
${project.version} to a filtered resource file, but that seems very
circuitous. Can I just get it in java?

Thanks,
Paul




-- 
View this message in context: http://www.nabble.com/getting-a-plugin%27s-own-version--tf2443270.html#a6812276
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: getting a plugin's own version?

Posted by pjungwir <ma...@9stmaryrd.com>.
Oh, that is much better! Thank you.
-- 
View this message in context: http://www.nabble.com/getting-a-plugin%27s-own-version--tf2443270.html#a6813179
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: getting a plugin's own version?

Posted by Dan Tran <da...@gmail.com>.
since your plugin is defined in project-->build-->plugins, I would suggest
to use that
browse it thru a api as well.




On 10/14/06, pjungwir <ma...@9stmaryrd.com> wrote:
>
>
>
> pjungwir wrote:
> >
> > I see that ArtifactVersion (from getSelectedVersion()) has the
> major/minor
> > numbers. Do I have to patch these together myself?
> >
>
> Actually, these are all set to zero....
>
> --
> View this message in context:
> http://www.nabble.com/getting-a-plugin%27s-own-version--tf2443270.html#a6812804
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: getting a plugin's own version?

Posted by pjungwir <ma...@9stmaryrd.com>.

pjungwir wrote:
> 
> I see that ArtifactVersion (from getSelectedVersion()) has the major/minor
> numbers. Do I have to patch these together myself?
> 

Actually, these are all set to zero....

-- 
View this message in context: http://www.nabble.com/getting-a-plugin%27s-own-version--tf2443270.html#a6812804
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: getting a plugin's own version?

Posted by pjungwir <ma...@9stmaryrd.com>.
Hi Dan, you're coding on a Saturday, too?


dan tran wrote:
> 
> use project to browse the user pom which for sure has your plugin.
> 

I was hoping nobody would suggest this! :-) But I'm giving it a try. I get
all the artifacts via project.getPluginArtifacts().
But when I find my own, I can only get "RELEASE" as the version. I need the
real number. I've tried getVersion(), getBaseVersion(), and
getSelectedVersion().getQualifier(). I see that ArtifactVersion (from
getSelectedVersion()) has the major/minor numbers. Do I have to patch these
together myself? Or is there an easier way?

Thanks,
Paul

-- 
View this message in context: http://www.nabble.com/getting-a-plugin%27s-own-version--tf2443270.html#a6812758
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: getting a plugin's own version?

Posted by Dan Tran <da...@gmail.com>.
Define this in your mojo


/**

* The POM

*

* *@parameter* expression="${project}

* *@required
*

* *@readonly
*

*/

*private *MavenProject project;

then use project to browse the user pom which for sure has your plugin.


-D



On 10/14/06, pjungwir <ma...@9stmaryrd.com> wrote:
>
>
> Hello,
>
> Is there an easy way for a plugin to get its own version? I can't just do
> a
> property set to ${project.version}, because that will get the version of
> the
> user's project. So far, the easiest thing I've come up with is to write
> ${project.version} to a filtered resource file, but that seems very
> circuitous. Can I just get it in java?
>
> Thanks,
> Paul
>
>
>
>
> --
> View this message in context:
> http://www.nabble.com/getting-a-plugin%27s-own-version--tf2443270.html#a6812276
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: getting a plugin's own version?

Posted by pjungwir <ma...@9stmaryrd.com>.
By the way, what are the get/setPluginContext methods on AbstractMojo for?
When I look in the Map, it is empty. Is this a way to pass information to
your plugin from the plugin's pom? Maybe I could use this for what I want.


-- 
View this message in context: http://www.nabble.com/getting-a-plugin%27s-own-version--tf2443270.html#a6812346
Sent from the Maven - Users mailing list archive at Nabble.com.


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