maven-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lennart Jörelid <lennart.jore...@gmail.com>
Subject Re: Plugin phase awareness...
Date Tue, 24 Dec 2013 01:53:06 GMT
Try just injecting the mojoExecution object.
Then invoke the getLifecyclePhase() method in it.


2013/12/24 Martin Gainty <mgainty@hotmail.com>

> Igor/Tamas
> a quick test
>
> package org.apache.maven.plugin;
> public class CompilerMojo extends AbstractCompilerMojo
> {
>     @Parameter(defaultValue = "${mojoExecution.lifecyclePhase}")
>     private String executionPhase;
>     public String getExecutionPhase() { return executionPhase; }
>
>
>     public void execute() throws MojoExecutionException,
> CompilationFailureException
>     {
>       getLog().info("CompilerMojo::execute LINE 136 Current phase is
> "+getExecutionPhase());
> ....
>
>   }
>
> }
> [info] CompilerMojo::execute LINE 136 Current phase is null
>
>
>
> does this work in all versions of maven...if not which versions can i
> implement mojoExecution.lifecyclePhase
>
> ?
> Martin
> ______________________________________________
> Jogi és Bizalmassági kinyilatkoztatás
>
>
> Ez az üzenet bizalmas.  Ha nem ön az akinek szánva volt, akkor kérjük,
> hogy jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának
> készítése nem megengedett.  Ez az üzenet csak ismeret cserét szolgál és
> semmiféle jogi alkalmazhatósága sincs.  Mivel az electronikus üzenetek
> könnyen megváltoztathatóak, ezért minket semmi felelöség nem terhelhet ezen
> üzenet tartalma miatt.
>
>
>
>
>
> > From: tamas@cservenak.net
> > Date: Mon, 23 Dec 2013 11:04:58 +0100
> > Subject: Re: Plugin phase awareness...
> > To: dev@maven.apache.org
> >
> > Here is an example, same as proposed by Igor
> >
> https://github.com/sonatype/nexus-maven-plugins/blob/master/staging/maven-plugin/src/main/java/org/sonatype/nexus/maven/staging/AbstractStagingMojo.java#L72
> >
> > Still, you need to be careful if you want maven 2.x, maven 3.0.x and
> maven
> > 3.1.x compatibility, as some methods did change around here.
> > Just skim the javadoc comments.
> >
> >
> > HTH,
> > ~t~
> >
> >
> > On Sat, Dec 21, 2013 at 3:27 PM, Igor Fedorenko <igor@ifedorenko.com>
> wrote:
> >
> > > Something like this should do the trick
> > >
> > > @Parameter(defaultValue = "${mojoExecution.lifecyclePhase}")
> > > private String executionPhase;
> > >
> > > other "magic" properties available to mojos are documented in [1]
> > >
> > > [1] http://maven.apache.org/ref/3.1.1/maven-core/apidocs/org/
> > > apache/maven/plugin/PluginParameterExpressionEvaluator.html
> > >
> > > --
> > > Regards,
> > > Igor
> > >
> > >
> > >
> > > On 12/21/2013, 3:52, Lennart Jörelid wrote:
> > >
> > >> Hello all,
> > >>
> > >> How can a running Mojo query the Maven API (or some other API) to
> find out
> > >> which Maven Phase it has been invoked in? Something like ...
> > >>
> > >> String currentPhase = getSomeMavenApiHelper().getCurrentPhase();
> > >>
> > >> --
> > >> +==============================+
> > >> | Bästa hälsningar,
> > >> | [sw. "Best regards"]
> > >> |
> > >> | Lennart Jörelid
> > >> | EAI Architect & Integrator
> > >> |
> > >> | jGuru Europe AB
> > >> | Mölnlycke - Kista
> > >> |
> > >> | Email: lj@jguru.se
> > >> | URL: www.jguru.se
> > >> | Phone
> > >> | (skype): jgurueurope
> > >> | (intl): +46 708 507 603
> > >> | (domestic): 0708 - 507 603
> > >> +==============================+
> > >>
> > >>
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > > For additional commands, e-mail: dev-help@maven.apache.org
> > >
> > >
>
>



-- 

--
+==============================+
| Bästa hälsningar,
| [sw. "Best regards"]
|
| Lennart Jörelid
| EAI Architect & Integrator
|
| jGuru Europe AB
| Mölnlycke - Kista
|
| Email: lj@jguru.se
| URL:   www.jguru.se
| Phone
| (skype):    jgurueurope
| (intl):     +46 708 507 603
| (domestic): 0708 - 507 603
+==============================+

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message