mirror of https://github.com/apache/maven.git
MNG-5389 introduced MavenLifecycleParticipant#afterSessionEnd callback
Signed-off-by: Igor Fedorenko <ifedorenko@apache.org>
This commit is contained in:
parent
626884e9ee
commit
8f3eca3d0f
|
@ -57,4 +57,16 @@ public abstract class AbstractMavenLifecycleParticipant
|
|||
// do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked after all projects were built.
|
||||
*
|
||||
* This callback is intended to allow extensions to perform cleanup of any
|
||||
* allocated external resources after the build. It is invoked on best-effort
|
||||
* basis and may be missed due to an Error or RuntimeException in Maven core
|
||||
* code.
|
||||
*/
|
||||
public void afterSessionEnd( MavenSession session )
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
|
|
@ -317,6 +317,8 @@ public class DefaultMaven
|
|||
|
||||
if ( result.hasExceptions() )
|
||||
{
|
||||
afterSessionEnd( projects, session );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -337,9 +339,29 @@ public class DefaultMaven
|
|||
return addExceptionToResult( result, session.getResult().getExceptions().get( 0 ) );
|
||||
}
|
||||
|
||||
afterSessionEnd( projects, session );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void afterSessionEnd( Collection<MavenProject> projects, MavenSession session )
|
||||
{
|
||||
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
try
|
||||
{
|
||||
for ( AbstractMavenLifecycleParticipant listener : getLifecycleParticipants( projects ) )
|
||||
{
|
||||
Thread.currentThread().setContextClassLoader( listener.getClass().getClassLoader() );
|
||||
|
||||
listener.afterSessionEnd( session );
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Thread.currentThread().setContextClassLoader( originalClassLoader );
|
||||
}
|
||||
}
|
||||
|
||||
public RepositorySystemSession newRepositorySession( MavenExecutionRequest request )
|
||||
{
|
||||
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
|
||||
|
|
Loading…
Reference in New Issue