Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to download dependencies inside a maven plugin?

What's the best way to download remote maven artifact from within a maven plugin while also supporting maven 2.2.x1), 3.0.x, 3.1.x and newer?

Aether seems a good candidate but it changed package namespace between 3.0.5 and 3.1 breaking compatibility.

There's pieces of information around,

  • some pointing towards maven-dependency-tree (as suggested in this SO post) (how?)
  • yet another to jcbi,
  • Another SO post which I think uses Aether underneath and presumably suffers from the same version incompatibility problem
  • Try to manually force your version of Ather based on the ResolveArtifact example
  • Try to port the really complex solution reflection solution from Apache Karaf
  • Some other util from maven-shared ?

So what's the correct, or at least working, way to go on about this?

1) Where Maven 2.2.x is a nice to have as pointed out by @khmarbaise is EoL

like image 243
Johan Sjöberg Avatar asked Aug 19 '14 23:08

Johan Sjöberg


1 Answers

If you're in a plugin and want to have another plugin invoked, the best solution - by far - is to use Mojo Executor. This way, you won't rewrite the maven-dependency-plugin ... Considering the maven version issues, well, I guess you should indeed give up on maven 2.* support.

like image 56
Riduidel Avatar answered Oct 14 '22 16:10

Riduidel