Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions maven-core/src/main/java/org/apache/maven/SessionScoped.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
* Indicates that annotated component should be instantiated before session execution starts
* and discarded after session execution completes.
*
* Note that components will be cached in the session scope and be injected with the root session.
* Derived sessions will reuse the same components than their root sessions, thus components
* should not rely on {@link org.apache.maven.execution.MavenSession#getCurrentProject()} which
* will always return the root project.
*
* @author Jason van Zyl
* @since 3.2.0
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,6 @@ public void buildProject( MavenSession session, MavenSession rootSession, Reacto

long buildStartTime = System.currentTimeMillis();

// session may be different from rootSession seeded in DefaultMaven
// explicitly seed the right session here to make sure it is used by Guice
final boolean scoped = session != rootSession;
if ( scoped )
{
sessionScope.enter();
sessionScope.seed( MavenSession.class, session );
}
try
{

Expand Down Expand Up @@ -149,11 +141,6 @@ public void buildProject( MavenSession session, MavenSession rootSession, Reacto
}
finally
{
if ( scoped )
{
sessionScope.exit();
}

session.setCurrentProject( null );

Thread.currentThread().setContextClassLoader( reactorContext.getOriginalContextClassLoader() );
Expand Down