You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Wendell Beckwith <wb...@gmail.com> on 2005/09/07 13:22:59 UTC

[m2] How to invoke Ant's Java task without an ant file?

I'm now trying to write a maven 2 plugin to execute a 2rd party's tools 
command line class. The class is written is java. The tool also has an ant 
task which just uses the Java task in ant to invoke the command line tool in 
a forked jvm. Does m2 already provide such functionality and I just haven 
seen it? Or barring that, can I add a dependency on a set of plugins that 
will allow my plugn to instantiate the the ant Java task, configure it and 
then call its execute() method.

I'm trying to avoid having end users create an additional build.xml, instead 
I'd rather they just configure my plugin in the pom, and I can internally 
configure the ant Java task and invoke it.

Wb

Re: [m2] How to invoke Ant's Java task without an ant file?

Posted by Wendell Beckwith <wb...@gmail.com>.
I would like to use the 1st option however I am unsure of how to configure 
the setup. The 3rd part ant task has code like the following:

if (projectFile == null)
throw new BuildException("missing required attribute 'projectFile'");
Java javaTask = (Java) getProject().createTask("java");
// set the properties on the Java task here
int returnValue = javaTask.executeJava();

The rest of the code is just getters and setters plus a few utility methods 
which ultimately end up forwarding the properties settings to the new Java 
task. From the above I gather that I need to have an ant Project instance to 
create the Java task from, is this true and if so is there an example of how 
to do this?

Wb


So if I was to use option one, would I just add a dependency to my plugin 
for ant-1.6.5



On 9/7/05, dan tran <da...@gmail.com> wrote:
> 
> Hi Wendell,
>  You have 3 options:
>   - invoke ant task directly within your mojo by setting up the neccesary 
> dependencies
>  then call the ant task class' execute method.
>   - Invoke the maven-executor-plugin, a generic mojo to invoke any java's 
> main method. 
>  It is still in the sanbox of at http://mojo.codehause.com
>   - I also have maven-exec-plugin, still in my local diskspace, which can 
> invoke any 
>  native executable. I have not proposed to check it into mojo.codehaus.com<http://mojo.codehaus.com>'s 
> sanbox
>  yet, since i dont see a demand for it yet. 
>  -D
>  On 9/7/05, Wendell Beckwith <wb...@gmail.com> wrote: 
> > 
> > I'm now trying to write a maven 2 plugin to execute a 2rd party's tools
> > command line class. The class is written is java. The tool also has an 
> > ant 
> > task which just uses the Java task in ant to invoke the command line 
> > tool in
> > a forked jvm. Does m2 already provide such functionality and I just 
> > haven
> > seen it? Or barring that, can I add a dependency on a set of plugins 
> > that 
> > will allow my plugn to instantiate the the ant Java task, configure it 
> > and
> > then call its execute() method.
> > 
> > I'm trying to avoid having end users create an additional build.xml, 
> > instead
> > I'd rather they just configure my plugin in the pom, and I can 
> > internally 
> > configure the ant Java task and invoke it.
> > 
> > Wb
> > 
> > 
>

Re: [m2] How to invoke Ant's Java task without an ant file?

Posted by Wendell Beckwith <wb...@gmail.com>.
Option 4 would be nice, however the 3rd party command line is more complex 
than I want to expose to most of the end users otherwise they can fubar 
their setup. Thus I had the brilliant (perhaps not so) idea of creating a m2 
plugin that would reduce down the complexity such that is cleaner and 
simpler to use. Otherwise option 4 would definitely be what I would use.

Wb


On 9/7/05, Kenney Westerhof <fo...@neonics.com> wrote:
> 
> On Wed, 7 Sep 2005, dan tran wrote:
> 
> ... and option 4: use the maven-antrun-plugin:
> 
> <build><plugins>
> <plugin>
> <artifactId>maven-antrun-plugin</artifactId>
> <executions>
> <execution> <phase>....</phase>
> <configuration>
> <tasks>
> <java ....../>
> ....
> 
> > Hi Wendell,
> > You have 3 options:
> > - invoke ant task directly within your mojo by setting up the neccesary
> > dependencies
> > then call the ant task class' execute method.
> > - Invoke the maven-executor-plugin, a generic mojo to invoke any java's
> > main method.
> > It is still in the sanbox of at http://mojo.codehause.com
> > - I also have maven-exec-plugin, still in my local diskspace, which can
> > invoke any
> > native executable. I have not proposed to check it into
> > mojo.codehaus.com <http://mojo.codehaus.com><http://mojo.codehaus.com>'s
> > sanbox
> > yet, since i dont see a demand for it yet.
> > -D
> > On 9/7/05, Wendell Beckwith <wb...@gmail.com> wrote:
> > >
> > > I'm now trying to write a maven 2 plugin to execute a 2rd party's 
> tools
> > > command line class. The class is written is java. The tool also has an 
> ant
> > > task which just uses the Java task in ant to invoke the command line 
> tool
> > > in
> > > a forked jvm. Does m2 already provide such functionality and I just 
> haven
> > > seen it? Or barring that, can I add a dependency on a set of plugins 
> that
> > > will allow my plugn to instantiate the the ant Java task, configure it 
> and
> > > then call its execute() method.
> > >
> > > I'm trying to avoid having end users create an additional build.xml,
> > > instead
> > > I'd rather they just configure my plugin in the pom, and I can 
> internally
> > > configure the ant Java task and invoke it.
> > >
> > > Wb
> > >
> > >
> >
> 
> --
> Kenney Westerhof
> http://www.neonics.com
> GPG public key: http://www.gods.nl/~forge/kenneyw.key
>

Re: [m2] How to invoke Ant's Java task without an ant file?

Posted by Kenney Westerhof <fo...@neonics.com>.
On Wed, 7 Sep 2005, dan tran wrote:

... and option 4: use the maven-antrun-plugin:

<build><plugins>
  <plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
      <execution> <phase>....</phase>
        <configuration>
          <tasks>
            <java ....../>
....

> Hi Wendell,
>  You have 3 options:
>   - invoke ant task directly within your mojo by setting up the neccesary
> dependencies
>  then call the ant task class' execute method.
>   - Invoke the maven-executor-plugin, a generic mojo to invoke any java's
> main method.
>  It is still in the sanbox of at http://mojo.codehause.com
>   - I also have maven-exec-plugin, still in my local diskspace, which can
> invoke any
>  native executable. I have not proposed to check it into
> mojo.codehaus.com<http://mojo.codehaus.com>'s
> sanbox
>  yet, since i dont see a demand for it yet.
>  -D
>  On 9/7/05, Wendell Beckwith <wb...@gmail.com> wrote:
> >
> > I'm now trying to write a maven 2 plugin to execute a 2rd party's tools
> > command line class. The class is written is java. The tool also has an ant
> > task which just uses the Java task in ant to invoke the command line tool
> > in
> > a forked jvm. Does m2 already provide such functionality and I just haven
> > seen it? Or barring that, can I add a dependency on a set of plugins that
> > will allow my plugn to instantiate the the ant Java task, configure it and
> > then call its execute() method.
> >
> > I'm trying to avoid having end users create an additional build.xml,
> > instead
> > I'd rather they just configure my plugin in the pom, and I can internally
> > configure the ant Java task and invoke it.
> >
> > Wb
> >
> >
>

--
Kenney Westerhof
http://www.neonics.com
GPG public key: http://www.gods.nl/~forge/kenneyw.key

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


Re: [m2] How to invoke Ant's Java task without an ant file?

Posted by dan tran <da...@gmail.com>.
Hi Wendell,
 You have 3 options:
  - invoke ant task directly within your mojo by setting up the neccesary 
dependencies
 then call the ant task class' execute method.
  - Invoke the maven-executor-plugin, a generic mojo to invoke any java's 
main method. 
 It is still in the sanbox of at http://mojo.codehause.com
  - I also have maven-exec-plugin, still in my local diskspace, which can 
invoke any 
 native executable. I have not proposed to check it into
mojo.codehaus.com<http://mojo.codehaus.com>'s
sanbox
 yet, since i dont see a demand for it yet. 
 -D
 On 9/7/05, Wendell Beckwith <wb...@gmail.com> wrote: 
> 
> I'm now trying to write a maven 2 plugin to execute a 2rd party's tools
> command line class. The class is written is java. The tool also has an ant
> task which just uses the Java task in ant to invoke the command line tool 
> in
> a forked jvm. Does m2 already provide such functionality and I just haven
> seen it? Or barring that, can I add a dependency on a set of plugins that
> will allow my plugn to instantiate the the ant Java task, configure it and
> then call its execute() method.
> 
> I'm trying to avoid having end users create an additional build.xml, 
> instead
> I'd rather they just configure my plugin in the pom, and I can internally
> configure the ant Java task and invoke it.
> 
> Wb
> 
>