简体   繁体   中英

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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