for %%i in ("%MAVEN_HOME%"\boot\plexus-classworlds-*) doset CLASSWORLDS_JAR="%%i" set CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
// session may be different from rootSession seeded in DefaultMaven // explicitly seed the right session here to make sure it is used by Guice sessionScope.enter( reactorContext.getSessionScopeMemento() ); sessionScope.seed( MavenSession.class, session ); try { if ( reactorContext.getReactorBuildStatus().isHaltedOrBlacklisted( currentProject ) ) { eventCatapult.fire( ExecutionEvent.Type.ProjectSkipped, session, null ); return; }
BuilderCommon.attachToThread( currentProject ); projectExecutionListener.beforeProjectExecution( new ProjectExecutionEvent( session, currentProject ) ); eventCatapult.fire( ExecutionEvent.Type.ProjectStarted, session, null ); //获取构建执行计划 MavenExecutionPlan executionPlan = builderCommon.resolveBuildPlan( session, currentProject, taskSegment, new HashSet<Artifact>() ); //通过执行计划得到执行器 List<MojoExecution> mojoExecutions = executionPlan.getMojoExecutions(); projectExecutionListener.beforeProjectLifecycleExecution( new ProjectExecutionEvent( session, currentProject, mojoExecutions ) ); //执行插件构建任务,其内部是循环执行mojoExecutions对应的执行器, //具体逻辑是通过MavenPluginManager拿到插件对应的Mojo接口实例 //然后执行Mojo实例,由此执行扩展接口逻辑,得到插件提供的强大扩展能力 mojoExecutor.execute( session, mojoExecutions, reactorContext.getProjectIndex() ); long buildEndTime = System.currentTimeMillis(); projectExecutionListener.afterProjectExecutionSuccess( new ProjectExecutionEvent( session, currentProject, mojoExecutions ) ); reactorContext.getResult().addBuildSummary( new BuildSuccess( currentProject, buildEndTime - buildStartTime ) ); eventCatapult.fire( ExecutionEvent.Type.ProjectSucceeded, session, null ); } catch ( Throwable t ) { builderCommon.handleBuildError( reactorContext, rootSession, session, currentProject, t, buildStartTime ); projectExecutionListener.afterProjectExecutionFailure( new ProjectExecutionEvent( session, currentProject, t ) ); // rethrow original errors and runtime exceptions if ( t instanceof RuntimeException ) { throw (RuntimeException) t; } if ( t instanceof Error ) { throw (Error) t; } } finally { sessionScope.exit(); session.setCurrentProject( null ); Thread.currentThread().setContextClassLoader( reactorContext.getOriginalContextClassLoader() ); } }