-2

I have a little Java program which uses Maven Invoker to run some maven commands programmatically. The Maven routine is basically:

InvocationRequest request = new DefaultInvocationRequest();
Invoker invoker = new DefaultInvoker();
request.setGoals(Arrays.asList("clean", "install"));

// module.pomFullPath(workspaceRoot) gets the module location
request.setPomFile(new File(module.pomFullPath(workspaceRoot))); 

InvocationResult result = invoker.execute(request);

This runs mvn clean install over the module. Now I need to run a command adding options, promtly mvn -pl !skipThis clean install

How can I add the -pl option to my request object in my program? Thanks in advance for your answers/comments

Alvaro Pedraza
  • 1,176
  • 6
  • 20
  • 44

1 Answers1

1

This is your friend:

InvocationRequest setProjects(List<String> projects)
s.fuhrm
  • 438
  • 4
  • 9
  • Thanks! The documentation for Maven Invoker leaves a lot to be desired, I must say. And the API is not quite intuitive. But it does the job, anyway! – Alvaro Pedraza Mar 05 '20 at 22:34