I do not believe that there is and do not think that this is a good idea.
From my understanding, what you are striving to achieve is a common component that will be used for several mojos. This requires that the current Maven session be transferred and used to return the value later.
The way Maven works is that it launches targets from plugins in an almost containerized environment. Each plugin is allowed to act within the Maven Phase as defined by <executions /> . This allows Maven to separate the complexity of building, testing, validating, deploying, etc. Etc. The mvn clean install call, unless I am mistaken, is two separate executions, one to start clean to build a life cycle , and then install .
Therefore, it is unsafe to assume that MavenSession and subsequent MavenExecutionRequest represent the same instance used in the previous call. clean is a separate call whose logic should not be supported in a new session.
So, I basically say, that although the common component of the plexus is good practice, especially to maintain consistency between your mojo, it is good practice (almost ioc ) to provide an appropriate session each time.
I hope the answer you are looking for. For quite some time, but to understand why you need to provide a session, think Maven .
Teh Hippo Aug 12 '12 at 23:30 2012-08-12 23:30
source share