mirror of https://github.com/apache/maven.git
Add get/setParentContainer to the configuration, and use it in
the embedder. If the classrealm that's passed in has a parent realm, then only the resources from the realm are scanned (getRealmResources). This was done to re-use components from parent realms. However, when embedding maven within another plexus container, providing a new dummy classworld with the current classloader as the parent, no components will be found. Since there's no parent container, it won't be checked for components. So, allowing a parent realm to be set in classworlds also requires a parent container to be set, so that when no components are found (since they're present in the parent container), there is a parent container available to delegate lookups to. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@563173 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0ceae1b648
commit
711eb8c416
|
@ -18,6 +18,7 @@ package org.apache.maven.embedder;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.classworlds.ClassWorld;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -76,6 +77,10 @@ public interface Configuration
|
|||
|
||||
Configuration setClassLoader( ClassLoader loader );
|
||||
|
||||
PlexusContainer getParentContainer();
|
||||
|
||||
Configuration setParentContainer( PlexusContainer parentContainer );
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Profiles
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.maven.embedder;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.classworlds.ClassWorld;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -53,6 +54,8 @@ public class DefaultConfiguration
|
|||
|
||||
private ClassWorld classWorld;
|
||||
|
||||
private PlexusContainer parentContainer;
|
||||
|
||||
private File localRepository;
|
||||
|
||||
/** Creates a new instance of DefaultConfiguration */
|
||||
|
@ -189,6 +192,17 @@ public class DefaultConfiguration
|
|||
return this;
|
||||
}
|
||||
|
||||
public PlexusContainer getParentContainer()
|
||||
{
|
||||
return parentContainer;
|
||||
}
|
||||
|
||||
public Configuration setParentContainer( PlexusContainer parentContainer )
|
||||
{
|
||||
this.parentContainer = parentContainer;
|
||||
return this;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Local Repository
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
@ -557,7 +557,7 @@ public class MavenEmbedder
|
|||
try
|
||||
{
|
||||
ContainerConfiguration cc = new DefaultContainerConfiguration()
|
||||
.setClassWorld( classWorld );
|
||||
.setClassWorld( classWorld ).setParentContainer( configuration.getParentContainer() );
|
||||
|
||||
container = new DefaultPlexusContainer( cc );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue