You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Brill Pappin <jo...@gmail.com> on 2005/11/27 01:25:16 UTC
writing a new plugin
I'm about to embark on writing a maven 2 plugin for Antenna.
Antenna has existing Ant tasks defined (in fact its an Ant task lib).
In Maven 1 it was fairly easy to implement a Maven plugin using ant tasks
because you could simple call them int he plugin... how would that type of
conversion be done for Maven 2?
So far the best I can see is to create a new Mojo that mirrors the Ant
task(s).
Is there documentation some place on converting an Ant task to a maven goal?
Re: writing a new plugin
Posted by Ashley Williams <ag...@mac.com>.
Hi Brill,
You could try the mant (maven-ant) plugin library I'm working on.
Essentially it handles all the ant stuff so that you just need to
write a single class like the one below that wraps ant
webdoclet - add required dependencies to your pom.xml as per usual.
Just copy an existing project eg https://svn.codehaus.org/mojo/trunk/
mojo/mojo-sandbox/webdoclet-maven-plugin/ and you could have all of
your ant tasks done in an hour, one mojo per task.
---
(sample-ear-proj in webdoclet-maven-plugin subdirectory has example
usage)
package org.codehaus.mojo.webdoclet;
/**
* @goal webdoclet
* @phase generate-sources
* @requiresDependencyResolution test
*/
public class WebDocletMojo extends AbstractMojo
{
/**
* @parameter expression="${project}"
* @required
* @readonly
*/
private MavenProject project;
/**
* @parameter
* @required
*/
private String task;
public void execute()
throws MojoExecutionException, MojoFailureException
{
// mappings: mant autofills in the ant task parameters on
the LHS with
// the maven properties on the RHS so users don't need to
supply them
String[] mappings = new String[] {
"@destDir",
MantGoal.JAVA_GEN,
"deploymentdescriptor/@destDir", MantGoal.WEB_INF_GEN,
"fileset/@dir",
MantGoal.JAVA,
"jbosswebxml/@destDir",
MantGoal.WEB_INF_GEN
};
String taskdefClass = "xdoclet.modules.web.WebDocletTask";
new MantGoal(this, project, taskdefClass, task,
mappings).execute();
}
}
Just check out codehaus mojo project and build mant first - directly
under the mojo-sandbox directory.
- Ashley
On 27 Nov 2005, at 11:13, puschteblume wrote:
> You are right. There isn't a migration strategy from maven1 to
> maven2 as I know, or can see. I have read that there will be groovy
> supported if it reaches the final version state. Within groovy ant
> is supported. Currently it helps you to start here:
>
> http://ant.apache.org/manual/antexternal.html
>
> You should also check in advance the groovy site to check if your
> requirements can match the groovy functions for ant integration.
>
> http://groovy.codehaus.org/Ant+Scripting
>
> As the plugins are distributed in jar file format it isn't easy to
> share your current ant scripts. Maybe you can think about to
> package your ant scripts in the jar file, extract and use it. I
> know, it isn't a nice way but maybe other people here have good
> ideas how to do that or can provide a better way.
>
> Good luck
> Heiko
>
> Brill Pappin wrote:
>
>> I'm about to embark on writing a maven 2 plugin for Antenna.
>>
>> Antenna has existing Ant tasks defined (in fact its an Ant task lib).
>>
>> In Maven 1 it was fairly easy to implement a Maven plugin using
>> ant tasks
>> because you could simple call them int he plugin... how would that
>> type of
>> conversion be done for Maven 2?
>>
>> So far the best I can see is to create a new Mojo that mirrors the
>> Ant
>> task(s).
>>
>> Is there documentation some place on converting an Ant task to a
>> maven goal?
>>
>
>
> ---------------------------------------------------------------------
> 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: writing a new plugin
Posted by puschteblume <pu...@gmx.de>.
You are right. There isn't a migration strategy from maven1 to maven2 as
I know, or can see. I have read that there will be groovy supported if
it reaches the final version state. Within groovy ant is supported.
Currently it helps you to start here:
http://ant.apache.org/manual/antexternal.html
You should also check in advance the groovy site to check if your
requirements can match the groovy functions for ant integration.
http://groovy.codehaus.org/Ant+Scripting
As the plugins are distributed in jar file format it isn't easy to share
your current ant scripts. Maybe you can think about to package your ant
scripts in the jar file, extract and use it. I know, it isn't a nice way
but maybe other people here have good ideas how to do that or can
provide a better way.
Good luck
Heiko
Brill Pappin wrote:
>I'm about to embark on writing a maven 2 plugin for Antenna.
>
>Antenna has existing Ant tasks defined (in fact its an Ant task lib).
>
>In Maven 1 it was fairly easy to implement a Maven plugin using ant tasks
>because you could simple call them int he plugin... how would that type of
>conversion be done for Maven 2?
>
>So far the best I can see is to create a new Mojo that mirrors the Ant
>task(s).
>
>Is there documentation some place on converting an Ant task to a maven goal?
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: writing a new plugin
Posted by David Sag <ds...@epo.org>.
You are basically correct - just write a Mojo that mirrors the ant task.
you can leave out the getters and setters and throw a slightly different
exception but that's about the only difference.
Kind regards,
Dave Sag
Brill Pappin <jo...@gmail.com> wrote on 27-11-2005 01:25:16:
> I'm about to embark on writing a maven 2 plugin for Antenna.
>
> Antenna has existing Ant tasks defined (in fact its an Ant task lib).
>
> In Maven 1 it was fairly easy to implement a Maven plugin using ant
tasks
> because you could simple call them int he plugin... how would that type
of
> conversion be done for Maven 2?
>
> So far the best I can see is to create a new Mojo that mirrors the Ant
> task(s).
>
> Is there documentation some place on converting an Ant task to a maven
goal?