You can use Maven Embedder to call another Mojo from within your Mojo.

Below is a snippet that I hope will help.

Cheers,
Rahul

-------------------- snip --------------------
MavenEmbedder maven = new MavenEmbedder ();

ClassLoader classLoader = Thread.currentThread ().getContextClassLoader
();

maven.setClassLoader (classLoader);

maven.setLogger (new MavenEmbedderConsoleLogger ());

try {

maven.start ();

File targetDirectory = new File (targetDir);

File pomFile = new File (targetDirectory, pomXml);

MavenProject pom = maven.readProjectWithDependencies (pomFile);

EventMonitor eventMonitor = new DefaultEventMonitor (new
PlexusLoggerAdapter (new MavenEmbedderConsoleLogger ()));

if (getLog ().isDebugEnabled ())

getLog ().debug ("Executing embedded Maven instance...");

if (getLog ().isInfoEnabled ())

getLog ().info ("delegating goal(s) now to embedded m2 instance.");

maven.execute (pom, goals, eventMonitor, new ConsoleDownloadMonitor (),
null, targetDirectory);

if (getLog ().isInfoEnabled ())

getLog ().info ("Embedded Maven executed successfully!");

} catch (Exception e) {

 // TODO : catch specific Exceptions (this is for demonstration)

}

------------------- snip -------------



----- Original Message ----- From: "Wilfred Springer" <[EMAIL PROTECTED]>
To: "Maven Users List" <[email protected]>
Sent: Monday, May 29, 2006 2:10 AM
Subject: m2: Delegating to other Mojo


All,

Is there any way to force execution of some Mojo from another Mojo?

Thanks,

Wilfred




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to