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