You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Gajo Csaba <cs...@cosylab.com> on 2010/12/01 12:06:53 UTC

Creating a custom lifecycle

Hello,

I'm trying to create a custom lifecycle. In this case, I don't mean 
providing custom classes for one of the defined phases, but redefining 
the phases themselves. For example, the DefaultLifecycleMapping seems to 
support clean, compile, test etc...

How can I, for example, make it so that the phases are deploy, clean, 
compile, install, test? Which component should I override to be able to 
do this?

I see that there are 3 cases where this is done: clean, site and default.

I've created by own class which implements LifecycleMapping. I wrote a 
components.xml and lifecycle.xml for it. When I observe the 
getPhases(String lifecycle) method, I see that the value of "lifecycle" 
is always "default". I'm guessing that I need to define something so 
that this wouldn't be "default", but my own lifecycle, for example 
"apple". How to do this?

Thanks, Csaba



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Creating a custom lifecycle

Posted by Antonio Petrelli <an...@gmail.com>.
2010/12/1 Gajo Csaba <cs...@cosylab.com>:
> I didn't try it yet, but I'll try it now.
>
> I think this will not solve the problem. If you write mvn deploy, you will
> probably have the compile, test etc. phases executed. What I need is, to not
> run any of these phases, but immediately print out "this is not supported"
> and end the execution. The only way to do is, as far as I know, is to create
> my own lifecycle.

Sorry but I don't understand. What kind of project does not need to
compile, test, etc.?
What should "mvn apple" do?

Antonio

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Creating a custom lifecycle

Posted by Gajo Csaba <cs...@cosylab.com>.
Yes, I've created a new packaging. In my test project pom.xml, I now have:

<packaging>apple</packaging>

<build>
<plugins>
<plugin>
<groupId>com.test.phases</groupId>
<artifactId>AppleLifecycle</artifactId>
<extensions>true</extensions>
</plugin>
</plugins>
</build>

The AppleLifecycle project defines the "apple" lifecycle.  However, 
contrary to how custom lifecycles are usually defined, my components.xml 
looks like this:

<plexus>
<components>
<component>
<role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
<role-hint>apple</role-hint>
<implementation>com.test.phases.HelloLifecycle</implementation>
</component>
</components>
</plexus>

The HelloLifecycle is my custom lifecycle, which supports only the 
"compile" phase. So if you write mvn package, it will skip all the 
phases, and execute only "compile".

The lifecycle.xml looks like this:

<lifecycles>
<lifecycle>
<id>apple</id>
</lifecycle>
</lifecycles>

This works, the test project uses my custom lifecycle for building 
itself. However, the compile, test, package etc. goals are still there. 
I want to redefine them.

The problem is, that if I write mvn deploy, it will execute also mvn 
compile (because compile < test < package < install < deploy). What I 
want is, when I write mvn deploy, that it doesn't execute compile. 
Instead, it should just print out a message.

How to do this?

I know that this is possible. For example, the "site" command is outside 
the scope of the default lifecycle. If you write mvn deploy, then the 
"site" phase will not get executed. Also, if you write "site", it will 
not invoke deploy. What I want is, when I write "deploy", that it 
doesn't invoke the test, compile, package etc. phases, but instead print 
out a message.

Csaba


On 1.12.2010 12:48, Tamás Cservenák wrote:
> Not sure what you aiming for, but you could introduce new packaging, and
> that new packaging might introduce completely new lifecycle also.
>
> If you build some "custom" packaging, this would be the best, since it gives
> you freedom to do all what you need in your custom build, but also freedom
> to map whatever you want in there.
>
> Thanks,
> ~t~
>
> On Wed, Dec 1, 2010 at 12:34 PM, Gajo Csaba<cs...@cosylab.com>  wrote:
>
>> I didn't try it yet, but I'll try it now.
>>
>> I think this will not solve the problem. If you write mvn deploy, you will
>> probably have the compile, test etc. phases executed. What I need is, to not
>> run any of these phases, but immediately print out "this is not supported"
>> and end the execution. The only way to do is, as far as I know, is to create
>> my own lifecycle.
>>
>> Csaba
>>
>>
>>
>> On 1.12.2010 12:31, Simone Tripodi wrote:
>>
>>> take a look at the maven deploy plugin configuration[1] and set
>>> <skip>true</skip>
>>> hope this helps
>>> Simo
>>>
>>> [1] http://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html
>>>
>>> http://people.apache.org/~simonetripodi/
>>> http://www.99soft.org/
>>>
>>>
>>>
>>> On Wed, Dec 1, 2010 at 12:18 PM, Gajo Csaba<cs...@cosylab.com>
>>>   wrote:
>>>
>>>> I want to delete the deploy goal. Make it exist as much as "mvn apple"
>>>> does
>>>>
>>>> On 1.12.2010 12:14, Antonio Petrelli wrote:
>>>>
>>>>> It's best to tell us what you want to accomplish.
>>>>> Fighting Maven is always a bad thing.
>>>>>
>>>>> Antonio
>>>>>
>>>>> 2010/12/1 Gajo Csaba<cs...@cosylab.com>:
>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> I'm trying to create a custom lifecycle. In this case, I don't mean
>>>>>> providing custom classes for one of the defined phases, but redefining
>>>>>> the
>>>>>> phases themselves. For example, the DefaultLifecycleMapping seems to
>>>>>> support
>>>>>> clean, compile, test etc...
>>>>>>
>>>>>> How can I, for example, make it so that the phases are deploy, clean,
>>>>>> compile, install, test? Which component should I override to be able to
>>>>>> do
>>>>>> this?
>>>>>>
>>>>>> I see that there are 3 cases where this is done: clean, site and
>>>>>> default.
>>>>>>
>>>>>> I've created by own class which implements LifecycleMapping. I wrote a
>>>>>> components.xml and lifecycle.xml for it. When I observe the
>>>>>> getPhases(String
>>>>>> lifecycle) method, I see that the value of "lifecycle" is always
>>>>>> "default".
>>>>>> I'm guessing that I need to define something so that this wouldn't be
>>>>>> "default", but my own lifecycle, for example "apple". How to do this?
>>>>>>
>>>>>> Thanks, Csaba
>>>>>>
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>>>> For additional commands, e-mail: users-help@maven.apache.org
>>>>>>
>>>>>>
>>>>>>   ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>>> For additional commands, e-mail: users-help@maven.apache.org
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>> For additional commands, e-mail: users-help@maven.apache.org
>>>>
>>>>
>>>>   ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Creating a custom lifecycle

Posted by Tamás Cservenák <ta...@cservenak.net>.
Not sure what you aiming for, but you could introduce new packaging, and
that new packaging might introduce completely new lifecycle also.

If you build some "custom" packaging, this would be the best, since it gives
you freedom to do all what you need in your custom build, but also freedom
to map whatever you want in there.

Thanks,
~t~

On Wed, Dec 1, 2010 at 12:34 PM, Gajo Csaba <cs...@cosylab.com> wrote:

> I didn't try it yet, but I'll try it now.
>
> I think this will not solve the problem. If you write mvn deploy, you will
> probably have the compile, test etc. phases executed. What I need is, to not
> run any of these phases, but immediately print out "this is not supported"
> and end the execution. The only way to do is, as far as I know, is to create
> my own lifecycle.
>
> Csaba
>
>
>
> On 1.12.2010 12:31, Simone Tripodi wrote:
>
>> take a look at the maven deploy plugin configuration[1] and set
>> <skip>true</skip>
>> hope this helps
>> Simo
>>
>> [1] http://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html
>>
>> http://people.apache.org/~simonetripodi/
>> http://www.99soft.org/
>>
>>
>>
>> On Wed, Dec 1, 2010 at 12:18 PM, Gajo Csaba<cs...@cosylab.com>
>>  wrote:
>>
>>> I want to delete the deploy goal. Make it exist as much as "mvn apple"
>>> does
>>>
>>> On 1.12.2010 12:14, Antonio Petrelli wrote:
>>>
>>>> It's best to tell us what you want to accomplish.
>>>> Fighting Maven is always a bad thing.
>>>>
>>>> Antonio
>>>>
>>>> 2010/12/1 Gajo Csaba<cs...@cosylab.com>:
>>>>
>>>>> Hello,
>>>>>
>>>>> I'm trying to create a custom lifecycle. In this case, I don't mean
>>>>> providing custom classes for one of the defined phases, but redefining
>>>>> the
>>>>> phases themselves. For example, the DefaultLifecycleMapping seems to
>>>>> support
>>>>> clean, compile, test etc...
>>>>>
>>>>> How can I, for example, make it so that the phases are deploy, clean,
>>>>> compile, install, test? Which component should I override to be able to
>>>>> do
>>>>> this?
>>>>>
>>>>> I see that there are 3 cases where this is done: clean, site and
>>>>> default.
>>>>>
>>>>> I've created by own class which implements LifecycleMapping. I wrote a
>>>>> components.xml and lifecycle.xml for it. When I observe the
>>>>> getPhases(String
>>>>> lifecycle) method, I see that the value of "lifecycle" is always
>>>>> "default".
>>>>> I'm guessing that I need to define something so that this wouldn't be
>>>>> "default", but my own lifecycle, for example "apple". How to do this?
>>>>>
>>>>> Thanks, Csaba
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>>> For additional commands, e-mail: users-help@maven.apache.org
>>>>>
>>>>>
>>>>>  ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>> For additional commands, e-mail: users-help@maven.apache.org
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>>
>>>
>>>  ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Creating a custom lifecycle

Posted by Gajo Csaba <cs...@cosylab.com>.
I didn't try it yet, but I'll try it now.

I think this will not solve the problem. If you write mvn deploy, you 
will probably have the compile, test etc. phases executed. What I need 
is, to not run any of these phases, but immediately print out "this is 
not supported" and end the execution. The only way to do is, as far as I 
know, is to create my own lifecycle.

Csaba


On 1.12.2010 12:31, Simone Tripodi wrote:
> take a look at the maven deploy plugin configuration[1] and set
> <skip>true</skip>
> hope this helps
> Simo
>
> [1] http://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html
>
> http://people.apache.org/~simonetripodi/
> http://www.99soft.org/
>
>
>
> On Wed, Dec 1, 2010 at 12:18 PM, Gajo Csaba<cs...@cosylab.com>  wrote:
>> I want to delete the deploy goal. Make it exist as much as "mvn apple" does
>>
>> On 1.12.2010 12:14, Antonio Petrelli wrote:
>>> It's best to tell us what you want to accomplish.
>>> Fighting Maven is always a bad thing.
>>>
>>> Antonio
>>>
>>> 2010/12/1 Gajo Csaba<cs...@cosylab.com>:
>>>> Hello,
>>>>
>>>> I'm trying to create a custom lifecycle. In this case, I don't mean
>>>> providing custom classes for one of the defined phases, but redefining
>>>> the
>>>> phases themselves. For example, the DefaultLifecycleMapping seems to
>>>> support
>>>> clean, compile, test etc...
>>>>
>>>> How can I, for example, make it so that the phases are deploy, clean,
>>>> compile, install, test? Which component should I override to be able to
>>>> do
>>>> this?
>>>>
>>>> I see that there are 3 cases where this is done: clean, site and default.
>>>>
>>>> I've created by own class which implements LifecycleMapping. I wrote a
>>>> components.xml and lifecycle.xml for it. When I observe the
>>>> getPhases(String
>>>> lifecycle) method, I see that the value of "lifecycle" is always
>>>> "default".
>>>> I'm guessing that I need to define something so that this wouldn't be
>>>> "default", but my own lifecycle, for example "apple". How to do this?
>>>>
>>>> Thanks, Csaba
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>> For additional commands, e-mail: users-help@maven.apache.org
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Creating a custom lifecycle

Posted by Simone Tripodi <si...@gmail.com>.
take a look at the maven deploy plugin configuration[1] and set
<skip>true</skip>
hope this helps
Simo

[1] http://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html

http://people.apache.org/~simonetripodi/
http://www.99soft.org/



On Wed, Dec 1, 2010 at 12:18 PM, Gajo Csaba <cs...@cosylab.com> wrote:
> I want to delete the deploy goal. Make it exist as much as "mvn apple" does
>
> On 1.12.2010 12:14, Antonio Petrelli wrote:
>>
>> It's best to tell us what you want to accomplish.
>> Fighting Maven is always a bad thing.
>>
>> Antonio
>>
>> 2010/12/1 Gajo Csaba<cs...@cosylab.com>:
>>>
>>> Hello,
>>>
>>> I'm trying to create a custom lifecycle. In this case, I don't mean
>>> providing custom classes for one of the defined phases, but redefining
>>> the
>>> phases themselves. For example, the DefaultLifecycleMapping seems to
>>> support
>>> clean, compile, test etc...
>>>
>>> How can I, for example, make it so that the phases are deploy, clean,
>>> compile, install, test? Which component should I override to be able to
>>> do
>>> this?
>>>
>>> I see that there are 3 cases where this is done: clean, site and default.
>>>
>>> I've created by own class which implements LifecycleMapping. I wrote a
>>> components.xml and lifecycle.xml for it. When I observe the
>>> getPhases(String
>>> lifecycle) method, I see that the value of "lifecycle" is always
>>> "default".
>>> I'm guessing that I need to define something so that this wouldn't be
>>> "default", but my own lifecycle, for example "apple". How to do this?
>>>
>>> Thanks, Csaba
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Creating a custom lifecycle

Posted by Gajo Csaba <cs...@cosylab.com>.
I want to delete the deploy goal. Make it exist as much as "mvn apple" does

On 1.12.2010 12:14, Antonio Petrelli wrote:
> It's best to tell us what you want to accomplish.
> Fighting Maven is always a bad thing.
>
> Antonio
>
> 2010/12/1 Gajo Csaba<cs...@cosylab.com>:
>> Hello,
>>
>> I'm trying to create a custom lifecycle. In this case, I don't mean
>> providing custom classes for one of the defined phases, but redefining the
>> phases themselves. For example, the DefaultLifecycleMapping seems to support
>> clean, compile, test etc...
>>
>> How can I, for example, make it so that the phases are deploy, clean,
>> compile, install, test? Which component should I override to be able to do
>> this?
>>
>> I see that there are 3 cases where this is done: clean, site and default.
>>
>> I've created by own class which implements LifecycleMapping. I wrote a
>> components.xml and lifecycle.xml for it. When I observe the getPhases(String
>> lifecycle) method, I see that the value of "lifecycle" is always "default".
>> I'm guessing that I need to define something so that this wouldn't be
>> "default", but my own lifecycle, for example "apple". How to do this?
>>
>> Thanks, Csaba
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Creating a custom lifecycle

Posted by Antonio Petrelli <an...@gmail.com>.
It's best to tell us what you want to accomplish.
Fighting Maven is always a bad thing.

Antonio

2010/12/1 Gajo Csaba <cs...@cosylab.com>:
> Hello,
>
> I'm trying to create a custom lifecycle. In this case, I don't mean
> providing custom classes for one of the defined phases, but redefining the
> phases themselves. For example, the DefaultLifecycleMapping seems to support
> clean, compile, test etc...
>
> How can I, for example, make it so that the phases are deploy, clean,
> compile, install, test? Which component should I override to be able to do
> this?
>
> I see that there are 3 cases where this is done: clean, site and default.
>
> I've created by own class which implements LifecycleMapping. I wrote a
> components.xml and lifecycle.xml for it. When I observe the getPhases(String
> lifecycle) method, I see that the value of "lifecycle" is always "default".
> I'm guessing that I need to define something so that this wouldn't be
> "default", but my own lifecycle, for example "apple". How to do this?
>
> Thanks, Csaba
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org