简体   繁体   中英

Maven Embedder: how to add command option

I'm using Maven Embedder followingly:

MavenCli cli = new MavenCli();
int result = cli.doMain(new String[] { "process-resources" }, "tmp/projectdir", System.out, System.err);

This works, and is equivalent to running command line command

mvn process-resources

in directory

tmp/projectdir

However, I need to specify an option to Maven, so that Maven Embedder performs the equivalent to command line command

mvn -Dstage=local process-resources

How can this be done?

-Dstage=local is a system variable that is set by just giving it as the argument parameter to doMain() :

MavenCli cli = new MavenCli();
int result = cli.doMain(new String[] { "-Dstage=local", "process-resources" }, "tmp/projectdir", System.out, System.err);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM