in src/main/java/org/apache/maven/plugins/linkcheck/SiteInvoker.java [265:346]
private InvocationResult invoke( Invoker invoker, InvocationRequest request, File invokerLog, List<String> goals,
Properties properties, String mavenOpts )
throws MavenInvocationException
{
PrintStream ps;
OutputStream os = null;
if ( invokerLog != null )
{
if ( getLog().isDebugEnabled() )
{
getLog().debug( "Using " + invokerLog.getAbsolutePath() + " to log the invoker" );
}
try
{
if ( !invokerLog.exists() )
{
invokerLog.getParentFile().mkdirs();
}
os = new FileOutputStream( invokerLog );
ps = new PrintStream( os, true, "UTF-8" );
}
catch ( FileNotFoundException e )
{
if ( getLog().isErrorEnabled() )
{
getLog().error( "FileNotFoundException: " + e.getMessage()
+ ". Using System.out to log the invoker." );
}
ps = System.out;
}
catch ( UnsupportedEncodingException e )
{
if ( getLog().isErrorEnabled() )
{
getLog().error( "UnsupportedEncodingException: " + e.getMessage()
+ ". Using System.out to log the invoker." );
}
ps = System.out;
}
}
else
{
getLog().debug( "Using System.out to log the invoker." );
ps = System.out;
}
if ( mavenOpts != null )
{
request.setMavenOpts( mavenOpts );
}
InvocationOutputHandler outputHandler = new PrintStreamHandler( ps, false );
request.setOutputHandler( outputHandler );
request.setErrorHandler( outputHandler );
try
{
outputHandler.consumeLine( "Invoking Maven for the goals: " + goals + " with properties=" + properties );
outputHandler.consumeLine( "" );
outputHandler.consumeLine( "M2_HOME=" + getMavenHome() );
outputHandler.consumeLine( "MAVEN_OPTS=" + getMavenOpts() );
outputHandler.consumeLine( "JAVA_HOME=" + getJavaHome() );
outputHandler.consumeLine( "JAVA_OPTS=" + getJavaOpts() );
outputHandler.consumeLine( "" );
}
catch ( IOException e )
{
throw new MavenInvocationException( e.getMessage(), e.getCause() );
}
try
{
return invoker.execute( request );
}
finally
{
IOUtil.close( os );
ps = null;
}
}