On Mon, Jan 20, 2014 at 10:37 AM, Stephen More <[email protected]>wrote:
> I am working on a maven plugin that needs to work with both 3.0.X and 3.1.X > and Aether ( org.sonatype.aether vs org.eclipse.aether) . What is > recommended, one or two separate plugins ? Has anyone already created a > utility that will work with either ? > I just went through this. It's not very well documented. If you're doing dependency resolution, you might gain some insight from my considerable pain; see https://github.com/ljnelson/maven-artifacts/blob/master/src/main/java/com/edugility/maven/Artifacts.java#L138to get started. Briefly, the DependencyGraphBuilder component can be injected into your plugin, and it does the dirty work of hiding how dependencies are discovered. Here's the javadoc: http://maven.apache.org/shared/maven-dependency-tree/apidocs/org/apache/maven/shared/dependency/graph/DependencyGraphBuilder.html Similarly, the ArtifactResolver component—while it lives in the maven-compat project, and while it consists of lots of deprecated methods—has one undeprecated method for resolving an artifact in an Eclipse/Sonatype-independent manner. I found that by leveraging these two components I could make my plugin work properly without having to rely on either Aether :-). Here's the javadoc: http://maven.apache.org/maven-compat/apidocs/org/apache/maven/artifact/resolver/ArtifactResolver.html You want this method (undocumented; you'll need to dig into the DefaultArtifactResolver source code to figure out what things can be null, what can't, etc. etc.): http://maven.apache.org/ref/3.1.1/maven-compat/apidocs/org/apache/maven/artifact/resolver/ArtifactResolver.html#resolve(org.apache.maven.artifact.resolver.ArtifactResolutionRequest) Best, Laird -- http://about.me/lairdnelson
