I may be going about this wrong, but I'm trying to get the top-level dependencies of a project within a maven plugin.
I can get all (top-level and transitive) dependencies using this call
MavenProject.getArtifacts()
I can get just the top-level dependencies using this call
MavenProject.getDependencyArtifacts()
The problem is that the artifactIds returned in the latter call is sometimes different than the artifactIds in the former call. This happens when the dependency is "relocated" such as xerces:xerces:2.4.0
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>xerces</groupId>
<artifactId>xerces</artifactId>
<version>2.4.0</version>
<distributionManagement>
<relocation>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</relocation>
</distributionManagement>
</project>
If the developer specifies xerces:xerces:2.4.0 in their pom, getArtifacts() returns xerces:xercesImpl. But getDependencyArtifacts() returns xerces:xerces.