You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Pedro Viegas <vi...@gmail.com> on 2007/11/12 03:24:16 UTC

How to create a Mojo that controls an ANT task

Hi there guys,

I am trying to create a Maven plugin that executes a given ANT task inside
it.
My real case is to call the Hibernate Tools task to generate a bunch of ORM
classes and Hibernate mappings.
But I need to make some decisions and have to pass some parameters to the
several Hibernate Tools tasks I need to call depending on some conditions
that I need to analize in a Java Mojo.

Basically I need to:

   1. Create a Mojo with some parameters and do some processing and file
   generation of my own
   2. Call the ANT Hibernate Tools tasks a bunch of times to generate all
   my classes/mapings on several packages for several database schemas
   3. Try to keep it as simple as possible to the end programmer user,
   simply call a Maven plugin and state some configuration files and
   destination package and let the conventioned behavior take charge.

I have created the first part easily by creating a Java Maven Plugin.
The second part I have configured like a maven-ant-plugin addition to the
POM and got it working, but this has to be copied into each of the projects
that need this goal and all the configuration I could pragmatically do have
to be typed repeatedly.
So 1 and 2 are go, 3 is what I can't find any documentation or sample to
help me.

I have seen the example from:
http://maven.apache.org/guides/plugin/guide-ant-plugin-development.html

But this is how to build a maven plugin with ANT. What I need is to build a
maven plugin in Java that can call an ant task, like antrun plugin does but
adding a few more java actions and decisions before and after.

So, how can I use the already running maven java plugin to call the ANT
tasks?
Can I call a plugin inside another plugin? How?
Should I try to extend the maven-antrun-plugin to try to accomplish this?

Thanks in advance,

-- 
Pedro Viegas

------------------------------------------------------------
Walking on water and developing software
from a specification are easy if both are
frozen.
                        - Edward V. Berard

Re: How to create a Mojo that controls an ANT task

Posted by Manos Batsis <ma...@geekologue.com>.
maven-antrun-plugin?

Siegfried Goeschl wrote:
> Hi Pedro,
> 
> I faced a similar task and it took a while to find a plugin invoking ANT 
> within a Maven build - unfortunately I can't remember what plugin I 
> looked at (oehaus?!) but I copy&wasted to code for my Canoo WebTest plugin
> 
> http://people.apache.org/~sgoeschl/download/maven-plugins/
> 
> The code uses an AntExecutor which does the trick
> 
> Cheers,
> 
> Siegfried Goeschl
> 
> 
> Pedro Viegas wrote:
>> Hi there guys,
>>
>> I am trying to create a Maven plugin that executes a given ANT task 
>> inside
>> it.
>> My real case is to call the Hibernate Tools task to generate a bunch 
>> of ORM
>> classes and Hibernate mappings.
>> But I need to make some decisions and have to pass some parameters to the
>> several Hibernate Tools tasks I need to call depending on some conditions
>> that I need to analize in a Java Mojo.
>>
>> Basically I need to:
>>
>>    1. Create a Mojo with some parameters and do some processing and file
>>    generation of my own
>>    2. Call the ANT Hibernate Tools tasks a bunch of times to generate all
>>    my classes/mapings on several packages for several database schemas
>>    3. Try to keep it as simple as possible to the end programmer user,
>>    simply call a Maven plugin and state some configuration files and
>>    destination package and let the conventioned behavior take charge.
>>
>> I have created the first part easily by creating a Java Maven Plugin.
>> The second part I have configured like a maven-ant-plugin addition to the
>> POM and got it working, but this has to be copied into each of the 
>> projects
>> that need this goal and all the configuration I could pragmatically do 
>> have
>> to be typed repeatedly.
>> So 1 and 2 are go, 3 is what I can't find any documentation or sample to
>> help me.
>>
>> I have seen the example from:
>> http://maven.apache.org/guides/plugin/guide-ant-plugin-development.html
>>
>> But this is how to build a maven plugin with ANT. What I need is to 
>> build a
>> maven plugin in Java that can call an ant task, like antrun plugin 
>> does but
>> adding a few more java actions and decisions before and after.
>>
>> So, how can I use the already running maven java plugin to call the ANT
>> tasks?
>> Can I call a plugin inside another plugin? How?
>> Should I try to extend the maven-antrun-plugin to try to accomplish this?
>>
>> Thanks in advance,
>>
>>   
> 
> ---------------------------------------------------------------------
> 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: How to create a Mojo that controls an ANT task

Posted by Siegfried Goeschl <si...@it20one.at>.
Hi Pedro,

I faced a similar task and it took a while to find a plugin invoking ANT 
within a Maven build - unfortunately I can't remember what plugin I 
looked at (oehaus?!) but I copy&wasted to code for my Canoo WebTest plugin

http://people.apache.org/~sgoeschl/download/maven-plugins/

The code uses an AntExecutor which does the trick

Cheers,

Siegfried Goeschl


Pedro Viegas wrote:
> Hi there guys,
>
> I am trying to create a Maven plugin that executes a given ANT task inside
> it.
> My real case is to call the Hibernate Tools task to generate a bunch of ORM
> classes and Hibernate mappings.
> But I need to make some decisions and have to pass some parameters to the
> several Hibernate Tools tasks I need to call depending on some conditions
> that I need to analize in a Java Mojo.
>
> Basically I need to:
>
>    1. Create a Mojo with some parameters and do some processing and file
>    generation of my own
>    2. Call the ANT Hibernate Tools tasks a bunch of times to generate all
>    my classes/mapings on several packages for several database schemas
>    3. Try to keep it as simple as possible to the end programmer user,
>    simply call a Maven plugin and state some configuration files and
>    destination package and let the conventioned behavior take charge.
>
> I have created the first part easily by creating a Java Maven Plugin.
> The second part I have configured like a maven-ant-plugin addition to the
> POM and got it working, but this has to be copied into each of the projects
> that need this goal and all the configuration I could pragmatically do have
> to be typed repeatedly.
> So 1 and 2 are go, 3 is what I can't find any documentation or sample to
> help me.
>
> I have seen the example from:
> http://maven.apache.org/guides/plugin/guide-ant-plugin-development.html
>
> But this is how to build a maven plugin with ANT. What I need is to build a
> maven plugin in Java that can call an ant task, like antrun plugin does but
> adding a few more java actions and decisions before and after.
>
> So, how can I use the already running maven java plugin to call the ANT
> tasks?
> Can I call a plugin inside another plugin? How?
> Should I try to extend the maven-antrun-plugin to try to accomplish this?
>
> Thanks in advance,
>
>   

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


Re: How to create a Mojo that controls an ANT task

Posted by Milos Kleint <mk...@gmail.com>.
i've done something along those lines with the mojo's nbm-maven-plugin. I
call a bunch of ant tasks for building netbeans modules.
https://svn.codehaus.org/mojo/trunk/mojo/nbm-maven-plugin/

Milos

On 11/12/07, Pedro Viegas <vi...@gmail.com> wrote:
>
> Hi there guys,
>
> I am trying to create a Maven plugin that executes a given ANT task inside
> it.
> My real case is to call the Hibernate Tools task to generate a bunch of
> ORM
> classes and Hibernate mappings.
> But I need to make some decisions and have to pass some parameters to the
> several Hibernate Tools tasks I need to call depending on some conditions
> that I need to analize in a Java Mojo.
>
> Basically I need to:
>
>    1. Create a Mojo with some parameters and do some processing and file
>    generation of my own
>    2. Call the ANT Hibernate Tools tasks a bunch of times to generate all
>    my classes/mapings on several packages for several database schemas
>    3. Try to keep it as simple as possible to the end programmer user,
>    simply call a Maven plugin and state some configuration files and
>    destination package and let the conventioned behavior take charge.
>
> I have created the first part easily by creating a Java Maven Plugin.
> The second part I have configured like a maven-ant-plugin addition to the
> POM and got it working, but this has to be copied into each of the
> projects
> that need this goal and all the configuration I could pragmatically do
> have
> to be typed repeatedly.
> So 1 and 2 are go, 3 is what I can't find any documentation or sample to
> help me.
>
> I have seen the example from:
> http://maven.apache.org/guides/plugin/guide-ant-plugin-development.html
>
> But this is how to build a maven plugin with ANT. What I need is to build
> a
> maven plugin in Java that can call an ant task, like antrun plugin does
> but
> adding a few more java actions and decisions before and after.
>
> So, how can I use the already running maven java plugin to call the ANT
> tasks?
> Can I call a plugin inside another plugin? How?
> Should I try to extend the maven-antrun-plugin to try to accomplish this?
>
> Thanks in advance,
>
> --
> Pedro Viegas
>
> ------------------------------------------------------------
> Walking on water and developing software
> from a specification are easy if both are
> frozen.
>                         - Edward V. Berard
>

Re: How to create a Mojo that controls an ANT task

Posted by Pedro Viegas <vi...@gmail.com>.
Sorry! I promised I'd post the results and forgot.
Better late than never.

The project that resulted from this is here:
http://development.digitalis.pt/apache2-default/staging/ormgenerator/index.html

Source can be browsed here...
http://development.digitalis.pt/apache2-default/staging/ormgenerator/xref/index.html

...and downloaded here...
http://development.digitalis.pt/apache2-default/staging/ormgenerator/downloads.html

Regards,



On Tue, Nov 13, 2007 at 1:03 AM, Pedro Viegas <vi...@gmail.com> wrote:

> Yep, good ideia.
>
> Although I need to have this feature in multiple projects. So I could only
> do this if I created a super POM that I would use as parent for all others.
> I think it is best in this scenario to create a custom plugin to get the
> job done with the minimal work to the users possible.
>
> I allready started the implementation and am working on it right now.
> It will decend from the maven-anrrun-plugin AbstractAntMojo class and
> provide the aditional features we need.
> No need for a fork, a simple inheritance will sufice.
>
> Thanks again.
>
> Will post the end resut here for all who care.
>
> Regards,
>
>
> On Nov 12, 2007 7:48 PM, Saloucious <saloucious@gmail.com > wrote:
>
>>
>> If you have multi-projects and a parent, a easier solution, should to add
>> your maven-antrun-plugin to <pluginsMagement/> tag in parent pom.xml.
>>
>> As far as I know you can refer in your children pom to your
>> maven-antrun-plugin without redefine tasks.
>>
>>
>>
>>
>>
>> Pedro Viegas-2 wrote:
>> >
>> > Hi there,
>> >
>> > Thanks a bunch for your responses.
>> > You pointed me in the right direction. I was wishing I could use the
>> > antrun
>> > plugin resources but without having to copy-paste or in other way break
>> > future updates of it.
>> > I'm drilling into the plugin's source right now and will post my result
>> as
>> > soon as I have new information.
>> >
>> > This plugin we're working on at my company will be open-sourced so if
>> > there
>> > is any interest I can post here the link to the project when we finish
>> it.
>> > We have yet to crerate a Maven repository in our server, but even it
>> that
>> > is
>> > not available the Maven Generated site will have all needed information
>> > including the source and package, until we publish the repository.
>> >
>> > Regards,
>> >
>> > On Nov 12, 2007 5:53 PM, Saloucious <sa...@gmail.com> wrote:
>> >
>> >>
>> >> Just an idea
>> >>
>> >> May be you can fork maven-antrun-plugin, and instead of let plexus bind
>> >> tasks attribute, instanciate tasks attribute with an xml file embded in
>>
>> >> you
>> >> plugin artifact
>> >>
>> >> I was just having a look in AntRunMojo class but i think you have to
>> use
>> >> AntTargetConverter
>> >>
>> >> This is just assumptions ...
>> >>
>> >> Please keep me in touch
>> >>
>> >>
>> >> Pedro Viegas-2 wrote:
>> >> >
>> >> > Hi there guys,
>> >> >
>> >> > I am trying to create a Maven plugin that executes a given ANT task
>> >> inside
>> >> > it.
>> >> > My real case is to call the Hibernate Tools task to generate a bunch
>> of
>> >> > ORM
>> >> > classes and Hibernate mappings.
>> >> > But I need to make some decisions and have to pass some parameters to
>>
>> >> the
>> >> > several Hibernate Tools tasks I need to call depending on some
>> >> conditions
>> >> > that I need to analize in a Java Mojo.
>> >> >
>> >> > Basically I need to:
>> >> >
>> >> >    1. Create a Mojo with some parameters and do some processing and
>> >> file
>> >> >    generation of my own
>> >> >    2. Call the ANT Hibernate Tools tasks a bunch of times to generate
>>
>> >> all
>> >> >    my classes/mapings on several packages for several database
>> schemas
>> >> >    3. Try to keep it as simple as possible to the end programmer
>> user,
>> >> >    simply call a Maven plugin and state some configuration files and
>> >> >    destination package and let the conventioned behavior take charge.
>> >> >
>> >> > I have created the first part easily by creating a Java Maven Plugin.
>> >> > The second part I have configured like a maven-ant-plugin addition to
>>
>> >> the
>> >> > POM and got it working, but this has to be copied into each of the
>> >> > projects
>> >> > that need this goal and all the configuration I could pragmatically
>> do
>> >> > have
>> >> > to be typed repeatedly.
>> >> > So 1 and 2 are go, 3 is what I can't find any documentation or sample
>> >> to
>> >> > help me.
>> >> >
>> >> > I have seen the example from:
>> >> >
>> http://maven.apache.org/guides/plugin/guide-ant-plugin-development.html
>> >> >
>> >> > But this is how to build a maven plugin with ANT. What I need is to
>> >> build
>> >> > a
>> >> > maven plugin in Java that can call an ant task, like antrun plugin
>> does
>> >> > but
>> >> > adding a few more java actions and decisions before and after.
>> >> >
>> >> > So, how can I use the already running maven java plugin to call the
>> ANT
>> >> > tasks?
>> >> > Can I call a plugin inside another plugin? How?
>> >> > Should I try to extend the maven-antrun-plugin to try to accomplish
>> >> this?
>> >> >
>> >> > Thanks in advance,
>> >> >
>> >> > --
>> >> > Pedro Viegas
>> >> >
>> >> > ------------------------------------------------------------
>> >> > Walking on water and developing software
>> >> > from a specification are easy if both are
>> >> > frozen.
>> >> >                         - Edward V. Berard
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >> http://www.nabble.com/How-to-create-a-Mojo-that-controls-an-ANT-task-tf4788523s177.html#a13710554
>>
>> >> Sent from the Maven - Users mailing list archive at Nabble.com<http://nabble.com/>
>> .
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> >> For additional commands, e-mail: users-help@maven.apache.org
>> >>
>> >>
>> >
>> >
>> > --
>> > Pedro Viegas
>> >
>> > ------------------------------------------------------------
>> > Walking on water and developing software
>> > from a specification are easy if both are
>> > frozen.
>> >                         - Edward V. Berard
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-create-a-Mojo-that-controls-an-ANT-task-tf4788523s177.html#a13712774
>>  Sent from the Maven - Users mailing list archive at Nabble.com<http://nabble.com/>
>> .
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>
>
> --
>  Pedro Viegas
>
> ------------------------------------------------------------
> Walking on water and developing software
> from a specification are easy if both are
> frozen.
>                         - Edward V. Berard
>



-- 
Pedro Viegas

------------------------------------------------------------
Walking on water and developing software
from a specification are easy if both are
frozen.
- Edward V. Berard

Re: How to create a Mojo that controls an ANT task

Posted by Saloucious <sa...@gmail.com>.
Yes, don't exactly know why I have said "fork" ....



Pedro Viegas-2 wrote:
> 
> Yep, good ideia.
> 
> Although I need to have this feature in multiple projects. So I could only
> do this if I created a super POM that I would use as parent for all
> others.
> I think it is best in this scenario to create a custom plugin to get the
> job
> done with the minimal work to the users possible.
> 
> I allready started the implementation and am working on it right now.
> It will decend from the maven-anrrun-plugin AbstractAntMojo class and
> provide the aditional features we need.
> No need for a fork, a simple inheritance will sufice.
> 
> Thanks again.
> 
> Will post the end resut here for all who care.
> 
> Regards,
> 
> On Nov 12, 2007 7:48 PM, Saloucious <sa...@gmail.com> wrote:
> 
>>
>> If you have multi-projects and a parent, a easier solution, should to add
>> your maven-antrun-plugin to <pluginsMagement/> tag in parent pom.xml.
>>
>> As far as I know you can refer in your children pom to your
>> maven-antrun-plugin without redefine tasks.
>>
>>
>>
>>
>>
>> Pedro Viegas-2 wrote:
>> >
>> > Hi there,
>> >
>> > Thanks a bunch for your responses.
>> > You pointed me in the right direction. I was wishing I could use the
>> > antrun
>> > plugin resources but without having to copy-paste or in other way break
>> > future updates of it.
>> > I'm drilling into the plugin's source right now and will post my result
>> as
>> > soon as I have new information.
>> >
>> > This plugin we're working on at my company will be open-sourced so if
>> > there
>> > is any interest I can post here the link to the project when we finish
>> it.
>> > We have yet to crerate a Maven repository in our server, but even it
>> that
>> > is
>> > not available the Maven Generated site will have all needed information
>> > including the source and package, until we publish the repository.
>> >
>> > Regards,
>> >
>> > On Nov 12, 2007 5:53 PM, Saloucious <sa...@gmail.com> wrote:
>> >
>> >>
>> >> Just an idea
>> >>
>> >> May be you can fork maven-antrun-plugin, and instead of let plexus
>> bind
>> >> tasks attribute, instanciate tasks attribute with an xml file embded
>> in
>> >> you
>> >> plugin artifact
>> >>
>> >> I was just having a look in AntRunMojo class but i think you have to
>> use
>> >> AntTargetConverter
>> >>
>> >> This is just assumptions ...
>> >>
>> >> Please keep me in touch
>> >>
>> >>
>> >> Pedro Viegas-2 wrote:
>> >> >
>> >> > Hi there guys,
>> >> >
>> >> > I am trying to create a Maven plugin that executes a given ANT task
>> >> inside
>> >> > it.
>> >> > My real case is to call the Hibernate Tools task to generate a bunch
>> of
>> >> > ORM
>> >> > classes and Hibernate mappings.
>> >> > But I need to make some decisions and have to pass some parameters
>> to
>> >> the
>> >> > several Hibernate Tools tasks I need to call depending on some
>> >> conditions
>> >> > that I need to analize in a Java Mojo.
>> >> >
>> >> > Basically I need to:
>> >> >
>> >> >    1. Create a Mojo with some parameters and do some processing and
>> >> file
>> >> >    generation of my own
>> >> >    2. Call the ANT Hibernate Tools tasks a bunch of times to
>> generate
>> >> all
>> >> >    my classes/mapings on several packages for several database
>> schemas
>> >> >    3. Try to keep it as simple as possible to the end programmer
>> user,
>> >> >    simply call a Maven plugin and state some configuration files and
>> >> >    destination package and let the conventioned behavior take
>> charge.
>> >> >
>> >> > I have created the first part easily by creating a Java Maven
>> Plugin.
>> >> > The second part I have configured like a maven-ant-plugin addition
>> to
>> >> the
>> >> > POM and got it working, but this has to be copied into each of the
>> >> > projects
>> >> > that need this goal and all the configuration I could pragmatically
>> do
>> >> > have
>> >> > to be typed repeatedly.
>> >> > So 1 and 2 are go, 3 is what I can't find any documentation or
>> sample
>> >> to
>> >> > help me.
>> >> >
>> >> > I have seen the example from:
>> >> >
>> http://maven.apache.org/guides/plugin/guide-ant-plugin-development.html
>> >> >
>> >> > But this is how to build a maven plugin with ANT. What I need is to
>> >> build
>> >> > a
>> >> > maven plugin in Java that can call an ant task, like antrun plugin
>> does
>> >> > but
>> >> > adding a few more java actions and decisions before and after.
>> >> >
>> >> > So, how can I use the already running maven java plugin to call the
>> ANT
>> >> > tasks?
>> >> > Can I call a plugin inside another plugin? How?
>> >> > Should I try to extend the maven-antrun-plugin to try to accomplish
>> >> this?
>> >> >
>> >> > Thanks in advance,
>> >> >
>> >> > --
>> >> > Pedro Viegas
>> >> >
>> >> > ------------------------------------------------------------
>> >> > Walking on water and developing software
>> >> > from a specification are easy if both are
>> >> > frozen.
>> >> >                         - Edward V. Berard
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/How-to-create-a-Mojo-that-controls-an-ANT-task-tf4788523s177.html#a13710554
>> >> Sent from the Maven - Users mailing list archive at Nabble.com.
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> >> For additional commands, e-mail: users-help@maven.apache.org
>> >>
>> >>
>> >
>> >
>> > --
>> > Pedro Viegas
>> >
>> > ------------------------------------------------------------
>> > Walking on water and developing software
>> > from a specification are easy if both are
>> > frozen.
>> >                         - Edward V. Berard
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-create-a-Mojo-that-controls-an-ANT-task-tf4788523s177.html#a13712774
>> Sent from the Maven - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
> 
> 
> -- 
> Pedro Viegas
> 
> ------------------------------------------------------------
> Walking on water and developing software
> from a specification are easy if both are
> frozen.
>                         - Edward V. Berard
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-create-a-Mojo-that-controls-an-ANT-task-tf4788523s177.html#a13721950
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: How to create a Mojo that controls an ANT task

Posted by Pedro Viegas <vi...@gmail.com>.
Yep, good ideia.

Although I need to have this feature in multiple projects. So I could only
do this if I created a super POM that I would use as parent for all others.
I think it is best in this scenario to create a custom plugin to get the job
done with the minimal work to the users possible.

I allready started the implementation and am working on it right now.
It will decend from the maven-anrrun-plugin AbstractAntMojo class and
provide the aditional features we need.
No need for a fork, a simple inheritance will sufice.

Thanks again.

Will post the end resut here for all who care.

Regards,

On Nov 12, 2007 7:48 PM, Saloucious <sa...@gmail.com> wrote:

>
> If you have multi-projects and a parent, a easier solution, should to add
> your maven-antrun-plugin to <pluginsMagement/> tag in parent pom.xml.
>
> As far as I know you can refer in your children pom to your
> maven-antrun-plugin without redefine tasks.
>
>
>
>
>
> Pedro Viegas-2 wrote:
> >
> > Hi there,
> >
> > Thanks a bunch for your responses.
> > You pointed me in the right direction. I was wishing I could use the
> > antrun
> > plugin resources but without having to copy-paste or in other way break
> > future updates of it.
> > I'm drilling into the plugin's source right now and will post my result
> as
> > soon as I have new information.
> >
> > This plugin we're working on at my company will be open-sourced so if
> > there
> > is any interest I can post here the link to the project when we finish
> it.
> > We have yet to crerate a Maven repository in our server, but even it
> that
> > is
> > not available the Maven Generated site will have all needed information
> > including the source and package, until we publish the repository.
> >
> > Regards,
> >
> > On Nov 12, 2007 5:53 PM, Saloucious <sa...@gmail.com> wrote:
> >
> >>
> >> Just an idea
> >>
> >> May be you can fork maven-antrun-plugin, and instead of let plexus bind
> >> tasks attribute, instanciate tasks attribute with an xml file embded in
> >> you
> >> plugin artifact
> >>
> >> I was just having a look in AntRunMojo class but i think you have to
> use
> >> AntTargetConverter
> >>
> >> This is just assumptions ...
> >>
> >> Please keep me in touch
> >>
> >>
> >> Pedro Viegas-2 wrote:
> >> >
> >> > Hi there guys,
> >> >
> >> > I am trying to create a Maven plugin that executes a given ANT task
> >> inside
> >> > it.
> >> > My real case is to call the Hibernate Tools task to generate a bunch
> of
> >> > ORM
> >> > classes and Hibernate mappings.
> >> > But I need to make some decisions and have to pass some parameters to
> >> the
> >> > several Hibernate Tools tasks I need to call depending on some
> >> conditions
> >> > that I need to analize in a Java Mojo.
> >> >
> >> > Basically I need to:
> >> >
> >> >    1. Create a Mojo with some parameters and do some processing and
> >> file
> >> >    generation of my own
> >> >    2. Call the ANT Hibernate Tools tasks a bunch of times to generate
> >> all
> >> >    my classes/mapings on several packages for several database
> schemas
> >> >    3. Try to keep it as simple as possible to the end programmer
> user,
> >> >    simply call a Maven plugin and state some configuration files and
> >> >    destination package and let the conventioned behavior take charge.
> >> >
> >> > I have created the first part easily by creating a Java Maven Plugin.
> >> > The second part I have configured like a maven-ant-plugin addition to
> >> the
> >> > POM and got it working, but this has to be copied into each of the
> >> > projects
> >> > that need this goal and all the configuration I could pragmatically
> do
> >> > have
> >> > to be typed repeatedly.
> >> > So 1 and 2 are go, 3 is what I can't find any documentation or sample
> >> to
> >> > help me.
> >> >
> >> > I have seen the example from:
> >> >
> http://maven.apache.org/guides/plugin/guide-ant-plugin-development.html
> >> >
> >> > But this is how to build a maven plugin with ANT. What I need is to
> >> build
> >> > a
> >> > maven plugin in Java that can call an ant task, like antrun plugin
> does
> >> > but
> >> > adding a few more java actions and decisions before and after.
> >> >
> >> > So, how can I use the already running maven java plugin to call the
> ANT
> >> > tasks?
> >> > Can I call a plugin inside another plugin? How?
> >> > Should I try to extend the maven-antrun-plugin to try to accomplish
> >> this?
> >> >
> >> > Thanks in advance,
> >> >
> >> > --
> >> > Pedro Viegas
> >> >
> >> > ------------------------------------------------------------
> >> > Walking on water and developing software
> >> > from a specification are easy if both are
> >> > frozen.
> >> >                         - Edward V. Berard
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/How-to-create-a-Mojo-that-controls-an-ANT-task-tf4788523s177.html#a13710554
> >> Sent from the Maven - Users mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >> For additional commands, e-mail: users-help@maven.apache.org
> >>
> >>
> >
> >
> > --
> > Pedro Viegas
> >
> > ------------------------------------------------------------
> > Walking on water and developing software
> > from a specification are easy if both are
> > frozen.
> >                         - Edward V. Berard
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/How-to-create-a-Mojo-that-controls-an-ANT-task-tf4788523s177.html#a13712774
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 
Pedro Viegas

------------------------------------------------------------
Walking on water and developing software
from a specification are easy if both are
frozen.
                        - Edward V. Berard

Re: How to create a Mojo that controls an ANT task

Posted by Saloucious <sa...@gmail.com>.
If you have multi-projects and a parent, a easier solution, should to add
your maven-antrun-plugin to <pluginsMagement/> tag in parent pom.xml.

As far as I know you can refer in your children pom to your 
maven-antrun-plugin without redefine tasks.





Pedro Viegas-2 wrote:
> 
> Hi there,
> 
> Thanks a bunch for your responses.
> You pointed me in the right direction. I was wishing I could use the
> antrun
> plugin resources but without having to copy-paste or in other way break
> future updates of it.
> I'm drilling into the plugin's source right now and will post my result as
> soon as I have new information.
> 
> This plugin we're working on at my company will be open-sourced so if
> there
> is any interest I can post here the link to the project when we finish it.
> We have yet to crerate a Maven repository in our server, but even it that
> is
> not available the Maven Generated site will have all needed information
> including the source and package, until we publish the repository.
> 
> Regards,
> 
> On Nov 12, 2007 5:53 PM, Saloucious <sa...@gmail.com> wrote:
> 
>>
>> Just an idea
>>
>> May be you can fork maven-antrun-plugin, and instead of let plexus bind
>> tasks attribute, instanciate tasks attribute with an xml file embded in
>> you
>> plugin artifact
>>
>> I was just having a look in AntRunMojo class but i think you have to use
>> AntTargetConverter
>>
>> This is just assumptions ...
>>
>> Please keep me in touch
>>
>>
>> Pedro Viegas-2 wrote:
>> >
>> > Hi there guys,
>> >
>> > I am trying to create a Maven plugin that executes a given ANT task
>> inside
>> > it.
>> > My real case is to call the Hibernate Tools task to generate a bunch of
>> > ORM
>> > classes and Hibernate mappings.
>> > But I need to make some decisions and have to pass some parameters to
>> the
>> > several Hibernate Tools tasks I need to call depending on some
>> conditions
>> > that I need to analize in a Java Mojo.
>> >
>> > Basically I need to:
>> >
>> >    1. Create a Mojo with some parameters and do some processing and
>> file
>> >    generation of my own
>> >    2. Call the ANT Hibernate Tools tasks a bunch of times to generate
>> all
>> >    my classes/mapings on several packages for several database schemas
>> >    3. Try to keep it as simple as possible to the end programmer user,
>> >    simply call a Maven plugin and state some configuration files and
>> >    destination package and let the conventioned behavior take charge.
>> >
>> > I have created the first part easily by creating a Java Maven Plugin.
>> > The second part I have configured like a maven-ant-plugin addition to
>> the
>> > POM and got it working, but this has to be copied into each of the
>> > projects
>> > that need this goal and all the configuration I could pragmatically do
>> > have
>> > to be typed repeatedly.
>> > So 1 and 2 are go, 3 is what I can't find any documentation or sample
>> to
>> > help me.
>> >
>> > I have seen the example from:
>> > http://maven.apache.org/guides/plugin/guide-ant-plugin-development.html
>> >
>> > But this is how to build a maven plugin with ANT. What I need is to
>> build
>> > a
>> > maven plugin in Java that can call an ant task, like antrun plugin does
>> > but
>> > adding a few more java actions and decisions before and after.
>> >
>> > So, how can I use the already running maven java plugin to call the ANT
>> > tasks?
>> > Can I call a plugin inside another plugin? How?
>> > Should I try to extend the maven-antrun-plugin to try to accomplish
>> this?
>> >
>> > Thanks in advance,
>> >
>> > --
>> > Pedro Viegas
>> >
>> > ------------------------------------------------------------
>> > Walking on water and developing software
>> > from a specification are easy if both are
>> > frozen.
>> >                         - Edward V. Berard
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-create-a-Mojo-that-controls-an-ANT-task-tf4788523s177.html#a13710554
>> Sent from the Maven - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
> 
> 
> -- 
> Pedro Viegas
> 
> ------------------------------------------------------------
> Walking on water and developing software
> from a specification are easy if both are
> frozen.
>                         - Edward V. Berard
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-create-a-Mojo-that-controls-an-ANT-task-tf4788523s177.html#a13712774
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: How to create a Mojo that controls an ANT task

Posted by Pedro Viegas <vi...@gmail.com>.
Hi there,

Thanks a bunch for your responses.
You pointed me in the right direction. I was wishing I could use the antrun
plugin resources but without having to copy-paste or in other way break
future updates of it.
I'm drilling into the plugin's source right now and will post my result as
soon as I have new information.

This plugin we're working on at my company will be open-sourced so if there
is any interest I can post here the link to the project when we finish it.
We have yet to crerate a Maven repository in our server, but even it that is
not available the Maven Generated site will have all needed information
including the source and package, until we publish the repository.

Regards,

On Nov 12, 2007 5:53 PM, Saloucious <sa...@gmail.com> wrote:

>
> Just an idea
>
> May be you can fork maven-antrun-plugin, and instead of let plexus bind
> tasks attribute, instanciate tasks attribute with an xml file embded in
> you
> plugin artifact
>
> I was just having a look in AntRunMojo class but i think you have to use
> AntTargetConverter
>
> This is just assumptions ...
>
> Please keep me in touch
>
>
> Pedro Viegas-2 wrote:
> >
> > Hi there guys,
> >
> > I am trying to create a Maven plugin that executes a given ANT task
> inside
> > it.
> > My real case is to call the Hibernate Tools task to generate a bunch of
> > ORM
> > classes and Hibernate mappings.
> > But I need to make some decisions and have to pass some parameters to
> the
> > several Hibernate Tools tasks I need to call depending on some
> conditions
> > that I need to analize in a Java Mojo.
> >
> > Basically I need to:
> >
> >    1. Create a Mojo with some parameters and do some processing and file
> >    generation of my own
> >    2. Call the ANT Hibernate Tools tasks a bunch of times to generate
> all
> >    my classes/mapings on several packages for several database schemas
> >    3. Try to keep it as simple as possible to the end programmer user,
> >    simply call a Maven plugin and state some configuration files and
> >    destination package and let the conventioned behavior take charge.
> >
> > I have created the first part easily by creating a Java Maven Plugin.
> > The second part I have configured like a maven-ant-plugin addition to
> the
> > POM and got it working, but this has to be copied into each of the
> > projects
> > that need this goal and all the configuration I could pragmatically do
> > have
> > to be typed repeatedly.
> > So 1 and 2 are go, 3 is what I can't find any documentation or sample to
> > help me.
> >
> > I have seen the example from:
> > http://maven.apache.org/guides/plugin/guide-ant-plugin-development.html
> >
> > But this is how to build a maven plugin with ANT. What I need is to
> build
> > a
> > maven plugin in Java that can call an ant task, like antrun plugin does
> > but
> > adding a few more java actions and decisions before and after.
> >
> > So, how can I use the already running maven java plugin to call the ANT
> > tasks?
> > Can I call a plugin inside another plugin? How?
> > Should I try to extend the maven-antrun-plugin to try to accomplish
> this?
> >
> > Thanks in advance,
> >
> > --
> > Pedro Viegas
> >
> > ------------------------------------------------------------
> > Walking on water and developing software
> > from a specification are easy if both are
> > frozen.
> >                         - Edward V. Berard
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/How-to-create-a-Mojo-that-controls-an-ANT-task-tf4788523s177.html#a13710554
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 
Pedro Viegas

------------------------------------------------------------
Walking on water and developing software
from a specification are easy if both are
frozen.
                        - Edward V. Berard

Re: How to create a Mojo that controls an ANT task

Posted by Saloucious <sa...@gmail.com>.
Just an idea

May be you can fork maven-antrun-plugin, and instead of let plexus bind
tasks attribute, instanciate tasks attribute with an xml file embded in you
plugin artifact

I was just having a look in AntRunMojo class but i think you have to use
AntTargetConverter 

This is just assumptions ...

Please keep me in touch


Pedro Viegas-2 wrote:
> 
> Hi there guys,
> 
> I am trying to create a Maven plugin that executes a given ANT task inside
> it.
> My real case is to call the Hibernate Tools task to generate a bunch of
> ORM
> classes and Hibernate mappings.
> But I need to make some decisions and have to pass some parameters to the
> several Hibernate Tools tasks I need to call depending on some conditions
> that I need to analize in a Java Mojo.
> 
> Basically I need to:
> 
>    1. Create a Mojo with some parameters and do some processing and file
>    generation of my own
>    2. Call the ANT Hibernate Tools tasks a bunch of times to generate all
>    my classes/mapings on several packages for several database schemas
>    3. Try to keep it as simple as possible to the end programmer user,
>    simply call a Maven plugin and state some configuration files and
>    destination package and let the conventioned behavior take charge.
> 
> I have created the first part easily by creating a Java Maven Plugin.
> The second part I have configured like a maven-ant-plugin addition to the
> POM and got it working, but this has to be copied into each of the
> projects
> that need this goal and all the configuration I could pragmatically do
> have
> to be typed repeatedly.
> So 1 and 2 are go, 3 is what I can't find any documentation or sample to
> help me.
> 
> I have seen the example from:
> http://maven.apache.org/guides/plugin/guide-ant-plugin-development.html
> 
> But this is how to build a maven plugin with ANT. What I need is to build
> a
> maven plugin in Java that can call an ant task, like antrun plugin does
> but
> adding a few more java actions and decisions before and after.
> 
> So, how can I use the already running maven java plugin to call the ANT
> tasks?
> Can I call a plugin inside another plugin? How?
> Should I try to extend the maven-antrun-plugin to try to accomplish this?
> 
> Thanks in advance,
> 
> -- 
> Pedro Viegas
> 
> ------------------------------------------------------------
> Walking on water and developing software
> from a specification are easy if both are
> frozen.
>                         - Edward V. Berard
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-create-a-Mojo-that-controls-an-ANT-task-tf4788523s177.html#a13710554
Sent from the Maven - Users mailing list archive at Nabble.com.


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