Ok, I realized I have to get the Maven Invoker from here:

http://svn.apache.org/viewvc/maven/shared/tags/maven-invoker-2.0.10

I'll try to make some tests with the code I have and see if it works...

--
David Nemer
Sent from: Kaiserslautern RP Germany.

On Sat, Mar 28, 2009 at 12:49 AM, David Nemer <[email protected]> wrote:

> Hello All,
>
> I'm new with Maven, and I was wondering if you guys could help me out here.
>
> I'm trying to invoke Maven from Java-code. For example, I have a build
> file, and I call it in Java code to build the project.
>
> I found this code, but I'm not sure if it works, I imported the Maven JAR
> to the project, but it doesn't seem to recognize the InvocationRequest,
> InvocationResult and Invoker... do I need other libraries to use them.
>
>         InvocationRequest request = new DefaultInvocationRequest();
>         request.setPomFile( new File( "/path/to/pom.xml" ) );
>         request.setGoals( Collections.singletonList( "install" ) );
>
>         Invoker invoker = new DefaultInvoker();
>
>         InvocationResult result = invoker.execute( request );
>
>         if ( result.getExitCode() != 0 )
>         {
>             throw new IllegalStateException( "Build failed." );
>         }
>
> Cheers,
> --
> David Nemer
> Sent from: Kaiserslautern RP Germany.

Reply via email to