[m2] how to control the plugin execution order

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

[m2] how to control the plugin execution order

Nicolas Chalumeau
I want to develop a mojo plugin for my project. The goal is to
generate java file from generated java file ie I use modello to
generate my class file but I want to generate interface for this
classes probably with XDoclet2 (GUI component will implement this
interface and extends JFrame for example).
So I want to know how to control the plugin execution in M2? The reply
will may be simple like the same order as in the pom... but I want to
check before star the plugin dev

Nicolas,

PS: if my M2 XDoclet2 plugin research interrest the maven or the
XDoclet2 teams I will be happy to contribute

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [m2] how to control the plugin execution order

Brett Porter
Hi Nicolas,

On 5/21/05, Nicolas Chalumeau <[hidden email]> wrote:
> I want to develop a mojo plugin for my project. The goal is to
> generate java file from generated java file ie I use modello to
> generate my class file but I want to generate interface for this
> classes probably with XDoclet2 (GUI component will implement this
> interface and extends JFrame for example).
> So I want to know how to control the plugin execution in M2? The reply
> will may be simple like the same order as in the pom... but I want to
> check before star the plugin dev

The order is determined by the build lifecycle. You probably want:

@phase generate-sources

in your plugin.

Within phases, order is currently indeterminate, but we intend for it
to be the order in the POM.

> PS: if my M2 XDoclet2 plugin research interrest the maven or the
> XDoclet2 teams I will be happy to contribute

In general I'd like to see it contributed to and maintained by the
product itself (i XDoclet2) if possible, but would definitely be
interested to hear how it goes and if there are any improvements
needed. We can also list it on the web site.

- Brett

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[m2] writing a plugin that generates Java code

J. Matthew Pryor
I am trying to write a plugin that will generate source code prior to
compilation, but the plugin fails when it gets called.

The plugin looks like this:

/**
 * @phase generate-sources
 * @goal bean
 * @author mpryor
 *
 */
public class ProtegeBeanGeneratorMojo extends AbstractGeneratorMojo {

    /**
     * @parameter expression="${project.build.directory}/generated-sources"
     * @required
     */
    protected File outputDirectory;
[snip]
}

POM snippet

<project>
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <artifactId>intermedi8-parent</artifactId>
    <groupId>net.mobiquity</groupId>
    <version>0.1-SNAPSHOT</version>
  </parent>
  <artifactId>intermedi8-protege-plugin</artifactId>
  <version>0.1-SNAPSHOT</version>
  <packaging>maven-plugin</packaging>
  <name>Intermedi8 Protege Plugin</name>
  <dependencies>

It builds and installs fine, with what appears to be a well formed
plugin.xml:

<plugin>
  <groupId>net.mobiquity</groupId>
  <artifactId>intermedi8-protege-plugin</artifactId>
  <isolatedRealm>true</isolatedRealm>
  <mojos>
    <mojo>
      <id>protege:bean</id>
      <requiresDependencyResolution>runtime</requiresDependencyResolution>
      <phase>generate-sources</phase>
      <executePhase>generate-sources</executePhase>
 
<implementation>net.mobiquity.intermedi8.tools.protege.ProtegeBeanGeneratorM
ojo</implementation>
      <language>java</language>
      <instantiationStrategy>per-lookup</instantiationStrategy>
      <executionStrategy>once-per-session</executionStrategy>
      <parameters>
        <parameter>
[snip]

I have another project that uses the plugin, configured like this:


  <build>
  <plugins>
  <plugin>
                <groupId>net.mobiquity</groupId>
                <artifactId>intermedi8-protege-plugin</artifactId>
                <version>0.1-SNAPSHOT</version>
                <configuration>
       
<protogeProject>${maven.src.dir}/ontology/intermedi8.pprj/</protogeProject>
                </configuration>
  </plugin>
  </plugins>

But the build fails with the following :

C:\proj\682\apps\intermedi8\intermedi8-core>m2 -X -e install
[INFO] intermedi8-parent: using locally installed snapshot
[INFO]
----------------------------------------------------------------------------
[INFO] Building Intermedi8 Core
[INFO]
----------------------------------------------------------------------------
[INFO] maven-jar-plugin: using locally installed snapshot
[INFO] maven-archiver: using locally installed snapshot
[INFO] maven: using locally installed snapshot
[INFO] intermedi8-protege-plugin: using locally installed snapshot
[INFO] maven-resources-plugin: using locally installed snapshot
[INFO] maven-compiler-plugin: using locally installed snapshot
[INFO] plexus-compiler-api: using locally installed snapshot
[INFO] plexus-compiler: using locally installed snapshot
[INFO] plexus-compiler-javac: using locally installed snapshot
[INFO] plexus-compilers: using locally installed snapshot
[INFO] maven-surefire-plugin: using locally installed snapshot
[INFO] maven-install-plugin: using locally installed snapshot
---------------------------------------------------
constituent[0]: file:/C:/dev/maven/m2dev/lib/commons-cli-1.0-beta-2.jar
constituent[1]: file:/C:/dev/maven/m2dev/lib/maven-artifact-2.0-SNAPSHOT.jar
constituent[2]: file:/C:/dev/maven/m2dev/lib/maven-core-2.0-SNAPSHOT.jar
constituent[3]: file:/C:/dev/maven/m2dev/lib/maven-model-2.0-SNAPSHOT.jar
constituent[4]: file:/C:/dev/maven/m2dev/lib/maven-monitor-2.0-SNAPSHOT.jar
constituent[5]:
file:/C:/dev/maven/m2dev/lib/maven-plugin-api-2.0-SNAPSHOT.jar
constituent[6]:
file:/C:/dev/maven/m2dev/lib/maven-plugin-descriptor-2.0-SNAPSHOT.jar
constituent[7]: file:/C:/dev/maven/m2dev/lib/maven-project-2.0-SNAPSHOT.jar
constituent[8]: file:/C:/dev/maven/m2dev/lib/maven-settings-2.0-SNAPSHOT.jar
constituent[9]:
file:/C:/dev/maven/m2dev/lib/plexus-container-artifact-1.0-alpha-3-SNAPSHOT.
jar
constituent[10]: file:/C:/dev/maven/m2dev/lib/plexus-i18n-1.0-beta-3.jar
constituent[11]:
file:/C:/dev/maven/m2dev/lib/wagon-http-lightweight-1.0-alpha-3-SNAPSHOT.jar
constituent[12]:
file:/C:/dev/maven/m2dev/lib/wagon-provider-api-1.0-alpha-3-SNAPSHOT.jar
---------------------------------------------------
java.lang.NullPointerException: version was null for
org.apache.maven.plugins:maven-protege-plugin
        at
org.apache.maven.artifact.DefaultArtifact.getBaseVersion(DefaultArtifact.jav
a:246)
        at
org.apache.maven.artifact.DefaultArtifact.getId(DefaultArtifact.java:159)
        at
org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultAr
tifactResolver.java:77)
        at
org.codehaus.plexus.DefaultArtifactEnabledContainer.addComponent(DefaultArti
factEnabledContainer.java:104)
        at
org.apache.maven.plugin.DefaultPluginManager.addPlugin(DefaultPluginManager.
java:282)
        at
org.apache.maven.plugin.DefaultPluginManager.verifyPlugin(DefaultPluginManag
er.java:241)
        at
org.apache.maven.plugin.DefaultPluginManager.verifyPluginForGoal(DefaultPlug
inManager.java:195)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeMojo(DefaultLifec
ycleExecutor.java:478)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executePhase(DefaultLife
cycleExecutor.java:436)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.processGoals(DefaultLife
cycleExecutor.java:164)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycle
Executor.java:94)
        at
org.apache.maven.DefaultMaven.processProject(DefaultMaven.java:222)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:136)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:217)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at
org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:303)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:243)
        at
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:416)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:363)


Any clues as to what I have done wrong ?

Thanks,
Matthew


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [m2] writing a plugin that generates Java code

Brett Porter
In reply to this post by Brett Porter
The <executePhase> part looks incorrect to me, and might explain the
problem as it would essentially setup an infinite loop in the
lifecycle and might explain why the plugin version isn't discovered.

Regardless, this would be a bug that it is not reported as an error properly.

I'm not sure why it is there, given you don't list it in your javadoc.
Can you confirm that it really is the same?

Thanks,
Brett

On 5/23/05, J. Matthew Pryor <[hidden email]> wrote:

> I am trying to write a plugin that will generate source code prior to
> compilation, but the plugin fails when it gets called.
>
> The plugin looks like this:
>
> /**
>  * @phase generate-sources
>  * @goal bean
>  * @author mpryor
>  *
>  */
> public class ProtegeBeanGeneratorMojo extends AbstractGeneratorMojo {
>
>     /**
>      * @parameter expression="${project.build.directory}/generated-sources"
>      * @required
>      */
>     protected File outputDirectory;
> [snip]
> }
>
> POM snippet
>
> <project>
>   <modelVersion>4.0.0</modelVersion>
>   <parent>
>     <artifactId>intermedi8-parent</artifactId>
>     <groupId>net.mobiquity</groupId>
>     <version>0.1-SNAPSHOT</version>
>   </parent>
>   <artifactId>intermedi8-protege-plugin</artifactId>
>   <version>0.1-SNAPSHOT</version>
>   <packaging>maven-plugin</packaging>
>   <name>Intermedi8 Protege Plugin</name>
>   <dependencies>
>
> It builds and installs fine, with what appears to be a well formed
> plugin.xml:
>
> <plugin>
>   <groupId>net.mobiquity</groupId>
>   <artifactId>intermedi8-protege-plugin</artifactId>
>   <isolatedRealm>true</isolatedRealm>
>   <mojos>
>     <mojo>
>       <id>protege:bean</id>
>       <requiresDependencyResolution>runtime</requiresDependencyResolution>
>       <phase>generate-sources</phase>
>       <executePhase>generate-sources</executePhase>
>
> <implementation>net.mobiquity.intermedi8.tools.protege.ProtegeBeanGeneratorM
> ojo</implementation>
>       <language>java</language>
>       <instantiationStrategy>per-lookup</instantiationStrategy>
>       <executionStrategy>once-per-session</executionStrategy>
>       <parameters>
>         <parameter>
> [snip]
>
> I have another project that uses the plugin, configured like this:
>
>
>   <build>
>         <plugins>
>                 <plugin>
>                 <groupId>net.mobiquity</groupId>
>                 <artifactId>intermedi8-protege-plugin</artifactId>
>                 <version>0.1-SNAPSHOT</version>
>                 <configuration>
>
> <protogeProject>${maven.src.dir}/ontology/intermedi8.pprj/</protogeProject>
>                 </configuration>
>                 </plugin>
>         </plugins>
>
> But the build fails with the following :
>
> C:\proj\682\apps\intermedi8\intermedi8-core>m2 -X -e install
> [INFO] intermedi8-parent: using locally installed snapshot
> [INFO]
> ----------------------------------------------------------------------------
> [INFO] Building Intermedi8 Core
> [INFO]
> ----------------------------------------------------------------------------
> [INFO] maven-jar-plugin: using locally installed snapshot
> [INFO] maven-archiver: using locally installed snapshot
> [INFO] maven: using locally installed snapshot
> [INFO] intermedi8-protege-plugin: using locally installed snapshot
> [INFO] maven-resources-plugin: using locally installed snapshot
> [INFO] maven-compiler-plugin: using locally installed snapshot
> [INFO] plexus-compiler-api: using locally installed snapshot
> [INFO] plexus-compiler: using locally installed snapshot
> [INFO] plexus-compiler-javac: using locally installed snapshot
> [INFO] plexus-compilers: using locally installed snapshot
> [INFO] maven-surefire-plugin: using locally installed snapshot
> [INFO] maven-install-plugin: using locally installed snapshot
> ---------------------------------------------------
> constituent[0]: file:/C:/dev/maven/m2dev/lib/commons-cli-1.0-beta-2.jar
> constituent[1]: file:/C:/dev/maven/m2dev/lib/maven-artifact-2.0-SNAPSHOT.jar
> constituent[2]: file:/C:/dev/maven/m2dev/lib/maven-core-2.0-SNAPSHOT.jar
> constituent[3]: file:/C:/dev/maven/m2dev/lib/maven-model-2.0-SNAPSHOT.jar
> constituent[4]: file:/C:/dev/maven/m2dev/lib/maven-monitor-2.0-SNAPSHOT.jar
> constituent[5]:
> file:/C:/dev/maven/m2dev/lib/maven-plugin-api-2.0-SNAPSHOT.jar
> constituent[6]:
> file:/C:/dev/maven/m2dev/lib/maven-plugin-descriptor-2.0-SNAPSHOT.jar
> constituent[7]: file:/C:/dev/maven/m2dev/lib/maven-project-2.0-SNAPSHOT.jar
> constituent[8]: file:/C:/dev/maven/m2dev/lib/maven-settings-2.0-SNAPSHOT.jar
> constituent[9]:
> file:/C:/dev/maven/m2dev/lib/plexus-container-artifact-1.0-alpha-3-SNAPSHOT.
> jar
> constituent[10]: file:/C:/dev/maven/m2dev/lib/plexus-i18n-1.0-beta-3.jar
> constituent[11]:
> file:/C:/dev/maven/m2dev/lib/wagon-http-lightweight-1.0-alpha-3-SNAPSHOT.jar
> constituent[12]:
> file:/C:/dev/maven/m2dev/lib/wagon-provider-api-1.0-alpha-3-SNAPSHOT.jar
> ---------------------------------------------------
> java.lang.NullPointerException: version was null for
> org.apache.maven.plugins:maven-protege-plugin
>         at
> org.apache.maven.artifact.DefaultArtifact.getBaseVersion(DefaultArtifact.jav
> a:246)
>         at
> org.apache.maven.artifact.DefaultArtifact.getId(DefaultArtifact.java:159)
>         at
> org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultAr
> tifactResolver.java:77)
>         at
> org.codehaus.plexus.DefaultArtifactEnabledContainer.addComponent(DefaultArti
> factEnabledContainer.java:104)
>         at
> org.apache.maven.plugin.DefaultPluginManager.addPlugin(DefaultPluginManager.
> java:282)
>         at
> org.apache.maven.plugin.DefaultPluginManager.verifyPlugin(DefaultPluginManag
> er.java:241)
>         at
> org.apache.maven.plugin.DefaultPluginManager.verifyPluginForGoal(DefaultPlug
> inManager.java:195)
>         at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeMojo(DefaultLifec
> ycleExecutor.java:478)
>         at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executePhase(DefaultLife
> cycleExecutor.java:436)
>         at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.processGoals(DefaultLife
> cycleExecutor.java:164)
>         at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycle
> Executor.java:94)
>         at
> org.apache.maven.DefaultMaven.processProject(DefaultMaven.java:222)
>         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:136)
>         at org.apache.maven.cli.MavenCli.main(MavenCli.java:217)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
> )
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
> .java:25)
>         at java.lang.reflect.Method.invoke(Method.java:324)
>         at
> org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:303)
>         at org.codehaus.classworlds.Launcher.launch(Launcher.java:243)
>         at
> org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:416)
>         at org.codehaus.classworlds.Launcher.main(Launcher.java:363)
>
>
> Any clues as to what I have done wrong ?
>
> Thanks,
> Matthew
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: [m2] writing a plugin that generates Java code

J. Matthew Pryor
That was a copy & paste issue. I copied the javadoc tag from the IdeaPlugin.

I changed that javadoc tag & now get

      <phase>generate-sources</phase>

I also fixed a bunch of typos & also removed the intermediate
AbstractGeneratorMojo (the NPE issue that was a red herring), so now I get
no errors, but no evidence of my plugin getting called

[INFO] Building Intermedi8 Core
[INFO]
----------------------------------------------------------------------------
[INFO] intermedi8-protege-plugin: using locally installed snapshot
[INFO] [resources:resources]
[INFO] intermedi8-roadmap-plugin: using locally installed snapshot
[INFO] [compiler:compile]
[INFO] No sources to compile
[INFO] [resources:testResources]
[INFO] [compiler:testCompile]
[INFO] No sources to compile
[INFO] [surefire:test]
[INFO] Setting reports dir:
C:\proj\682\apps\intermedi8\intermedi8-core\target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
There are no test to run.

Results :
[surefire] Tests run: 0, Failures: 0, Errors: 0

[INFO] [jar:jar]
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar:
C:\proj\682\apps\intermedi8\intermedi8-core\target\intermedi8-core-0.1-SNAPS
HOT.jar
[INFO] [install:install]
[INFO] Installing
C:\proj\682\apps\intermedi8\intermedi8-core\target\intermedi8-core-0.1-SNAPS
HOT.jar to C:\Documents and Settings\m
pryor\.m2\repository\net\mobiquity\intermedi8-core\0.1-SNAPSHOT\intermedi8-c
ore-0.1-SNAPSHOT.jar
[INFO]
----------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO]
----------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Mon May 23 11:20:13 EST 2005
[INFO] Final Memory: 2M/4M
[INFO]
----------------------------------------------------------------------------

How can I get better information about what plugins are getting called?

Any other hints to get a better diagnosis?

Thanks,
Matthew

> -----Original Message-----
> From: Brett Porter [mailto:[hidden email]]
> Sent: Monday, May 23, 2005 11:12 AM
> To: [hidden email]
> Cc: Maven Users List
> Subject: Re: [m2] writing a plugin that generates Java code
>
> The <executePhase> part looks incorrect to me, and might
> explain the problem as it would essentially setup an infinite
> loop in the lifecycle and might explain why the plugin
> version isn't discovered.
>
> Regardless, this would be a bug that it is not reported as an
> error properly.
>
> I'm not sure why it is there, given you don't list it in your javadoc.
> Can you confirm that it really is the same?
>
> Thanks,
> Brett
>
> On 5/23/05, J. Matthew Pryor <[hidden email]> wrote:
> > I am trying to write a plugin that will generate source
> code prior to
> > compilation, but the plugin fails when it gets called.
> >
> > The plugin looks like this:
> >
> > /**
> >  * @phase generate-sources
> >  * @goal bean
> >  * @author mpryor
> >  *
> >  */
> > public class ProtegeBeanGeneratorMojo extends
> AbstractGeneratorMojo {
> >
> >     /**
> >      * @parameter
> expression="${project.build.directory}/generated-sources"
> >      * @required
> >      */
> >     protected File outputDirectory;
> > [snip]
> > }
> >
> > POM snippet
> >
> > <project>
> >   <modelVersion>4.0.0</modelVersion>
> >   <parent>
> >     <artifactId>intermedi8-parent</artifactId>
> >     <groupId>net.mobiquity</groupId>
> >     <version>0.1-SNAPSHOT</version>
> >   </parent>
> >   <artifactId>intermedi8-protege-plugin</artifactId>
> >   <version>0.1-SNAPSHOT</version>
> >   <packaging>maven-plugin</packaging>
> >   <name>Intermedi8 Protege Plugin</name>
> >   <dependencies>
> >
> > It builds and installs fine, with what appears to be a well formed
> > plugin.xml:
> >
> > <plugin>
> >   <groupId>net.mobiquity</groupId>
> >   <artifactId>intermedi8-protege-plugin</artifactId>
> >   <isolatedRealm>true</isolatedRealm>
> >   <mojos>
> >     <mojo>
> >       <id>protege:bean</id>
> >      
> <requiresDependencyResolution>runtime</requiresDependencyResolution>
> >       <phase>generate-sources</phase>
> >       <executePhase>generate-sources</executePhase>
> >
> >
> <implementation>net.mobiquity.intermedi8.tools.protege.ProtegeBeanGene
> > ratorM
> > ojo</implementation>
> >       <language>java</language>
> >       <instantiationStrategy>per-lookup</instantiationStrategy>
> >       <executionStrategy>once-per-session</executionStrategy>
> >       <parameters>
> >         <parameter>
> > [snip]
> >
> > I have another project that uses the plugin, configured like this:
> >
> >
> >   <build>
> >         <plugins>
> >                 <plugin>
> >                 <groupId>net.mobiquity</groupId>
> >                 <artifactId>intermedi8-protege-plugin</artifactId>
> >                 <version>0.1-SNAPSHOT</version>
> >                 <configuration>
> >
> >
> <protogeProject>${maven.src.dir}/ontology/intermedi8.pprj/</pr
> otogeProject>
> >                 </configuration>
> >                 </plugin>
> >         </plugins>
> >
> > But the build fails with the following :
> >
> > C:\proj\682\apps\intermedi8\intermedi8-core>m2 -X -e install [INFO]
> > intermedi8-parent: using locally installed snapshot [INFO]
> >
> ----------------------------------------------------------------------
> > ------
> > [INFO] Building Intermedi8 Core
> > [INFO]
> >
> ----------------------------------------------------------------------
> > ------ [INFO] maven-jar-plugin: using locally installed snapshot
> > [INFO] maven-archiver: using locally installed snapshot
> [INFO] maven:
> > using locally installed snapshot [INFO] intermedi8-protege-plugin:
> > using locally installed snapshot [INFO]
> maven-resources-plugin: using
> > locally installed snapshot [INFO] maven-compiler-plugin:
> using locally
> > installed snapshot [INFO] plexus-compiler-api: using
> locally installed
> > snapshot [INFO] plexus-compiler: using locally installed snapshot
> > [INFO] plexus-compiler-javac: using locally installed
> snapshot [INFO]
> > plexus-compilers: using locally installed snapshot [INFO]
> > maven-surefire-plugin: using locally installed snapshot [INFO]
> > maven-install-plugin: using locally installed snapshot
> > ---------------------------------------------------
> > constituent[0]:
> > file:/C:/dev/maven/m2dev/lib/commons-cli-1.0-beta-2.jar
> > constituent[1]:
> > file:/C:/dev/maven/m2dev/lib/maven-artifact-2.0-SNAPSHOT.jar
> > constituent[2]:
> > file:/C:/dev/maven/m2dev/lib/maven-core-2.0-SNAPSHOT.jar
> > constituent[3]:
> > file:/C:/dev/maven/m2dev/lib/maven-model-2.0-SNAPSHOT.jar
> > constituent[4]:
> > file:/C:/dev/maven/m2dev/lib/maven-monitor-2.0-SNAPSHOT.jar
> > constituent[5]:
> > file:/C:/dev/maven/m2dev/lib/maven-plugin-api-2.0-SNAPSHOT.jar
> > constituent[6]:
> >
> file:/C:/dev/maven/m2dev/lib/maven-plugin-descriptor-2.0-SNAPSHOT.jar
> > constituent[7]:
> > file:/C:/dev/maven/m2dev/lib/maven-project-2.0-SNAPSHOT.jar
> > constituent[8]:
> > file:/C:/dev/maven/m2dev/lib/maven-settings-2.0-SNAPSHOT.jar
> > constituent[9]:
> >
> file:/C:/dev/maven/m2dev/lib/plexus-container-artifact-1.0-alp
> ha-3-SNAPSHOT.
> > jar
> > constituent[10]:
> > file:/C:/dev/maven/m2dev/lib/plexus-i18n-1.0-beta-3.jar
> > constituent[11]:
> >
> file:/C:/dev/maven/m2dev/lib/wagon-http-lightweight-1.0-alpha-3-SNAPSH
> > OT.jar
> > constituent[12]:
> >
> file:/C:/dev/maven/m2dev/lib/wagon-provider-api-1.0-alpha-3-SNAPSHOT.j
> > ar
> > ---------------------------------------------------
> > java.lang.NullPointerException: version was null for
> > org.apache.maven.plugins:maven-protege-plugin
> >         at
> >
> org.apache.maven.artifact.DefaultArtifact.getBaseVersion(DefaultArtifa
> > ct.jav
> > a:246)
> >         at
> >
> org.apache.maven.artifact.DefaultArtifact.getId(DefaultArtifac
> t.java:159)
> >         at
> >
> org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(Def
> > aultAr
> > tifactResolver.java:77)
> >         at
> >
> org.codehaus.plexus.DefaultArtifactEnabledContainer.addComponent(Defau
> > ltArti
> > factEnabledContainer.java:104)
> >         at
> >
> org.apache.maven.plugin.DefaultPluginManager.addPlugin(Default
> PluginManager.
> > java:282)
> >         at
> >
> org.apache.maven.plugin.DefaultPluginManager.verifyPlugin(DefaultPlugi
> > nManag
> > er.java:241)
> >         at
> >
> org.apache.maven.plugin.DefaultPluginManager.verifyPluginForGoal(Defau
> > ltPlug
> > inManager.java:195)
> >         at
> >
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeMojo(Defaul
> > tLifec
> > ycleExecutor.java:478)
> >         at
> >
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executePhase(Defau
> > ltLife
> > cycleExecutor.java:436)
> >         at
> >
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.processGoals(Defau
> > ltLife
> > cycleExecutor.java:164)
> >         at
> >
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLif
> > ecycle
> > Executor.java:94)
> >         at
> > org.apache.maven.DefaultMaven.processProject(DefaultMaven.java:222)
> >         at
> org.apache.maven.DefaultMaven.execute(DefaultMaven.java:136)
> >         at org.apache.maven.cli.MavenCli.main(MavenCli.java:217)
> >         at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >         at
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
> > ava:39
> > )
> >         at
> >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> > orImpl
> > .java:25)
> >         at java.lang.reflect.Method.invoke(Method.java:324)
> >         at
> > org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:303)
> >         at
> org.codehaus.classworlds.Launcher.launch(Launcher.java:243)
> >         at
> >
> org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:416)
> >         at org.codehaus.classworlds.Launcher.main(Launcher.java:363)
> >
> >
> > Any clues as to what I have done wrong ?
> >
> > Thanks,
> > Matthew
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [m2] writing a plugin that generates Java code

Brett Porter
In reply to this post by Brett Porter
On 5/23/05, J. Matthew Pryor <[hidden email]> wrote:
> That was a copy & paste issue. I copied the javadoc tag from the IdeaPlugin.
>
> I changed that javadoc tag & now get
>
>       <phase>generate-sources</phase>
>
> I also fixed a bunch of typos & also removed the intermediate
> AbstractGeneratorMojo (the NPE issue that was a red herring), so now I get
> no errors, but no evidence of my plugin getting called

Ok, sorry for following the red herring.

> How can I get better information about what plugins are getting called?

If it is called, [protege:bean] would appear.

The problem is that you need to add
<goals><goal><id>bean</id></goal></goals> to the plugin configuration
to tell Maven to register the goal with the phase.

Apart from the fact this all needs to be documented (which will happen
at the end of the week when everything else is finalised), do you
agree this is the right way to do it? One of the aims is for there to
be minimal magic as well as minimal configuration so it is fairly
obvious looking at a POM what will happen.

It will probably be possible to let a plugin, once configured,
auto-register some goals (like the packaging ones do), by the end of
the week when the design is implemented (first section of
http://docs.codehaus.org/display/MAVEN/Lifecycle).

- Brett

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: [m2] writing a plugin that generates Java code

J. Matthew Pryor
In general, aside from the noted lack of documentation (once again happy to
provide support here) I think the basic approach is the right one.

Writing a Mojo with javadoc tags is definitely nice & straightforward.

What I am confused about is how my new plugin actually gets called. I
basically get the whole lifecycle/phase thing, I that on the money AFAIAC,
but what I can't quite get is connecting the new plugin with the project
that needs the code generated.

> The problem is that you need to add
> <goals><goal><id>bean</id></goal></goals> to the plugin
> configuration to tell Maven to register the goal with the phase.
>

So here are you talking about the plugin or the project that uses the
plugin?

Assuming the later, I did this:

And got this:

[INFO] intermedi8-protege-plugin: using locally installed snapshot
FATAL ERROR: Error executing Maven for a project
org.apache.maven.reactor.ReactorException: Error executing project within
the reactor
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:144)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:217)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at
org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:303)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:243)
        at
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:416)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:363)
Caused by: org.apache.maven.lifecycle.LifecycleExecutionException: A goal
'protege:bean' was declared in pom.xml, but does not exist

        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.processPluginPhases(Defa
ultLifecycleExecutor.java:293)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.processPluginConfigurati
on(DefaultLifecycleExecutor.java:240)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.processGoals(DefaultLife
cycleExecutor.java:152)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycle
Executor.java:94)
        at
org.apache.maven.DefaultMaven.processProject(DefaultMaven.java:222)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:136)
        ... 9 more

Very happy to keep plugigng away to get this resolved

Matthew


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [m2] writing a plugin that generates Java code

Brett Porter
In reply to this post by Brett Porter
On 5/23/05, J. Matthew Pryor <[hidden email]> wrote:
> In general, aside from the noted lack of documentation (once again happy to
> provide support here) I think the basic approach is the right one.

Cool. BTW, did you get my recent email about the pluginManagement docs
you wrote? (4 days ago).

> So here are you talking about the plugin or the project that uses the
> plugin?

The goal definition needs to go into the project to tell Maven to
register the goal in the lifecycle. eg:
http://svn.apache.org/viewcvs.cgi/maven/components/trunk/maven-model/pom.xml?rev=169961&view=markup

> Assuming the later, I did this:

This went missing, but I assume you got it right.

>
> And got this:
>

Based on the location of the error, you are using alpha-1. Plugins
with arbitrary IDs are only supported from alpha-2 (note that this
required some heavy changes to the mojo API, but that is what is
documented on the site. So you probably want to switch to alpha-2
anyway, but it will mean regenerating your plugins after the change as
it was not backwards compatible).

Hope this helps!

- Brett

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [m2] writing a plugin that generates Java code

Brett Porter
In reply to this post by Brett Porter
My later answer still holds (upgrade to alpha-2). Using alpha-1
definitely explains the exception you got as it also didn't support
version discovery.

- Brett

On 5/23/05, J. Matthew Pryor <[hidden email]> wrote:

> In answer to my own post, the addition of the goals
> section to the "using" project now appears to call the
> plugin, or at least start to.
>
> In fact the Red Herring wasn't red after all, now I am
> back here.
>
> [INFO] Building Intermedi8 Core
> [INFO]
> ----------------------------------------------------------------------------
> [INFO] intermedi8-protege-plugin: using locally
> installed snapshot
> ---------------------------------------------------
> constituent[0]:
> file:/C:/dev/maven/m2dev/lib/commons-cli-1.0-beta-2.jar
> constituent[1]:
> file:/C:/dev/maven/m2dev/lib/maven-artifact-2.0-SNAPSHOT.jar
> constituent[2]:
> file:/C:/dev/maven/m2dev/lib/maven-core-2.0-SNAPSHOT.jar
> constituent[3]:
> file:/C:/dev/maven/m2dev/lib/maven-model-2.0-SNAPSHOT.jar
> constituent[4]:
> file:/C:/dev/maven/m2dev/lib/maven-monitor-2.0-SNAPSHOT.jar
> constituent[5]:
> file:/C:/dev/maven/m2dev/lib/maven-plugin-api-2.0-SNAPSHOT.jar
> constituent[6]:
> file:/C:/dev/maven/m2dev/lib/maven-plugin-descriptor-2.0-SNAPSHOT.jar
> constituent[7]:
> file:/C:/dev/maven/m2dev/lib/maven-project-2.0-SNAPSHOT.jar
> constituent[8]:
> file:/C:/dev/maven/m2dev/lib/maven-settings-2.0-SNAPSHOT.jar
> constituent[9]:
> file:/C:/dev/maven/m2dev/lib/plexus-container-artifact-1.0-alpha-3-SNAPSHOT.jar
> constituent[10]:
> file:/C:/dev/maven/m2dev/lib/plexus-i18n-1.0-beta-3.jar
> constituent[11]:
> file:/C:/dev/maven/m2dev/lib/wagon-http-lightweight-1.0-alpha-3-SNAPSHOT.jar
> constituent[12]:
> file:/C:/dev/maven/m2dev/lib/wagon-provider-api-1.0-alpha-3-SNAPSHOT.jar
> ---------------------------------------------------
> java.lang.NullPointerException: version was null for
> org.apache.maven.plugins:maven-protege-plugin
>         at
> org.apache.maven.artifact.DefaultArtifact.getBaseVersion(DefaultArtifact.java:246)
>         at
> org.apache.maven.artifact.DefaultArtifact.getId(DefaultArtifact.java:159)
>         at
> org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:77)
>         at
> org.codehaus.plexus.DefaultArtifactEnabledContainer.addComponent(DefaultArtifactEnabledContainer.java:104)
>         at
> org.apache.maven.plugin.DefaultPluginManager.addPlugin(DefaultPluginManager.java:282)
>         at
> org.apache.maven.plugin.DefaultPluginManager.verifyPlugin(DefaultPluginManager.java:241)
>         at
> org.apache.maven.plugin.DefaultPluginManager.verifyPluginForGoal(DefaultPluginManager.java:195)
>         at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeMojo(DefaultLifecycleExecutor.java:478)
>         at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executePhase(DefaultLifecycleExecutor.java:436)
>         at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.processGoals(DefaultLifecycleExecutor.java:164)
>         at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:94)
>         at
> org.apache.maven.DefaultMaven.processProject(DefaultMaven.java:222)
>         at
> org.apache.maven.DefaultMaven.execute(DefaultMaven.java:136)
>         at
> org.apache.maven.cli.MavenCli.main(MavenCli.java:217)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at
> java.lang.reflect.Method.invoke(Method.java:324)
>         at
> org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:303)
>         at
> org.codehaus.classworlds.Launcher.launch(Launcher.java:243)
>         at
> org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:416)
>         at
> org.codehaus.classworlds.Launcher.main(Launcher.java:363)
>
>
> Not sure where to go now?
>
> Matthew
>
> --- "J. Matthew Pryor" <[hidden email]> wrote:
> > In general, aside from the noted lack of
> > documentation (once again happy to
> > provide support here) I think the basic approach is
> > the right one.
> >
> > Writing a Mojo with javadoc tags is definitely nice
> > & straightforward.
> >
> > What I am confused about is how my new plugin
> > actually gets called. I
> > basically get the whole lifecycle/phase thing, I
> > that on the money AFAIAC,
> > but what I can't quite get is connecting the new
> > plugin with the project
> > that needs the code generated.
> >
> > > The problem is that you need to add
> > > <goals><goal><id>bean</id></goal></goals> to the
> > plugin
> > > configuration to tell Maven to register the goal
> > with the phase.
> > >
> >
> > So here are you talking about the plugin or the
> > project that uses the
> > plugin?
> >
> > Assuming the later, I did this:
> >
> > And got this:
> >
> > [INFO] intermedi8-protege-plugin: using locally
> > installed snapshot
> > FATAL ERROR: Error executing Maven for a project
> > org.apache.maven.reactor.ReactorException: Error
> > executing project within
> > the reactor
> >         at
> >
> org.apache.maven.DefaultMaven.execute(DefaultMaven.java:144)
> >         at
> >
> org.apache.maven.cli.MavenCli.main(MavenCli.java:217)
> >         at
> > sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > Method)
> >         at
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
> > )
> >         at
> >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
> > .java:25)
> >         at
> > java.lang.reflect.Method.invoke(Method.java:324)
> >         at
> >
> org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:303)
> >         at
> >
> org.codehaus.classworlds.Launcher.launch(Launcher.java:243)
> >         at
> >
> org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:416)
> >         at
> >
> org.codehaus.classworlds.Launcher.main(Launcher.java:363)
> > Caused by:
> >
> org.apache.maven.lifecycle.LifecycleExecutionException:
> > A goal
> > 'protege:bean' was declared in pom.xml, but does not
> > exist
> >
> >         at
> >
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.processPluginPhases(Defa
> > ultLifecycleExecutor.java:293)
> >         at
> >
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.processPluginConfigurati
> > on(DefaultLifecycleExecutor.java:240)
> >         at
> >
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.processGoals(DefaultLife
> > cycleExecutor.java:152)
> >         at
> >
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycle
> > Executor.java:94)
> >         at
> >
> org.apache.maven.DefaultMaven.processProject(DefaultMaven.java:222)
> >         at
> >
> org.apache.maven.DefaultMaven.execute(DefaultMaven.java:136)
> >         ... 9 more
> >
> > Very happy to keep plugigng away to get this
> > resolved
> >
> > Matthew
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > [hidden email]
> > For additional commands, e-mail:
> > [hidden email]
> >
> >
> >
> >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [m2] writing a plugin that generates Java code

J. Matthew Pryor
OK so here is where I am at.

I now have the plugin working. Thanks.

Yes I thought I had built m2 from bootstrap, but
apparently not, so I downloaded alpha-2, that did the
trick.

BTW PluginDescriptorGenerator throws an NPE is a Mojo
doesn't have an @goal tag.

So now I generate my source code, but it doesn't get
compiled. Is there a 'special' place to generate Java
source into so it will get compiled? Or do I need to
do something else ?

I would prefer it if the plugin was able o cause the
generated code to get compiled rather than the using
project having to add something to its POM, but I'll
do whatever works for now.

To your previous question, I think having to explcitly
nominate:
<goals><goal><id>blah</id></goal></goals> in the using
project is too much, the plugin should be able to
fully  establish itself without the using project
having to know what goal to set up. Configuration of a
plugin is a different matter IMO, but one should be
able to use a plugin without any configuraton as a
starting point.

Thanks again for the help

Matthew

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [m2] writing a plugin that generates Java code

Brett Porter
On 5/23/05, J. Matthew Pryor <[hidden email]> wrote:
> OK so here is where I am at.
>
> I now have the plugin working. Thanks.

Great, glad I could help.

> BTW PluginDescriptorGenerator throws an NPE is a Mojo
> doesn't have an @goal tag.

ok, I'll fix it.

> So now I generate my source code, but it doesn't get
> compiled. Is there a 'special' place to generate Java
> source into so it will get compiled? Or do I need to
> do something else ?

Yep. Another thing we are trying to streamline but the current
practice is to take a MavenProject field and call
project.addCompileSourceRoot( ... ); The compiler will pick that up.

> To your previous question, I think having to explcitly
> nominate:
> <goals><goal><id>blah</id></goal></goals> in the using
> project is too much, the plugin should be able to
> fully  establish itself without the using project
> having to know what goal to set up. Configuration of a
> plugin is a different matter IMO, but one should be
> able to use a plugin without any configuraton as a
> starting point.

Ok, will keep that in mind when we talk through the design later this week.

- Brett

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [m2] writing a plugin that generates Java code

J. Matthew Pryor
In reply to this post by Brett Porter

> Yep. Another thing we are trying to streamline but
> the current
> practice is to take a MavenProject field and call
> project.addCompileSourceRoot( ... ); The compiler
> will pick that up.
>

OK that was pretty easy and not intrusive to the using
project. it works a treat, I am up & runnign.

Cheers,
Matthew

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [m2] how to control the plugin execution order

Anatol Pomozov
In reply to this post by Brett Porter
> PS: if my M2 XDoclet2 plugin research interrest the maven or the
> XDoclet2 teams I will be happy to contribute

We are (xdoclet2 team) glad to hear it. If you think that your plugin
ready for cruise please create new ticket
http://jira.codehaus.org/browse/XDOCLET and attach sources to them.

--
anatol

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [m2] how to control the plugin execution order

Nicolas Chalumeau
Hi Anatol

I's actually just a project in my todo list but I will do it as I need
it ;-). I let you know when it will be ready. Do you want I open an
issue for this (xdoclet2 project or xdoclet2 plugin project ?)

Nicolas

On 5/23/05, Anatol Pomozov <[hidden email]> wrote:

> > PS: if my M2 XDoclet2 plugin research interrest the maven or the
> > XDoclet2 teams I will be happy to contribute
>
> We are (xdoclet2 team) glad to hear it. If you think that your plugin
> ready for cruise please create new ticket
> http://jira.codehaus.org/browse/XDOCLET and attach sources to them.
>
> --
> anatol
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]