mirror of https://github.com/apache/maven.git
o Fixed project realm handling to be more embedder friendly
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@795206 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8efe10c89e
commit
ef13f229e8
|
@ -97,13 +97,16 @@ class DefaultModelBuildingListener
|
|||
projectBuildingHelper.createProjectRealm( model, projectBuildingRequest.getLocalRepository(),
|
||||
pluginRepositories );
|
||||
|
||||
if ( projectRealm != null )
|
||||
{
|
||||
/*
|
||||
* Update the context class loader so that the container will search the project realm when the model
|
||||
* builder injects the lifecycle bindings from the packaging next. The class loader is reset by the project
|
||||
* builder when the project is fully assembled.
|
||||
* Update the context class loader such that the container will search the project realm when the model
|
||||
* builder injects the lifecycle bindings from the packaging in the next step. The context class loader
|
||||
* will be reset by the project builder when the project is fully assembled.
|
||||
*/
|
||||
Thread.currentThread().setContextClassLoader( projectRealm );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -302,7 +302,23 @@ public class DefaultProjectBuilder
|
|||
.setRemoteRepostories( project.getRemoteArtifactRepositories() )
|
||||
.setManagedVersionMap( project.getManagedVersionMap() );
|
||||
|
||||
ArtifactResolutionResult result = repositorySystem.resolve( artifactRequest );
|
||||
ArtifactResolutionResult result;
|
||||
|
||||
ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
|
||||
try
|
||||
{
|
||||
if ( project.getClassRealm() != null )
|
||||
{
|
||||
Thread.currentThread().setContextClassLoader( project.getClassRealm() );
|
||||
}
|
||||
|
||||
result = repositorySystem.resolve( artifactRequest );
|
||||
}
|
||||
finally
|
||||
{
|
||||
Thread.currentThread().setContextClassLoader( oldContextClassLoader );
|
||||
}
|
||||
|
||||
if ( result.hasExceptions() )
|
||||
{
|
||||
|
|
|
@ -98,7 +98,7 @@ public class DefaultProjectBuildingHelper
|
|||
List<ArtifactRepository> remoteRepositories )
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
ClassRealm projectRealm = container.getContainerRealm();
|
||||
ClassRealm projectRealm = null;
|
||||
|
||||
Build build = model.getBuild();
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ public interface ProjectBuildingHelper
|
|||
* @param model The model to create the project realm for, must not be {@code null}
|
||||
* @param localRepository The local repository to use for artifact resolution, must not be {@code null}.
|
||||
* @param remoteRepositories The remote repositories to use for artifact resolution, must not be {@code null}.
|
||||
* @return The project realm, never {@code null}.
|
||||
* @return The project realm or {@code null} if the project uses no extensions.
|
||||
* @throws ArtifactResolutionException If any build extension could not be resolved.
|
||||
*/
|
||||
ClassRealm createProjectRealm( Model model, ArtifactRepository localRepository,
|
||||
|
|
Loading…
Reference in New Issue