Search code examples
mavenmaven-pluginmaven-3sonatype

RepositorySystemSession Null in Maven 3 Plugin Unit Test


I am attempting to write a unit test for a Maven 3 Plugin with a dependency on Aether using the Maven Plugin Testing Harness. When executing my tests though the RepositorySystemSession is null and after an extensive search I can not figure out how to inject a session into the unit tests plugin harness.

I am using Maven 3.0.3 core APIs, Maven Plugin Test Harness 2.0 and Aether 1.12. I have tried other various combinations but appear to be missing a critical component somewhere along the line.

The code base for the example can be found here: http://www.sonatype.com/people/2011/01/how-to-use-aether-in-maven-plugins/.

The documentation for the plugin harness can be found here: http://maven.apache.org/plugin-testing/maven-plugin-testing-harness/getting-started/index.html.

My example code can be seen here:

MyAetherMojo

MyAetherMojoTest

Any ideas on how to get the RepositorySystemSession injected into the container for the unit test?

TIA, Scott ES


Solution

  • The plugin testing harness does not support Aether testing. You have to use the Maven Invoker Plugin as demonstrated in the How To Use Aether in Maven Plugins demo code.