Search code examples
javamavenmaven-invoker-plugin

Add -pl option to maven invoker request


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


Solution

  • This is your friend:

    InvocationRequest setProjects(List<String> projects)