This is a good way to do it. If you are looking to cut and paste the ant tasks, you might like to write the plugins in Marmalade, or use the AntRun plugin if the number of tasks is -very small- (though it could be to farm it out to a larger ant script using the <ant ... /> task).
- Brett On 7/14/05, Peter van de Hoef <[EMAIL PROTECTED]> wrote: > Hi Vitaliy, > > You can add the Ant jars as dependency in your plugin's POM, like: > > <dependency> > <groupId>ant</groupId> > <artifactId>ant</artifactId> > <version>1.6.2</version> > </dependency> > <dependency> > <groupId>ant</groupId> > <artifactId>ant-launcher</artifactId> > <version>1.6.2</version> > </dependency> > ... etc, depending on the Ant functionality you need. > > And, in your plugin code: > > Project project = new Project(); > project.init(); > project.addBuildListener( logger ); > > project.fireBuildStarted(); > > project.setBaseDir( baseDir ); > project.setKeepGoingMode( false ); > project.setUserProperty( "ant.version", Main.getAntVersion() ); > > // Initialize the project file. > project.setUserProperty( "ant.file", buildFile.getAbsolutePath() ); > ProjectHelper projectHelper = ProjectHelper.getProjectHelper(); > project.addReference( "ant.projectHelper", projectHelper ); > projectHelper.parse( project, buildFile ); > > project.executeTarget( target ); > > project.fireBuildFinished( null ); > > Here are some other pointers: > > - > http://www-128.ibm.com/developerworks/websphere/library/techarticles/0502_gawor/0502_gawor.html > - http://www.onjava.com/pub/a/onjava/2002/07/24/antauto.html > - And the source of the org.apache.tools.ant.Main class of course. > > I don't know if this is the 'officially approved' way to embed Ant in Maven, > but it works for me. > Maybe the devs can shed some light on this. > > Hope this helps. > Peter van de Hoef > > Vitaliy Geraymovych wrote: > > I am in the process of moving Ant scripts to Maven2. > > > > I am looking for an example of how to invoke ant task within a > > specific phase of m2. My goal for now is to invoke our custom ant > > targets and than later on replace them one by one with maven plugins. > > > > Thanks, > > Vitaliy > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
