Add code to clean the build context after each embedder function that uses it.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@594313 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2007-11-12 22:02:44 +00:00
parent 60baf80fab
commit b4f9ac3067
1 changed files with 19 additions and 1 deletions

View File

@ -30,6 +30,7 @@ import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.context.BuildContextManager;
import org.apache.maven.embedder.execution.MavenExecutionRequestPopulator;
import org.apache.maven.execution.DefaultMavenExecutionRequest;
import org.apache.maven.execution.DefaultMavenExecutionResult;
@ -145,6 +146,8 @@ public class MavenEmbedder
private ArtifactHandlerManager artifactHandlerManager;
private BuildContextManager buildContextManager;
private Maven maven;
private MavenExecutionRequestPopulator populator;
@ -336,6 +339,7 @@ public class MavenEmbedder
}
finally
{
buildContextManager.clearBuildContext();
request.getRealmManager().clear();
}
}
@ -451,6 +455,7 @@ public class MavenEmbedder
}
finally
{
buildContextManager.clearBuildContext();
request.getRealmManager().clear();
}
}
@ -482,7 +487,14 @@ public class MavenEmbedder
ArtifactRepository localRepository )
throws ArtifactResolutionException, ArtifactNotFoundException
{
artifactResolver.resolve( artifact, remoteRepositories, localRepository );
try
{
artifactResolver.resolve( artifact, remoteRepositories, localRepository );
}
finally
{
buildContextManager.clearBuildContext();
}
}
public ArtifactHandler getArtifactHandler( Artifact artifact )
@ -630,6 +642,8 @@ public class MavenEmbedder
artifactHandlerManager = (ArtifactHandlerManager) container.lookup( ArtifactHandlerManager.ROLE );
buildContextManager = (BuildContextManager) container.lookup( BuildContextManager.ROLE );
// This is temporary as we can probably cache a single request and use it for default values and
// simply cascade values in from requests used for individual executions.
request = new DefaultMavenExecutionRequest();
@ -688,6 +702,8 @@ public class MavenEmbedder
public void stop()
throws MavenEmbedderException
{
buildContextManager.clearBuildContext();
container.dispose();
}
@ -815,6 +831,8 @@ public class MavenEmbedder
finally
{
loggerManager.setThresholds( oldThreshold );
buildContextManager.clearBuildContext();
request.getRealmManager().clear();
}
}