You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Oliver Drotbohm <od...@vmware.com> on 2021/10/05 13:42:04 UTC

MavenProject.getRuntimeClasspathElements() not returning runtime elements

Hi all,

in a Maven Plugin project, we need to obtain all elements of the runtime classpath during the *compile* phase. The code is currently calling `project.getRuntimeClasspathElements()`. That in turn iterates over `MavenProject.getArtifacts()` which is documented to only return elements of a certain scope:

/**
 * All dependencies that this project has, including transitive ones. Contents are lazily populated, so depending on
 * what phases have run dependencies in some scopes won't be included. eg. if only compile phase has run,
 * dependencies with scope test won't be included.
 */

IIUC, that means that during the compile phase, runtime dependencies will not be returned, which makes me wonder why `….getRuntimeClasspathElements()` uses that obviously limited method in the first place because depending on the phase you call the method in you'll never actually be able to see the runtime elements.

Should the method augment the set of artifacts resolved with the runtime scoped ones held in `ModuleProject.dependencyArtifacts`?

Cheers,
Ollie