Search in sources :

Example 11 with DefaultPlexusContainer

use of org.codehaus.plexus.DefaultPlexusContainer in project pom-manipulation-ext by release-engineering.

the class DistributionEnforcingManipulatorTest method setMavenSession.

private void setMavenSession() throws Exception {
    final MavenExecutionRequest req = new DefaultMavenExecutionRequest().setUserProperties(userCliProperties).setRemoteRepositories(Collections.<ArtifactRepository>emptyList());
    final PlexusContainer container = new DefaultPlexusContainer();
    final MavenSession mavenSession = new MavenSession(container, null, req, new DefaultMavenExecutionResult());
    session.setMavenSession(mavenSession);
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) DefaultPlexusContainer(org.codehaus.plexus.DefaultPlexusContainer) PlexusContainer(org.codehaus.plexus.PlexusContainer) DefaultPlexusContainer(org.codehaus.plexus.DefaultPlexusContainer) DefaultMavenExecutionResult(org.apache.maven.execution.DefaultMavenExecutionResult) MavenExecutionRequest(org.apache.maven.execution.MavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest)

Example 12 with DefaultPlexusContainer

use of org.codehaus.plexus.DefaultPlexusContainer in project pom-manipulation-ext by release-engineering.

the class PropertiesUtilsTest method createUpdateSession.

private ManipulationSession createUpdateSession() throws Exception {
    ManipulationSession session = new ManipulationSession();
    session.setState(new DependencyState(p));
    session.setState(new VersioningState(p));
    session.setState(new CommonState(p));
    final MavenExecutionRequest req = new DefaultMavenExecutionRequest().setUserProperties(p).setRemoteRepositories(Collections.<ArtifactRepository>emptyList());
    final PlexusContainer container = new DefaultPlexusContainer();
    final MavenSession mavenSession = new MavenSession(container, null, req, new DefaultMavenExecutionResult());
    session.setMavenSession(mavenSession);
    return session;
}
Also used : CommonState(org.commonjava.maven.ext.core.state.CommonState) MavenSession(org.apache.maven.execution.MavenSession) DefaultPlexusContainer(org.codehaus.plexus.DefaultPlexusContainer) PlexusContainer(org.codehaus.plexus.PlexusContainer) DefaultPlexusContainer(org.codehaus.plexus.DefaultPlexusContainer) DependencyState(org.commonjava.maven.ext.core.state.DependencyState) DefaultMavenExecutionResult(org.apache.maven.execution.DefaultMavenExecutionResult) MavenExecutionRequest(org.apache.maven.execution.MavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) ManipulationSession(org.commonjava.maven.ext.core.ManipulationSession) VersioningState(org.commonjava.maven.ext.core.state.VersioningState)

Example 13 with DefaultPlexusContainer

use of org.codehaus.plexus.DefaultPlexusContainer in project plugin-compat-tester by jenkinsci.

the class SCMManagerFactory method start.

public void start() throws PlexusContainerException {
    if (plexus == null) {
        this.plexus = new DefaultPlexusContainer();
        try {
            // These will only be useful for Hudson v1.395 and under
            // ... Since the use of sisu-plexus-inject will initialize
            // everything in the constructor
            PlexusContainer.class.getDeclaredMethod("initialize").invoke(this.plexus);
            PlexusContainer.class.getDeclaredMethod("start").invoke(this.plexus);
        } catch (Throwable e) {
        /* Don't do anything here ... initialize/start methods should be called prior to v1.395 ! */
        }
    }
}
Also used : DefaultPlexusContainer(org.codehaus.plexus.DefaultPlexusContainer) PlexusContainer(org.codehaus.plexus.PlexusContainer) DefaultPlexusContainer(org.codehaus.plexus.DefaultPlexusContainer)

Example 14 with DefaultPlexusContainer

use of org.codehaus.plexus.DefaultPlexusContainer in project spring-cloud-function by spring-cloud.

the class DependencyResolutionModule method initialize.

private void initialize() {
    if (this.container == null) {
        synchronized (lock) {
            if (this.container == null) {
                ClassWorld classWorld = new ClassWorld("plexus.core", Thread.currentThread().getContextClassLoader());
                ContainerConfiguration config = new DefaultContainerConfiguration().setClassWorld(classWorld).setRealm(classWorld.getClassRealm("plexus.core")).setClassPathScanning(PlexusConstants.SCANNING_INDEX).setAutoWiring(true).setName("maven");
                PlexusContainer container;
                try {
                    container = new DefaultPlexusContainer(config, new AetherModule(), new DependencyResolutionModule());
                    localRepositoryManagerFactory = container.lookup(LocalRepositoryManagerFactory.class);
                    container.addComponent(new ClassRealmManager((MutablePlexusContainer) container, new DefaultBeanLocator()), ClassRealmManager.class.getName());
                    projectBuilder = container.lookup(ProjectBuilder.class);
                    repositorySystem = container.lookup(RepositorySystem.class);
                } catch (Exception e) {
                    throw new IllegalStateException("Cannot create container", e);
                }
                this.container = container;
                this.settings = new MavenSettingsReader().readSettings();
            }
        }
    }
}
Also used : ClassRealmManager(org.eclipse.sisu.plexus.ClassRealmManager) DefaultPlexusContainer(org.codehaus.plexus.DefaultPlexusContainer) MutablePlexusContainer(org.codehaus.plexus.MutablePlexusContainer) PlexusContainer(org.codehaus.plexus.PlexusContainer) AetherModule(org.eclipse.aether.impl.guice.AetherModule) DefaultBeanLocator(org.eclipse.sisu.inject.DefaultBeanLocator) MutablePlexusContainer(org.codehaus.plexus.MutablePlexusContainer) ClassWorld(org.codehaus.plexus.classworlds.ClassWorld) ContainerConfiguration(org.codehaus.plexus.ContainerConfiguration) DefaultContainerConfiguration(org.codehaus.plexus.DefaultContainerConfiguration) ProjectBuildingException(org.apache.maven.project.ProjectBuildingException) NoLocalRepositoryManagerException(org.eclipse.aether.repository.NoLocalRepositoryManagerException) IOException(java.io.IOException) RepositorySystem(org.eclipse.aether.RepositorySystem) LocalRepositoryManagerFactory(org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory) DefaultContainerConfiguration(org.codehaus.plexus.DefaultContainerConfiguration) DefaultPlexusContainer(org.codehaus.plexus.DefaultPlexusContainer) ProjectBuilder(org.apache.maven.project.ProjectBuilder)

Example 15 with DefaultPlexusContainer

use of org.codehaus.plexus.DefaultPlexusContainer in project sts4 by spring-projects.

the class MavenBridge method newPlexusContainer.

private static DefaultPlexusContainer newPlexusContainer() throws PlexusContainerException {
    final ClassWorld classWorld = new ClassWorld(MAVEN_CORE_REALM_ID, ClassWorld.class.getClassLoader());
    final ClassRealm realm;
    try {
        realm = classWorld.getRealm(MAVEN_CORE_REALM_ID);
    } catch (NoSuchRealmException e) {
        throw new PlexusContainerException("Could not lookup required class realm", e);
    }
    final ContainerConfiguration mavenCoreCC = // 
    new DefaultContainerConfiguration().setClassWorld(// 
    classWorld).setRealm(// 
    realm).setClassPathScanning(// 
    PlexusConstants.SCANNING_INDEX).setAutoWiring(// 
    true).setName(// $NON-NLS-1$
    "mavenCore");
    final Module logginModule = new AbstractModule() {

        protected void configure() {
            bind(ILoggerFactory.class).toInstance(LoggerFactory.getILoggerFactory());
        }
    };
    final Module coreExportsModule = new AbstractModule() {

        protected void configure() {
            ClassRealm realm = mavenCoreCC.getRealm();
            CoreExtensionEntry entry = CoreExtensionEntry.discoverFrom(realm);
            CoreExports exports = new CoreExports(entry);
            bind(CoreExports.class).toInstance(exports);
        }
    };
    return new DefaultPlexusContainer(mavenCoreCC, logginModule, coreExportsModule);
}
Also used : NoSuchRealmException(org.codehaus.plexus.classworlds.realm.NoSuchRealmException) PlexusContainerException(org.codehaus.plexus.PlexusContainerException) ClassRealm(org.codehaus.plexus.classworlds.realm.ClassRealm) DefaultContainerConfiguration(org.codehaus.plexus.DefaultContainerConfiguration) ILoggerFactory(org.slf4j.ILoggerFactory) CoreExports(org.apache.maven.extension.internal.CoreExports) DefaultPlexusContainer(org.codehaus.plexus.DefaultPlexusContainer) CoreExtensionEntry(org.apache.maven.extension.internal.CoreExtensionEntry) ClassWorld(org.codehaus.plexus.classworlds.ClassWorld) Module(com.google.inject.Module) AbstractModule(com.google.inject.AbstractModule) ContainerConfiguration(org.codehaus.plexus.ContainerConfiguration) DefaultContainerConfiguration(org.codehaus.plexus.DefaultContainerConfiguration) AbstractModule(com.google.inject.AbstractModule)

Aggregations

DefaultPlexusContainer (org.codehaus.plexus.DefaultPlexusContainer)16 DefaultContainerConfiguration (org.codehaus.plexus.DefaultContainerConfiguration)8 PlexusContainer (org.codehaus.plexus.PlexusContainer)6 PlexusContainerException (org.codehaus.plexus.PlexusContainerException)6 DefaultMavenExecutionRequest (org.apache.maven.execution.DefaultMavenExecutionRequest)5 MavenExecutionRequest (org.apache.maven.execution.MavenExecutionRequest)5 ContainerConfiguration (org.codehaus.plexus.ContainerConfiguration)5 ClassWorld (org.codehaus.plexus.classworlds.ClassWorld)5 File (java.io.File)4 DefaultMavenExecutionResult (org.apache.maven.execution.DefaultMavenExecutionResult)4 MavenSession (org.apache.maven.execution.MavenSession)4 ClassRealm (org.codehaus.plexus.classworlds.realm.ClassRealm)4 AbstractModule (com.google.inject.AbstractModule)3 MavenExecutionRequestPopulationException (org.apache.maven.execution.MavenExecutionRequestPopulationException)3 MavenExecutionRequestPopulator (org.apache.maven.execution.MavenExecutionRequestPopulator)3 IOException (java.io.IOException)2 ParseException (org.apache.commons.cli.ParseException)2 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)2 MavenArtifactRepository (org.apache.maven.artifact.repository.MavenArtifactRepository)2 CoreExports (org.apache.maven.extension.internal.CoreExports)2