*/
@Override
protected WebappLoader createWebappLoader()
throws IOException, MojoExecutionException
{
WebappLoader loader = super.createWebappLoader();
if ( useSeparateTomcatClassLoader )
{
loader.setDelegate( delegate );
}
try
{
ClassLoaderEntriesCalculatorRequest request =
new ClassLoaderEntriesCalculatorRequest().setDependencies( dependencies ).setLog(
getLog() ).setMavenProject( project ).setAddWarDependenciesInClassloader(
addWarDependenciesInClassloader ).setUseTestClassPath( useTestClasspath );
ClassLoaderEntriesCalculatorResult classLoaderEntriesCalculatorResult =
classLoaderEntriesCalculator.calculateClassPathEntries( request );
List<String> classLoaderEntries = classLoaderEntriesCalculatorResult.getClassPathEntries();
final List<File> tmpDirectories = classLoaderEntriesCalculatorResult.getTmpDirectories();
Runtime.getRuntime().addShutdownHook( new Thread()
{
@Override
public void run()
{
for ( File tmpDir : tmpDirectories )
{
try
{
FileUtils.deleteDirectory( tmpDir );
}
catch ( IOException e )
{
// ignore
}
}
}
} );
if ( classLoaderEntries != null )
{
for ( String classLoaderEntry : classLoaderEntries )
{
loader.addRepository( classLoaderEntry );
}
}
if ( additionalClasspathDirs != null && !additionalClasspathDirs.isEmpty() )
{
for ( String additionalClasspathDir : additionalClasspathDirs )
{
if ( StringUtils.isNotBlank( additionalClasspathDir ) )
{
File file = new File( additionalClasspathDir );
if ( file.exists() )
{
String fileUri = file.toURI().toString();
getLog().debug( "add file:" + fileUri + " as a additionalClasspathDir" );
loader.addRepository( fileUri );
}
}
}
}
}