On 18 September 2012 23:19, John Riedl <[email protected]> wrote:

> Stephen:
>
> Wow, nice detailed observations.
>
> Just to make sure everyone else catches something that I misread the
> first time: it's only if you don't specify any phase that you get the
> help text without the new phases included.  If you do specify a phase
> that maven is confused about (as in your example below), the phases
> show up in the help text, after the default phases, but before site
> and clean.
>
>
I had offered the content as an edit to your answer on SO but the reviewers
felt it was a comment, so instead it is a second answer


> Best,
> John
>
> On Tue, Sep 18, 2012 at 10:34 AM, Stephen Connolly
> <[email protected]> wrote:
> > There are some limits to this... perhaps due to some bugs in how Maven
> > handles this type of thing e.g.
> >
> > This requires Maven 3.0 or newer to work. When you try to use this in
> Maven
> > 2.x you will get a error such as:
> >
> > $ mvn eval
> > [INFO] Scanning for projects...
> > [INFO]
> ------------------------------------------------------------------------
> > [ERROR] BUILD FAILURE
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] Invalid task 'eval': you must specify a valid lifecycle phase, or
> a goal
> > in the format plugin:goal or
> pluginGroupId:pluginArtifactId:pluginVersion:goal
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] For more information, run Maven with the -e switch
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] Total time: < 1 second
> > [INFO] Finished at: Tue Sep 18 15:58:12 IST 2012
> > [INFO] Final Memory: 2M/81M
> > [INFO]
> ------------------------------------------------------------------------
> >
> > At least as of Maven 3.0.4 it does not list these phases in the help text
> > when you invoke Maven without a goal or phase:
> >
> > $ mvn
> > [INFO] Scanning for projects...
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] BUILD FAILURE
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] Total time: 0.224s
> > [INFO] Finished at: Tue Sep 18 16:03:20 IST 2012
> > [INFO] Final Memory: 2M/81M
> > [INFO]
> ------------------------------------------------------------------------
> > [ERROR] No goals have been specified for this build. You must specify a
> valid
> > lifecycle phase or a goal in the format <plugin-prefix>:<goal> or
> > <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>.
> Available
> > lifecycle phases are: validate, initialize, generate-sources,
> process-sources,
> > generate-resources, process-resources, compile, process-classes,
> > generate-test-sources, process-test-sources, generate-test-resources,
> > process-test-resources, test-compile, process-test-classes, test,
> > prepare-package, package, pre-integration-test, integration-test,
> > post-integration-test, verify, install, deploy, pre-clean, clean,
> post-clean,
> > pre-site, site, post-site, site-deploy. -> [Help 1]
> > [ERROR]
> > [ERROR] To see the full stack trace of the errors, re-run Maven with
> > the -e switch.
> > [ERROR] Re-run Maven using the -X switch to enable full debug logging.
> > [ERROR]
> > [ERROR] For more information about the errors and possible solutions,
> > please read the following articles:
> > [ERROR] [Help 1]
> >
> http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException
> >
> > In a multi-module build you can end up screwed.
> >
> > Consider the following two extenions modules:
> > Extension 1
> >
> > <component-set>
> >   <components>
> >     <component>
> >       <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
> >       <role-hint>fancy</role-hint>
> >       <implementation>
> >         org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping
> >       </implementation>
> >     </component>
> >     <component>
> >       <role>org.apache.maven.lifecycle.Lifecycle</role>
> >
> <implementation>org.apache.maven.lifecycle.Lifecycle</implementation>
> >       <role-hint>fancy</role-hint>
> >       <configuration>
> >          <id>fancy</id>
> >          <phases>
> >             <phase>fancy</phase>
> >          </phases>
> >          <default-phases>
> >             <fancy>org.codehaus.mojo:rpm-maven-plugin:version</fancy>
> >          </default-phases>
> >       </configuration>
> >     </component>
> >   </components>
> > </component-set>
> >
> > Extension 2
> >
> > <component-set>
> >   <components>
> >     <component>
> >       <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
> >       <role-hint>poncy</role-hint>
> >       <implementation>
> >         org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping
> >       </implementation>
> >     </component>
> >     <component>
> >       <role>org.apache.maven.lifecycle.Lifecycle</role>
> >
> <implementation>org.apache.maven.lifecycle.Lifecycle</implementation>
> >       <role-hint>poncy</role-hint>
> >       <configuration>
> >          <id>poncy</id>
> >          <phases>
> >             <phase>poncy</phase>
> >             <phase>fancy</phase>
> >          </phases>
> >          <default-phases>
> >
> <poncy>org.apache.maven.plugins:maven-enforcer-plugin:display-info</poncy>
> >
> <fancy>org.codehaus.mojo:build-helper-maven-plugin:parse-version</fancy>
> >          </default-phases>
> >       </configuration>
> >     </component>
> >   </components>
> > </component-set>
> >
> > Parent pom
> >
> > <?xml version="1.0" encoding="utf-8"?>
> > <project xmlns="http://maven.apache.org/POM/4.0.0";
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> >          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> > http://maven.apache.org/maven-v4_0_0.xsd";>
> >   <modelVersion>4.0.0</modelVersion>
> >
> >   <groupId>localdomain.localhost</groupId>
> >   <artifactId>fancy-lifecycle-parent</artifactId>
> >   <version>0.1-SNAPSHOT</version>
> >   <packaging>pom</packaging>
> >
> >   <modules>
> >     <module>poncy-test</module>
> >     <module>fancy-test</module>
> >   </modules>
> >
> > </project>
> >
> > Fancy-test pom
> >
> > <?xml version="1.0" encoding="utf-8"?>
> > <project xmlns="http://maven.apache.org/POM/4.0.0";
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> >          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> > http://maven.apache.org/maven-v4_0_0.xsd";>
> >   <modelVersion>4.0.0</modelVersion>
> >
> >   <groupId>localdomain.localhost</groupId>
> >   <artifactId>fancy-test</artifactId>
> >   <version>0.1-SNAPSHOT</version>
> >   <packaging>fancy</packaging>
> >
> >   <build>
> >     <extensions>
> >       <extension>
> >         <groupId>localdomain.localhost</groupId>
> >         <artifactId>fancy-lifecycle</artifactId>
> >         <version>0.1-SNAPSHOT</version>
> >       </extension>
> >     </extensions>
> >   </build>
> > </project>
> >
> > Poncy-test pom
> >
> > <?xml version="1.0" encoding="utf-8"?>
> > <project xmlns="http://maven.apache.org/POM/4.0.0";
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> >          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> > http://maven.apache.org/maven-v4_0_0.xsd";>
> >   <modelVersion>4.0.0</modelVersion>
> >
> >   <groupId>localdomain.localhost</groupId>
> >   <artifactId>poncy-test</artifactId>
> >   <version>0.1-SNAPSHOT</version>
> >   <packaging>poncy</packaging>
> >
> >   <build>
> >     <extensions>
> >       <extension>
> >         <groupId>localdomain.localhost</groupId>
> >         <artifactId>poncy-lifecycle</artifactId>
> >         <version>0.1-SNAPSHOT</version>
> >       </extension>
> >     </extensions>
> >   </build>
> > </project>
> >
> > Some tests
> >
> > $ mvn -f pom.xml fancy
> > [INFO] Scanning for projects...
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] Reactor Build Order:
> > [INFO]
> > [INFO] poncy-test
> > [INFO] fancy-test
> > [INFO] fancy-lifecycle-parent
> > [INFO]
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] Building poncy-test 0.1-SNAPSHOT
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO]
> > [INFO] --- maven-enforcer-plugin:1.1.1:display-info
> > (default-display-info) @ poncy-test ---
> > [INFO] Maven Version: 3.0.4
> > [INFO] JDK Version: 1.6.0_35 normalized as: 1.6.0-35
> > [INFO] OS Info: Arch: x86_64 Family: mac Name: mac os x Version: 10.8.1
> > [INFO]
> > [INFO] --- build-helper-maven-plugin:1.7:parse-version
> > (default-parse-version) @ poncy-test ---
> > [INFO]
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] Building fancy-test 0.1-SNAPSHOT
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO]
> > [INFO] --- rpm-maven-plugin:2.1-alpha-2:version (default-version) @
> > fancy-test ---
> > [WARNING] rpm version string truncated to 0.1
> > [INFO] setting [rpm.version] property to value [0.1].
> > [INFO] setting [rpm.release] property to value [SNAPSHOT20120918152051].
> > [INFO]
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] Building fancy-lifecycle-parent 0.1-SNAPSHOT
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] Reactor Summary:
> > [INFO]
> > [INFO] poncy-test ........................................ SUCCESS
> [0.727s]
> > [INFO] fancy-test ........................................ SUCCESS
> [0.196s]
> > [INFO] fancy-lifecycle-parent ............................ SUCCESS
> [0.001s]
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] BUILD SUCCESS
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] Total time: 1.152s
> > [INFO] Finished at: Tue Sep 18 16:20:51 IST 2012
> > [INFO] Final Memory: 4M/81M
> > [INFO]
> ------------------------------------------------------------------------
> >
> > This first test is from the parent pom and everything builds just fine.
> > Notice that the two phases (poncyand fancy's executions are invoked for
> the
> > poncy-test module but only one phase (fancy) is invoked for the
> > fancy-test module,
> > as you would expect.
> >
> > Now try the same only with the poncy phase
> >
> > $ mvn poncy
> > [INFO] Scanning for projects...
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] Reactor Build Order:
> > [INFO]
> > [INFO] poncy-test
> > [INFO] fancy-test
> > [INFO] fancy-lifecycle-parent
> > [INFO]
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] Building poncy-test 0.1-SNAPSHOT
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO]
> > [INFO] --- maven-enforcer-plugin:1.1.1:display-info
> > (default-display-info) @ poncy-test ---
> > [INFO] Maven Version: 3.0.4
> > [INFO] JDK Version: 1.6.0_35 normalized as: 1.6.0-35
> > [INFO] OS Info: Arch: x86_64 Family: mac Name: mac os x Version: 10.8.1
> > [INFO]
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] Building fancy-test 0.1-SNAPSHOT
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] Reactor Summary:
> > [INFO]
> > [INFO] poncy-test ........................................ SUCCESS
> [0.588s]
> > [INFO] fancy-test ........................................ FAILURE
> [0.033s]
> > [INFO] fancy-lifecycle-parent ............................ SKIPPED
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] BUILD FAILURE
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] Total time: 0.853s
> > [INFO] Finished at: Tue Sep 18 16:23:27 IST 2012
> > [INFO] Final Memory: 3M/81M
> > [INFO]
> ------------------------------------------------------------------------
> > [ERROR] Unknown lifecycle phase "poncy". You must specify a valid
> > lifecycle phase or a goal in the format <plugin-prefix>:<goal> or
> > <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>.
> > Available lifecycle phases are: validate, initialize,
> > generate-sources, process-sources, generate-resources,
> > process-resources, compile, process-classes, generate-test-sources,
> > process-test-sources, generate-test-resources, process-test-resources,
> > test-compile, process-test-classes, test, prepare-package, package,
> > pre-integration-test, integration-test, post-integration-test, verify,
> > install, deploy, fancy, pre-clean, clean, post-clean, pre-site, site,
> > post-site, site-deploy. -> [Help 1]
> > [ERROR]
> > [ERROR] To see the full stack trace of the errors, re-run Maven with
> > the -e switch.
> > [ERROR] Re-run Maven using the -X switch to enable full debug logging.
> > [ERROR]
> > [ERROR] For more information about the errors and possible solutions,
> > please read the following articles:
> > [ERROR] [Help 1]
> >
> http://cwiki.apache.org/confluence/display/MAVEN/LifecyclePhaseNotFoundException
> >
> > Notice that we now have a build failure because the phase is unknown for
> > the fancy-test module.
> >
> > If we build the parent and poncy-test explicitly all works just fine:
> >
> > $ mvn poncy -pl :fancy-lifecycle-parent,:poncy-test
> > [INFO] Scanning for projects...
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] Reactor Build Order:
> > [INFO]
> > [INFO] poncy-test
> > [INFO] fancy-lifecycle-parent
> > [INFO]
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] Building poncy-test 0.1-SNAPSHOT
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO]
> > [INFO] --- maven-enforcer-plugin:1.1.1:display-info
> > (default-display-info) @ poncy-test ---
> > [INFO] Maven Version: 3.0.4
> > [INFO] JDK Version: 1.6.0_35 normalized as: 1.6.0-35
> > [INFO] OS Info: Arch: x86_64 Family: mac Name: mac os x Version: 10.8.1
> > [INFO]
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] Building fancy-lifecycle-parent 0.1-SNAPSHOT
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] Reactor Summary:
> > [INFO]
> > [INFO] poncy-test ........................................ SUCCESS
> [5.247s]
> > [INFO] fancy-lifecycle-parent ............................ SUCCESS
> [0.001s]
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] BUILD SUCCESS
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] Total time: 5.488s
> > [INFO] Finished at: Tue Sep 18 16:24:45 IST 2012
> > [INFO] Final Memory: 3M/81M
> > [INFO]
> ------------------------------------------------------------------------
> >
> > And finally, on a positive note, if we add a jar packaging module without
> > the extension defined into the mix, all hell does not break loose:
> >
> > $ mvn fancy
> > [INFO] Scanning for projects...
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] Reactor Build Order:
> > [INFO]
> > [INFO] jar-test
> > [INFO] poncy-test
> > [INFO] fancy-test
> > [INFO] fancy-lifecycle-parent
> > [INFO]
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] Building jar-test 0.1-SNAPSHOT
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO]
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] Building poncy-test 0.1-SNAPSHOT
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO]
> > [INFO] --- maven-enforcer-plugin:1.1.1:display-info
> > (default-display-info) @ poncy-test ---
> > [INFO] Maven Version: 3.0.4
> > [INFO] JDK Version: 1.6.0_35 normalized as: 1.6.0-35
> > [INFO] OS Info: Arch: x86_64 Family: mac Name: mac os x Version: 10.8.1
> > [INFO]
> > [INFO] --- build-helper-maven-plugin:1.7:parse-version
> > (default-parse-version) @ poncy-test ---
> > [INFO]
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO] Building fancy-test 0.1-SNAPSHOT
> > [INFO]
> ------------------------------------------------------------------------
> > [INFO]
> > [INFO] --- rpm-maven-plugin:2.1-alpha-2:version (default-version) @
> > fancy-test ---
> > [WARNING] rpm version string truncated to 0.1
> > [INFO] setting [rpm.version] property to value [0.1].
> > [INFO] setting [rpm.release] property to value [SNAPSHOT20120918152733].
> > [INFO]
> >
> >
> > On 17 September 2012 23:52, Manfred Moser <[email protected]> wrote:
> >
> >> Fork the book on github and write the update. Send a pull request and I
> >> will work with your for whatever else is necessary.
> >>
> >> Manfred
> >>
> >>
> >> On Mon, September 17, 2012 3:48 pm, John Riedl wrote:
> >> > And *that* was exactly what I needed.  Thank you very much for your
> >> > help.  It turns out the lifecycle.xml was fine, but I needed *both* a
> >> > LifecycleMapping component *and* a Lifecycle component.  I had
> >> > discovered examples with each separately on the web, but this is the
> >> > first example I've seen with both -- and that's what is needed for
> >> > everything to work.  The working set of components is below.
> >> >
> >> > Note that the example you pointed me to has some duplication that is
> >> > (conveniently) not needed: you can delete the configuration from the
> >> > LifecycleMapping.
> >> >
> >> > In an expression of thanks, I'm willing to write up a replacement for
> >> > the now out-of-date page at
> >> >
> >>
> http://www.sonatype.com/books/mvnref-book/reference/writing-plugins-sect-plugins-lifecycle.html
> >> ;
> >> > does anyone know how such a thing would be contributed?
> >> >
> >> > Thanks again!
> >> > John
> >> >
> >> > <component-set>
> >> >   <components>
> >> >     <component>
> >> >       <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
> >> >       <role-hint>lenskit</role-hint>
> >> >       <implementation>
> >> >       org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping
> >> >       </implementation>
> >> >     </component>
> >> >     <component>
> >> >       <role>org.apache.maven.lifecycle.Lifecycle</role>
> >> >
> >> <implementation>org.apache.maven.lifecycle.Lifecycle</implementation>
> >> >       <role-hint>lenskit</role-hint>
> >> >       <configuration>
> >> >        <id>lenskit</id>
> >> >        <phases>
> >> >           <phase>get-data</phase>
> >> >           <phase>analyze</phase>
> >> >           <phase>eval</phase>
> >> >        </phases>
> >> >        <default-phases>
> >> >           <get-data>org.riedl:hello-lenskit-plugin:greet</get-data>
> >> >           <analyze>org.riedl:hello-lenskit-plugin:greet</analyze>
> >> >           <eval>org.riedl:hello-lenskit-plugin:greet</eval>
> >> >        </default-phases>
> >> >       </configuration>
> >> >     </component>
> >> >   </components>
> >> > </component-set>
> >> >
> >> >
> >> > On Sun, Sep 16, 2012 at 7:42 AM, Benson Margulies <
> [email protected]
> >> >
> >> > wrote:
> >> >> We happen to have an example of this in stock, recently minted.
> >> >>
> >> >>
> >>
> https://svn.apache.org/repos/asf/maven/plugins/trunk/maven-scm-publish-plugin
> >> >>
> >> >> That is, this is a plugin with a custom lifecycle definition and
> custom
> >> >> phases.
> >> >>
> >> >>
> >> >>
> >> >> On Sun, Sep 16, 2012 at 12:00 AM, Barrie Treloar <[email protected]
> >
> >> >> wrote:
> >> >>> On Sun, Sep 16, 2012 at 7:06 AM, John Riedl <[email protected]> wrote:
> >> >>>> Baptiste:
> >> >>>>
> >> >>>> Thanks for the answer.  You're certainly right about needing the
> >> >>>> extensions true line, and I do have that in my pom (below).  Note
> that
> >> >>>> the error message I'm getting gives a complete list of all
> lifecycle
> >> >>>> phases that are legal, and that the list does not include any of
> the
> >> >>>> phases I've tried to define.  Note also that in the pom I ask for
> >> >>>> packaging lenskit.  If I change that to something else, like
> "foo", I
> >> >>>> get an error that foo is an unknown lifecycle.  So: it seems that
> >> >>>> maven is picking up the lifecycle, but NOT changing its list of
> >> >>>> built-in phases.
> >> >>>
> >> >>> Doing this is advanced Maven stuff.
> >> >>> It involves some understanding of plexus which is not well
> documented.
> >> >>>
> >> >>> I'm not sure whether the Maven books at
> >> >>> http://maven.apache.org/articles.html go into that level of
> details.
> >> >>>
> >> >>> I'm sure there are examples out there of how to do this, but I can't
> >> >>> think of any of the top of my head.
> >> >>>
> >> >>> Looking at your stack overflow page I see spaces inside the content
> of
> >> >>> your tags, dont know if that is causing problems.
> >> >>>
> >> >>>
> ---------------------------------------------------------------------
> >> >>> To unsubscribe, e-mail: [email protected]
> >> >>> For additional commands, e-mail: [email protected]
> >> >>>
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: [email protected]
> >> >> For additional commands, e-mail: [email protected]
> >> >>
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: [email protected]
> >> > For additional commands, e-mail: [email protected]
> >> >
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [email protected]
> >> For additional commands, e-mail: [email protected]
> >>
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to