in src/main/java/org/apache/maven/plugins/linkcheck/SiteInvoker.java [169:253]
private void invoke( File projectFile, File invokerLog, String mavenHome, List<String> goals,
List<String> activeProfiles, Properties properties )
{
Invoker invoker = new DefaultInvoker();
invoker.setMavenHome( new File( mavenHome ) );
File localRepoDir = new File( localRepository.getBasedir() );
invoker.setLocalRepositoryDirectory( localRepoDir );
InvocationRequest request = new DefaultInvocationRequest();
request.setLocalRepositoryDirectory( localRepoDir );
// request.setUserSettingsFile( settingsFile );
request.setBatchMode( true );
request.setShowErrors( getLog().isErrorEnabled() );
request.setDebug( getLog().isDebugEnabled() );
// request.setShowVersion( false );
request.setBaseDirectory( projectFile.getParentFile() );
request.setPomFile( projectFile );
request.setGoals( goals );
request.setProperties( properties );
request.setProfiles( activeProfiles );
File javaHome = getJavaHome();
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;
try ( Reader reader = ReaderFactory.newReader( invokerLog, "UTF-8" ) )
{
invokerLogContent = IOUtil.toString( reader );
}
catch ( IOException e )
{
getLog().error( "IOException: " + e.getMessage() );
getLog().debug( e );
}
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() );
}
}
}