| Method from org.apache.maven.DefaultMaven Detail: |
public void contextualize(Context context) throws ContextException {
container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
}
|
protected MavenSession createSession(MavenExecutionRequest request,
ReactorManager rpm) {
return new MavenSession( container, request.getSettings(), request.getLocalRepository(),
request.getEventDispatcher(), rpm, request.getGoals(), request.getBaseDirectory(),
request.getExecutionProperties(), request.getStartTime() );
}
|
public void execute(MavenExecutionRequest request) throws MavenExecutionException {
// ----------------------------------------------------------------------
// Project execution
// ----------------------------------------------------------------------
// if ( request.getLocalRepository() == null )
// {
// request.setLocalRepository( mavenTools.createLocalRepository( request.getLocalRepositoryPath() ) );
// }
EventDispatcher dispatcher = request.getEventDispatcher();
String event = MavenEvents.REACTOR_EXECUTION;
dispatcher.dispatchStart( event, request.getBaseDirectory() );
ReactorManager rm;
try
{
rm = doExecute( request, dispatcher );
}
catch ( LifecycleExecutionException e )
{
dispatcher.dispatchError( event, request.getBaseDirectory(), e );
logError( e, request.isShowErrors() );
stats( request.getStartTime() );
line();
throw new MavenExecutionException( e.getMessage(), e );
}
catch ( BuildFailureException e )
{
dispatcher.dispatchError( event, request.getBaseDirectory(), e );
logFailure( e, request.isShowErrors() );
stats( request.getStartTime() );
line();
throw new MavenExecutionException( e.getMessage(), e );
}
catch ( Throwable t )
{
dispatcher.dispatchError( event, request.getBaseDirectory(), t );
logFatal( t );
stats( request.getStartTime() );
line();
throw new MavenExecutionException( "Error executing project within the reactor", t );
}
// Either the build was successful, or it was a fail_at_end/fail_never reactor build
// TODO: should all the logging be left to the CLI?
logReactorSummary( rm );
if ( rm.hasBuildFailures() )
{
logErrors( rm, request.isShowErrors() );
if ( !ReactorManager.FAIL_NEVER.equals( rm.getFailureBehavior() ) )
{
dispatcher.dispatchError( event, request.getBaseDirectory(), null );
getLogger().info( "BUILD ERRORS" );
line();
stats( request.getStartTime() );
line();
throw new MavenExecutionException( "Some builds failed" );
}
else
{
getLogger().info( " + Ignoring failures" );
}
}
logSuccess( rm );
stats( request.getStartTime() );
line();
dispatcher.dispatchEnd( event, request.getBaseDirectory() );
}
|
protected static String formatTime(long ms) {
long secs = ms / MS_PER_SEC;
long min = secs / SEC_PER_MIN;
secs = secs % SEC_PER_MIN;
String msg = "";
if ( min > 1 )
{
msg = min + " minutes ";
}
else if ( min == 1 )
{
msg = "1 minute ";
}
if ( secs > 1 )
{
msg += secs + " seconds";
}
else if ( secs == 1 )
{
msg += "1 second";
}
else if ( min == 0 )
{
msg += "< 1 second";
}
return msg;
}
|
public MavenProject getProject(File pom,
MavenExecutionRequest request) throws ArtifactResolutionException, ProfileActivationException, ProjectBuildingException {
if ( pom.exists() )
{
if ( pom.length() == 0 )
{
throw new ProjectBuildingException( "unknown", "The file " + pom.getAbsolutePath() +
" you specified has zero length." );
}
}
ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration();
config.setLocalRepository( request.getLocalRepository() )
.setGlobalProfileManager( request.getGlobalProfileManager() )
.setUserProperties( request.getUserProperties() );
return projectBuilder.build( pom, config );
}
|
public MavenProject getProject(File pom,
ArtifactRepository localRepository,
Settings settings,
Properties userProperties,
ProfileManager globalProfileManager) throws ArtifactResolutionException, ProfileActivationException, ProjectBuildingException {
MavenExecutionRequest request = new DefaultMavenExecutionRequest(
localRepository,
settings,
new DefaultEventDispatcher(),
Collections.EMPTY_LIST,
pom.getParentFile()
.getAbsolutePath(),
globalProfileManager,
globalProfileManager.getRequestProperties(),
new Properties(), false );
return getProject( pom, request );
} Deprecated! Use - DefaultMaven#getProject(File, MavenExecutionRequest) instead.
|
protected void line() {
getLogger().info( "------------------------------------------------------------------------" );
}
|
protected void logError(Exception e,
boolean showErrors) {
line();
getLogger().error( "BUILD ERROR" );
line();
logDiagnostics( e );
logTrace( e, showErrors );
if ( !showErrors )
{
getLogger().info( "For more information, run Maven with the -e switch" );
line();
}
}
|
protected void logFailure(BuildFailureException e,
boolean showErrors) {
line();
getLogger().error( "BUILD FAILURE" );
line();
logDiagnostics( e );
logTrace( e, showErrors );
if ( !showErrors )
{
getLogger().info( "For more information, run Maven with the -e switch" );
line();
}
}
|
protected void logFatal(Throwable error) {
line();
getLogger().error( "FATAL ERROR" );
line();
logDiagnostics( error );
logTrace( error, true );
}
|
protected void logSuccess(ReactorManager rm) {
line();
getLogger().info( "BUILD SUCCESSFUL" );
line();
}
|
protected void stats(Date start) {
Date finish = new Date();
long time = finish.getTime() - start.getTime();
getLogger().info( "Total time: " + formatTime( time ) );
getLogger().info( "Finished at: " + finish );
//noinspection CallToSystemGC
System.gc();
Runtime r = Runtime.getRuntime();
getLogger().info(
"Final Memory: " + ( r.totalMemory() - r.freeMemory() ) / MB + "M/" + r.totalMemory() / MB + "M" );
}
|