Repository: maven Updated Branches: refs/heads/master 88ef34c5c -> 1de53e8e2
code simplification for LifecycleParticipant handling Project: http://git-wip-us.apache.org/repos/asf/maven/repo Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/1de53e8e Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/1de53e8e Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/1de53e8e Branch: refs/heads/master Commit: 1de53e8e2ca9aa9b1810c83ec295510176534f69 Parents: 88ef34c Author: Hervé Boutemy <hbout...@apache.org> Authored: Fri Oct 7 08:31:00 2016 +0200 Committer: Hervé Boutemy <hbout...@apache.org> Committed: Fri Oct 7 08:31:00 2016 +0200 ---------------------------------------------------------------------- .../java/org/apache/maven/DefaultMaven.java | 67 +++++++++++--------- 1 file changed, 36 insertions(+), 31 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven/blob/1de53e8e/maven-core/src/main/java/org/apache/maven/DefaultMaven.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java index 15b946e..6954e9b 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java @@ -193,6 +193,10 @@ public class DefaultMaven return doExecute( request, session, result, repoSession ); } + catch ( MavenExecutionException e ) + { + return addExceptionToResult( result, e ); + } finally { sessionScope.exit(); @@ -201,20 +205,9 @@ public class DefaultMaven private MavenExecutionResult doExecute( MavenExecutionRequest request, MavenSession session, MavenExecutionResult result, DefaultRepositorySystemSession repoSession ) + throws MavenExecutionException { - try - { - // CHECKSTYLE_OFF: LineLength - for ( AbstractMavenLifecycleParticipant listener : getLifecycleParticipants( Collections.<MavenProject>emptyList() ) ) - { - listener.afterSessionStart( session ); - } - // CHECKSTYLE_ON: LineLength - } - catch ( MavenExecutionException e ) - { - return addExceptionToResult( result, e ); - } + afterSessionStart( session ); eventCatapult.fire( ExecutionEvent.Type.ProjectDiscoveryStarted, session, null ); @@ -257,24 +250,7 @@ public class DefaultMaven repoSession.setReadOnly(); - ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); - try - { - for ( AbstractMavenLifecycleParticipant listener : getLifecycleParticipants( session.getProjects() ) ) - { - Thread.currentThread().setContextClassLoader( listener.getClass().getClassLoader() ); - - listener.afterProjectsRead( session ); - } - } - catch ( MavenExecutionException e ) - { - return addExceptionToResult( result, e ); - } - finally - { - Thread.currentThread().setContextClassLoader( originalClassLoader ); - } + afterProjectRead( session ); // // The projects need to be topologically after the participants have run their afterProjectsRead(session) @@ -330,6 +306,35 @@ public class DefaultMaven return result; } + @SuppressWarnings( "checkstyle:linelength" ) + private void afterSessionStart( MavenSession session ) + throws MavenExecutionException + { + for ( AbstractMavenLifecycleParticipant listener : getLifecycleParticipants( Collections.<MavenProject>emptyList() ) ) + { + listener.afterSessionStart( session ); + } + } + + private void afterProjectRead( MavenSession session ) + throws MavenExecutionException + { + ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); + try + { + for ( AbstractMavenLifecycleParticipant listener : getLifecycleParticipants( session.getProjects() ) ) + { + Thread.currentThread().setContextClassLoader( listener.getClass().getClassLoader() ); + + listener.afterProjectsRead( session ); + } + } + finally + { + Thread.currentThread().setContextClassLoader( originalClassLoader ); + } + } + private void afterSessionEnd( Collection<MavenProject> projects, MavenSession session ) throws MavenExecutionException {