mirror of https://github.com/apache/maven.git
[MNG-4194] API to safely release of plugin realms
o Allowed cache to track usage of plugins by projects git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@817681 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
341f030f5c
commit
eda354717b
|
@ -31,6 +31,7 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
|
|||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Exclusion;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.codehaus.plexus.classworlds.realm.ClassRealm;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
|
||||
|
@ -233,4 +234,9 @@ public class DefaultPluginRealmCache
|
|||
return s1 != null ? s1.equals( s2 ) : s2 == null;
|
||||
}
|
||||
|
||||
public void register( MavenProject project, ClassRealm pluginRealm )
|
||||
{
|
||||
// default cache does not track plugin usage
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.List;
|
|||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.codehaus.plexus.classworlds.realm.ClassRealm;
|
||||
|
||||
/**
|
||||
|
@ -57,4 +58,14 @@ public interface PluginRealmCache
|
|||
|
||||
void flush();
|
||||
|
||||
/**
|
||||
* Registers the specified plugin realm for usage with the given project. Integrators can use the information
|
||||
* collected from this method in combination with a custom cache implementation to dispose unused plugin realms from
|
||||
* the cache.
|
||||
*
|
||||
* @param project The project that employs the plugin realm, must not be {@code null}.
|
||||
* @param pluginRealm The plugin realm being used for the project, must not be {@code null}.
|
||||
*/
|
||||
void register( MavenProject project, ClassRealm pluginRealm );
|
||||
|
||||
}
|
||||
|
|
|
@ -297,9 +297,11 @@ public class DefaultMavenPluginManager
|
|||
{
|
||||
Plugin plugin = pluginDescriptor.getPlugin();
|
||||
|
||||
MavenProject project = session.getCurrentProject();
|
||||
|
||||
PluginRealmCache.CacheRecord cacheRecord =
|
||||
pluginRealmCache.get( plugin, parent, imports, session.getLocalRepository(),
|
||||
session.getCurrentProject().getPluginArtifactRepositories() );
|
||||
project.getPluginArtifactRepositories() );
|
||||
|
||||
if ( cacheRecord != null )
|
||||
{
|
||||
|
@ -311,9 +313,11 @@ public class DefaultMavenPluginManager
|
|||
createPluginRealm( pluginDescriptor, session, parent, imports );
|
||||
|
||||
pluginRealmCache.put( plugin, parent, imports, session.getLocalRepository(),
|
||||
session.getCurrentProject().getPluginArtifactRepositories(),
|
||||
pluginDescriptor.getClassRealm(), pluginDescriptor.getArtifacts() );
|
||||
project.getPluginArtifactRepositories(), pluginDescriptor.getClassRealm(),
|
||||
pluginDescriptor.getArtifacts() );
|
||||
}
|
||||
|
||||
pluginRealmCache.register( project, pluginDescriptor.getClassRealm() );
|
||||
}
|
||||
|
||||
private void createPluginRealm( PluginDescriptor pluginDescriptor, MavenSession session, ClassLoader parent,
|
||||
|
|
Loading…
Reference in New Issue