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

问题描述

我试图创建一个的IntelliJ插件,需要对当前项目执行的Maven目标。在intertubes所有的谈话建议使用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.

我去检查了3.0版本的嵌入项目:http://maven.apache.org/ref/3.0-beta-3/maven-embedder/它摒弃了MavenEmbedder对象一起,似乎只支持通过MavenCli主或域方法的访问。有没有人使用这些方法,可以给一些建议?

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是significatly简单,但我还是想一些例子。这里有一个工程......

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 programattically的一个很好的例子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 08:18