Gogi
Gogi

Reputation: 1695

Developing maven-plugin: how to get list of direct dependencies defined in pom.xml?

I am using methods getDependencyManagement() and getDependencies() of class org.apache.maven.project.MavenProject to get a list of dependencies of pom.xml on which the plugin is executed, but I am also getting the inherited dependencies.

How I can get a list of dependencies defined directly inside the pom.xml, and not any of the inherited ones.

Upvotes: 1

Views: 549

Answers (1)

DB5
DB5

Reputation: 13978

From the MavenProject class you can use the getDependencyArtifacts() method. Its Javadoc reads:

/**
 * Direct dependencies that this project has.
 * @return Set<Artifact>
 * @see #getArtifacts() to get all transitive dependencies
 */

Upvotes: 1

Related Questions