MNG-6209 better executeMojo thread context classloader Signed-off-by: Igor Fedorenko <ifedore...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/maven/repo Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/bc089f94 Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/bc089f94 Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/bc089f94 Branch: refs/heads/MNG-6169_2/not-updated-MJAR-MCOMPILER Commit: bc089f942b0c641482ef047bba899fc605014c61 Parents: d3c7c3f Author: Igor Fedorenko <ifedore...@apache.org> Authored: Tue Apr 11 07:59:34 2017 -0700 Committer: Michael Osipov <micha...@apache.org> Committed: Thu May 11 19:54:51 2017 +0200 ---------------------------------------------------------------------- .../java/org/apache/maven/plugin/DefaultBuildPluginManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven/blob/bc089f94/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java index b4f7a4d..3af1125 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java @@ -106,8 +106,11 @@ public class DefaultBuildPluginManager 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();