Hi:

I´m developing a pluging to echoe it´s execution phase to console, in the Wiki 
FAQ this is one unanswered question so i tried it out by myself.

I believed that by using the MojoDescriptor i could get it (javadocs are not 
too complet) but i´m having a NullPointerException when trying to retrieve the 
MojoDescriptor:

[INFO] Trace
java.lang.NullPointerException
        at org.apache.maven.plugin.descriptor.PluginDescriptor.getMojo(PluginDes
criptor.java:262)
        at com.cursomaven.plugin.mojo.PhaseInfoMojo.execute(PhaseInfoMojo.java:5
1)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPlugi
nManager.java:443)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
ultLifecycleExecutor.java:539)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLi
fecycle(DefaultLifecycleExecutor.java:480)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Defau
ltLifecycleExecutor.java:459)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHan
dleFailures(DefaultLifecycleExecutor.java:311)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmen
ts(DefaultLifecycleExecutor.java:278)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi
fecycleExecutor.java:143)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:334)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:125)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:280)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)

        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

Im using the mojo´s goal as parameter for the PluginDescriptor.getMojo() 
method, but i´m not sure if this is a correct use of the API. If not, could 
anyone give me a hint about the correct use of the getMojo method?.

Another problem i´m facing is that the phase binding of my mojo is not working 
unless i explicity set a execution tag in my pom, i don´t need to specify a 
execution phase, but i need a goal for my plugin to execute.

I Attach both my Mojo and the plugin.xml generated file.

Thanks
  

------------------------------------------------------------------
This e-mail and the documents attached are confidential and intended solely
for the addressee; it may also be privileged. If you receive this e-mail
in error, please notify the sender immediately and destroy it.
As its integrity cannot be secured on the Internet, the Atos Origin group
liability cannot be triggered for the message content. Although the
sender endeavours to maintain a computer virus-free network, the sender does
not warrant that this transmission is virus-free and will not be liable for
any damages resulting from any virus transmitted.

Este mensaje y los ficheros adjuntos pueden contener informacion
confidencial destinada solamente a la(s) persona(s) mencionadas
anteriormente. Pueden estar protegidos por secreto profesional Si usted
recibe este correo electronico por error, gracias de informar inmediatamente
al remitente y destruir el mensaje.
Al no estar asegurada la integridad de este mensaje sobre la red, Atos
Origin no se hace responsable por su contenido. Su contenido no constituye
ningun compromiso para el grupo Atos Origin, salvo ratificacion escrita por
ambas partes.
Aunque se esfuerza al maximo por mantener su red libre de virus, el emisor
no puede garantizar nada al respecto y no sera responsable de cualesquiera
danos que puedan resultar de una transmision de virus
------------------------------------------------------------------

<plugin>
  <description></description>
  <groupId>EjercicioFasesPlugin</groupId>
  <artifactId>EjercicioFasesPlugin</artifactId>
  <version>0.0.1</version>
  <goalPrefix>EjercicioFasesPlugin</goalPrefix>
  <isolatedRealm>false</isolatedRealm>
  <inheritedByDefault>true</inheritedByDefault>
  <mojos>
    <mojo>
      <goal>muestra</goal>
      <description>Esta clase define un mojo de Maven para imprimir por pantalla una frase con
el fin de ayudar en los ejercicios para la comprensión del ciclo de vida de
Maven y su modificación, así como el uso de plugins

El alumno debería utilizar este plugin asociandolo a diferentes fases del
ciclo de vida de Maven y comprobar su funcionamiento.

Solo tiene un goal, &quot;muestra&quot; que genera un fichero ejecuciones.txt con la
información.</description>
      <requiresDirectInvocation>false</requiresDirectInvocation>
      <requiresProject>true</requiresProject>
      <requiresReports>false</requiresReports>
      <aggregator>false</aggregator>
      <requiresOnline>false</requiresOnline>
      <inheritedByDefault>true</inheritedByDefault>
      <phase>compile</phase>
      <implementation>com.cursomaven.plugin.mojo.PhaseInfoMojo</implementation>
      <language>java</language>
      <instantiationStrategy>per-lookup</instantiationStrategy>
      <executionStrategy>once-per-session</executionStrategy>
      <parameters>
        <parameter>
          <name>baseDir</name>
          <type>java.lang.String</type>
          <required>false</required>
          <editable>true</editable>
          <description>Directorio donde se generará el fichero</description>
        </parameter>
        <parameter>
          <name>descriptor</name>
          <type>org.apache.maven.plugin.descriptor.PluginDescriptor</type>
          <required>false</required>
          <editable>true</editable>
          <description>El descriptor del plugin para sacar información sobre él</description>
        </parameter>
      </parameters>
      <configuration>
        <baseDir implementation="java.lang.String" default-value="${basedir}"/>
        <descriptor implementation="org.apache.maven.plugin.descriptor.PluginDescriptor" default-value="${plugin}"/>
      </configuration>
    </mojo>
  </mojos>
  <dependencies/>
</plugin>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to