I am trying to create my first Maven plugin and for this I need to access MavenSession in my Mojos. In many places, I found that the following snippet should be enough, but I always get the mavenSession object as null, although in the Maven log (from POM.xml using my plugin) it seems that the maven session has been transferred or at least is full - But not injected into the MavenSession object.
Can someone tell me what I am missing?
Thanks!
private MavenSession mavenSession;
I also added the following to the POM.xml plugin (based on a comment I found somewhere):
<dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-core</artifactId> <version>3.2.5</version> </dependency>
And this is from the magazine:
[DEBUG] Configuring mojo 'com.ofernicus.helpers:resource-helper:1.0-SNAPSHOT:iterate' with basic configurator --> [DEBUG] (f) session = org.apache.maven.execution.MavenSession@1a785a79 [DEBUG] (f) mavenProject = MavenProject: com.ofernicus.consumers:resource-helper-consumer:1.0-SNAPSHOT @ C:\Users\oferlan\workspaces\Maven\PluginConsumer\resource-helper-consumer\pom.xml
source share