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

那年仲夏 提交于 2019-12-05 02:57:19

问题


I would create programmatically the effective model from a pom file to get all inherited attributes in the pom model instance. I would analyze some attributes of a pom - but I need for it all attributes - incl. inhertied.

What have I to do? I have tried Sonatype Aether but I did not find a example.


回答1:


Check out this Gist https://gist.github.com/reiz/6203767. It shows a method which builds a MavenProject inside of a maven plugin. On the MavenProject you can call methods like project.getDependencies() and so on.




回答2:


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. 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.



来源:https://stackoverflow.com/questions/7429799/how-to-programmatically-build-the-effective-model-of-a-pom-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!