You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by hibikijoji <to...@atlassian.com> on 2006/07/20 09:50:52 UTC

[m2] Calling goals outside a plugin

To all,

I am currently migrating from the Maven 1 to the Maven 2 build system.
Here's the scenario:

In maven 1, I have goals in maven.xml that has a prereq attribute. For
argument's sake, let's say its:

<goal name="foo:bar"
          prereqs="clean, goal1, goal2">
<!-- insert some ant script code here -->
</goal>

If goal1 is specified within the plugin whereas goal2 isnt, What is the
equivalent in implementing this in maven 2?



-- 
View this message in context: http://www.nabble.com/-m2--Calling-goals-outside-a-plugin-tf1970783.html#a5410304
Sent from the Maven - Users forum at Nabble.com.


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


Re: [m2] Calling goals outside a plugin

Posted by Tony Truong <to...@atlassian.com>.

dcabasson wrote:
> 
> I guess you can't do that out of the box in Maven 2.
> 
> Executing maven foo:bar, is equivalent to calling the foo plugin with the
> bar mojo. So I guess you would have to create a scripting (ant) plugin.
> That's not that difficult, and it's well documented here:
> http://maven.apache.org/guides/plugin/guide-ant-plugin-development.html
> 
> Good luck!
> 
> Denis.
> 
> 

Thanks for replying

I have had a look at those and can already make simple ant scripts. What I
want though, is to be able to invoke mojos from other targets. 

To give a better example:

I have plugin A (Ant Script) and plugin B (Unknown). 
plugin A has 'target1', plugin B has 'target2'.
In the middle of 'target1', I want it to invoke 'target2'

If there's a java way of implementing this, that would also be ideal.


-- 
View this message in context: http://www.nabble.com/-m2--Calling-goals-outside-a-plugin-tf1970783.html#a5463364
Sent from the Maven - Users forum at Nabble.com.


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


Re: [m2] Calling goals outside a plugin

Posted by dcabasson <de...@insee.fr>.

Tony Truong wrote:
> 
>>mvn foo:bar
> ...
> [INFO] [clean:clean]
> ...
> [INFO] [goal1:goal1]
> ...
> [INFO] [goal2:goal2]
> ...
> [INFO] [goal3:goal3]
> ...
> 
> Is it possible for m2 to do this? If so, how?
> 

I guess you can't do that out of the box in Maven 2.

Executing maven foo:bar, is equivalent to calling the foo plugin with the
bar mojo. So I guess you would have to create a scripting (ant) plugin.
That's not that difficult, and it's well documented here:
http://maven.apache.org/guides/plugin/guide-ant-plugin-development.html

Good luck!

Denis.

-- 
View this message in context: http://www.nabble.com/-m2--Calling-goals-outside-a-plugin-tf1970783.html#a5462881
Sent from the Maven - Users forum at Nabble.com.


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


Re: [m2] Calling goals outside a plugin

Posted by hibikijoji <to...@atlassian.com>.
I understand what you're saying. At the moment, I do not want to bind the ant
plugin to a build lifecycle. I want the plugin to be a standalone execution.

For instance, in prompt i want to do this:

>mvn foo:bar
...
[INFO] [clean:clean]
...
[INFO] [goal1:goal1]
...
[INFO] [goal2:goal2]
...
[INFO] [goal2:goal2]
...
[INFO] [foo:bar]

Is it possible for m2 to do this? If so, how?
-- 
View this message in context: http://www.nabble.com/-m2--Calling-goals-outside-a-plugin-tf1970783.html#a5461121
Sent from the Maven - Users forum at Nabble.com.


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


Re: [m2] Calling goals outside a plugin

Posted by dcabasson <de...@insee.fr>.
Hi,

When using maven 2, you have to stick to a pretty standard lifecycle (of
course, you could change it, but that wouldn't be a good idea).

What you generally do is bind an ant target to a lifecycle phase.

So for example, you can bind your goal1 ant target to the generate-source
phase, and your goal2 ant target to the package phase (or whatever,
depending on what your goals are).
And Maven will make sure everything has been going fine until the package
phase, including your goal1 ant target.

So, to sum it up, there is no general answer to your question. It
depends.... But most of the time, maven 2 solution is far simpler that what
you're trying to maintain in your maven1/ant targets.

Be sure to read the M2 FAQ for Maven 1 users:
http://maven.apache.org/maven1.html

Denis


hibikijoji wrote:
> 
> To all,
> 
> I am currently migrating from the Maven 1 to the Maven 2 build system.
> Here's the scenario:
> 
> In maven 1, I have goals in maven.xml that has a prereq attribute. For
> argument's sake, let's say its:
> 
> <goal name="foo:bar"
>           prereqs="clean, goal1, goal2">
> <!-- insert some ant script code here -->
> </goal>
> 
> If goal1 is specified within the plugin whereas goal2 isnt, What is the
> equivalent in implementing this in maven 2?
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-m2--Calling-goals-outside-a-plugin-tf1970783.html#a5417037
Sent from the Maven - Users forum at Nabble.com.


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