MNG-6209 better executeMojo thread context classloader

Signed-off-by: Igor Fedorenko <ifedorenko@apache.org>
This commit is contained in:
Igor Fedorenko 2017-04-11 07:59:34 -07:00
parent 567af0d964
commit ec629f7d51
1 changed files with 4 additions and 1 deletions

View File

@ -106,8 +106,11 @@ public void executeMojo( MavenSession session, MojoExecution mojoExecution )
throw new PluginExecutionException( mojoExecution, project, e );
}
// use project realm as thread context classloader to enable components from all extensions=true plugins
ClassRealm tccl = mojoExecution.getPlugin().isExtensions() ? project.getClassRealm() : pluginRealm;
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader( pluginRealm );
Thread.currentThread().setContextClassLoader( tccl );
MavenSession oldSession = legacySupport.getSession();