If it is a dependency only needed by the plugin in question (during build time) it should not be added to the project's dependencies. However, it should probably be added as a dependency to the plugin in the pom, hich will add it to the classpath for the plugin execution. However, AFAIK that section does not honor versions declared in the depMgmt section.
/Anders On Mon, Oct 13, 2014 at 1:17 AM, Thomas Broyer <[email protected]> wrote: > Hi all, > > I have a situation where a plugin needs to take the project's classpath and > add some elements to it. What I'd like is that the elements be resolved as > if they were declared as dependencies in the project's POM: take into > account dependencyManagement for the artifact's version and (more > importantly) its transitive dependencies. > How to do it? (in a way compatible with all Maven 3.x releases) > > Or do you think it'd be a better approach to just ask people add those > dependencies to their projects? They're tools needed for building the > project, but they don't need to be in the javac classpath. I tend to > believe this approach is much cleaner, but would appreciate external > feedback. > The plugin currently resolves the dependencies using maven-compat's > ArtifactResolver but I don't think this respects the projects > dependencyManagement (BTW, the "root" artifact passed comes from the > pluginArtifactMap); it also unconditionally add the JARs to the classpath, > which could cause conflicts I believe in some (edge-case) conditions. The > first question I asked because I'd like to keep backwards compatibility and > try to fix things (or at least make them better), but if the best practice > is to add the dependencies to the project using the plugin, I'd just leave > resolution as it is today but disable it behind a flag (either the plugin > extends the classpath in some "broken" way, or you add the dependencies to > your project and the plugin just uses the project's classpath). > > -- > Thomas Broyer > /tɔ.ma.bʁwa.je/ <http://xn--nna.ma.xn--bwa-xxb.je/> < > http://xn--nna.ma.xn--bwa-xxb.je/> >
