Maven - Runtime Search Dependencies

I would like to be able to determine which versions I run the dependency at runtime, as well as the version of the web application itself.

Each deployed web application is packed with pom.xml which I can read, this part is trivial. The next part of the parsing does not require much effort.

How the web application works, I want to be able to understand which version I have, and which versions have my dependencies.

Ideally, I would like to do something like:

MavenPom pom = new MavenPom(webApplicationPomInputStream);
pom.getVersion();
pom.getArtifactId();
pom.getGroupId();

for(Dependency dependency:pom.getDependencies())
{
  dependency.getVersion();
  dependency.getArtifactId();
  dependency.getGroupId();
}

Should I just use XPath notation here, or is there a library I can call for this type?

, / - : mvn dependency: tree. , groupId, artifactId , .

, XML ? JAXB , .

, .

+3
2

mvn dependency: tree . / . , groupId, artifactId, version .

, , , , . , , , :.

+2

Source: https://habr.com/ru/post/1726854/


All Articles