谁能给出一个以编程方式使用org.apache.maven.cli.MavenCli的好例子? [英] Can anyone give a good example of using org.apache.maven.cli.MavenCli programmatically?

查看:75
本文介绍了谁能给出一个以编程方式使用org.apache.maven.cli.MavenCli的好例子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个intelliJ插件,该插件需要在当前项目上执行maven目标. Intertube中的所有谈话都建议使用MavenEmbedder.祝你好运.没有很好地支持2.0.4版本,也没有关于如何使用它的参考.

I'm trying to create an intelliJ plugin that needs to execute maven targets on the current project. All the talk in the intertubes recommends using the MavenEmbedder. Good luck with that. The 2.0.4 version isn't well supported and there are no references for how to use it.

我旋转了一下,撞到一堵墙,在该墙中嵌入器尚未使用其所需的所有字段进行初始化.反光的私人成员注入?惊人的!为什么有人需要一种明显的方法来初始化对象?

I gave it a whirl and ran into a wall where the embedder had not been initialized with all the fields it needs. Reflective private member injection? Awesome! Why would anyone need an obvious way to initialize an object?

似乎有人使用2.1版本取得了一些成功.我一直无法在罐子或什至来源中找到它.

It seems a few people are using a 2.1 version with some success. I have been unable to find that in a jar or even sources.

我去检查了embedder项目的3.0版本: http://maven.apache.org/ref/3.0-beta-3/maven-embedder/它完全消除了MavenEmbedder对象,并且似乎仅支持通过MavenCli上的main或doMain方法进行访问.有没有人使用过这些方法并且可以提供一些建议?

I went and checked out the 3.0 version of the embedder project: http://maven.apache.org/ref/3.0-beta-3/maven-embedder/ It does away with the MavenEmbedder object all together and seems to only support access through the main or doMain methods on MavenCli. Has anyone used these methods and can give some advice?

推荐答案

是的,关于MavenCli的记录方式并不多.该API明显更简单,但我仍想举一些示例.这是一个可行的...

Yeah, the's not much in the way of documentation of MavenCli. The API is significatly simpler but i'd still like some examples. Here's one that works...

MavenCli cli = new MavenCli();
int result = cli.doMain(new String[]{"compile"},
        "/home/aioffe/workspace/MiscMaven",
        System.out, System.out);
System.out.println("result: " + result);

它需要一个目录并运行编译"阶段...

It takes a dir and runs the 'compile' phase...

这篇关于谁能给出一个以编程方式使用org.apache.maven.cli.MavenCli的好例子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆