简体   繁体   English

如何以编程方式构建pom文件的有效模型?

[英]How to programmatically build the effective model of a pom file?

I would create programmatically the effective model from a pom file to get all inherited attributes in the pom model instance. 我将以编程方式从pom文件创建有效模型,以获取pom模型实例中的所有继承属性。 I would analyze some attributes of a pom - but I need for it all attributes - incl. 我会分析一个pom的一些属性 - 但我需要它的所有属性 - 包括。 inhertied. inhertied。

What have I to do? 我该怎么办? I have tried Sonatype Aether but I did not find a example. 我试过Sonatype Aether,但我找不到一个例子。

Check out this Gist https://gist.github.com/reiz/6203767 . 看看这个要点https://gist.github.com/reiz/6203767 It shows a method which builds a MavenProject inside of a maven plugin. 它显示了一个在maven插件中构建MavenProject的方法。 On the MavenProject you can call methods like project.getDependencies() and so on. 在MavenProject上,您可以调用project.getDependencies()等方法。

You could just run mvn help:effective-pom to get the pom that maven is actually using, including all default inherited and parent pom inherited attributes. 您可以运行mvn help:effective-pom来获取maven实际使用的pom,包括所有默认继承和父pom继承的属性。 I don't believe this would give you all the transitive dependencies of listed dependencies, but it should give you what you are asking for here. 我不相信这会给你列出所有依赖关系的所有传递依赖关系,但它应该给你在这里要求的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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