如何在插件中解析 Maven 存储库中的工件?
在上一个问题中,我得到了一个用于下载的答案来自 Maven 存储库的工件。这对我来说效果很好,但我需要阅读 MavenProject 以获取下载的工件。
我在插件中阅读 MavenProject 以获取下载的工件的最佳方式是什么?
In a previous question I got an answer for downloading an artifact from the Maven repository. This works well for me, but I need to read the MavenProject for the downloaded artifact.
What is the best way for me to read the MavenProject for the downloaded artifact in my plugin?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 MavenProjectBuilder 解析工件并将下载的 pom 读入 MavenProject。 buildFromRepository() 方法将从远程存储库获取工件(如果需要),因此在阅读之前无需下载它。
这些是先前答案解决 Maven 项目所需的更改:
You can use the MavenProjectBuilder to resolve the artifact and read the downloaded pom into a MavenProject. The buildFromRepository() method will obtain the artifact (if needed) from the remote repositories so there is no need to download it before reading.
These are the changes needed to the previous answer resolve the maven project:
此处提供了一些示例: http://docs.codehaus.org/display/ MAVENUSER/Mojo+开发者+Cookbook。
Some examples are available here: http://docs.codehaus.org/display/MAVENUSER/Mojo+Developer+Cookbook.