if ( javaHome != null )
{
request.setJavaHome( javaHome );
}
InvocationResult invocationResult;
try
{
if ( getLog().isDebugEnabled() )
{
getLog().debug( "Invoking Maven for the goals: " + goals + " with properties=" + properties );
}
invocationResult = invoke( invoker, request, invokerLog, goals, properties, null );
}
catch ( MavenInvocationException e )
{
getLog().error( "Error when invoking Maven, consult the invoker log." );
getLog().debug( e );
return;
}
String invokerLogContent = null;
Reader reader = null;
try
{
reader = ReaderFactory.newReader( invokerLog, "UTF-8" );
invokerLogContent = IOUtil.toString( reader );
}
catch ( IOException e )
{
getLog().error( "IOException: " + e.getMessage() );
getLog().debug( e );
}
finally
{
IOUtil.close( reader );
}
if ( invokerLogContent != null
&& invokerLogContent.contains("Error occurred during initialization of VM"))
{
getLog().info( "Error occurred during initialization of VM, try to use an empty MAVEN_OPTS." );
if ( getLog().isDebugEnabled() )
{
getLog().debug( "Reinvoking Maven for the goals: " + goals + " with an empty MAVEN_OPTS" );
}
try
{
invocationResult = invoke( invoker, request, invokerLog, goals, properties, "" );
}
catch ( MavenInvocationException e )
{
getLog().error( "Error when reinvoking Maven, consult the invoker log." );
getLog().debug( e );
return;
}
}
if ( invocationResult.getExitCode() != 0 )
{
if ( getLog().isErrorEnabled() )
{
getLog().error( "Error when invoking Maven, consult the invoker log file: "
+ invokerLog.getAbsolutePath() );