You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Jeff Maxwell <je...@gmail.com> on 2012/09/10 18:59:53 UTC
Dynamically determining the currently executing goal name
I would like to dynamically determine the currently executing goal from a
MOJO.
I attempted this using reflection but the new annotations are not available
at runtime.
All other solutions I have seen appear to require access to the executing
MOJO's groupId and artifactId.
Anyone have a solution?
Is there an issue with having the annotations available at runtime?
--
View this message in context: http://maven.40175.n5.nabble.com/Dynamically-determining-the-currently-executing-goal-name-tp5721050.html
Sent from the Maven Developers mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
Re: Dynamically determining the currently executing goal name
Posted by Jeff Maxwell <je...@gmail.com>.
This works fine:
/** The project. */
@Parameter(required = true, readonly = true, defaultValue =
"${mojoExecution}")
private MojoExecution mojoExecution;
@Override
public String getGoalName() {
return this.mojoExecution.getMojoDescriptor().getGoal();
}
It was a bit of effort to get it to work with AbstractMojoTestCase but
not too bad.
Thanks!
--
View this message in context: http://maven.40175.n5.nabble.com/Dynamically-determining-the-currently-executing-goal-name-tp5721050p5721312.html
Sent from the Maven Developers mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
Re: Dynamically determining the currently executing goal name
Posted by Tamás Cservenák <ta...@cservenak.net>.
Add following member to your Mojo and inspect what is injected:
/**
* Mojo execution.
*
* @parameter default-value="${mojoExecution}"
* @required
* @readonly
*/
private org.apache.maven.plugin.MojoExecution mojoExecution;
Hope helps,
~t~
On Mon, Sep 10, 2012 at 6:59 PM, Jeff Maxwell <je...@gmail.com>wrote:
> I would like to dynamically determine the currently executing goal from a
> MOJO.
>
> I attempted this using reflection but the new annotations are not available
> at runtime.
>
> All other solutions I have seen appear to require access to the executing
> MOJO's groupId and artifactId.
>
> Anyone have a solution?
> Is there an issue with having the annotations available at runtime?
>
>
>
>
>
>
>
>
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Dynamically-determining-the-currently-executing-goal-name-tp5721050.html
> Sent from the Maven Developers mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>