![JAR search and dependency download from the Maven repository](/logo.png)
org.apache.maven.execution.MavenSession Maven / Gradle / Ivy
package org.apache.maven.execution;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.io.File;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.RepositoryCache;
import org.apache.maven.monitor.event.EventDispatcher;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.settings.Settings;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.eclipse.aether.RepositorySystemSession;
/**
* @author Jason van Zyl
*/
public class MavenSession
implements Cloneable
{
private PlexusContainer container;
private MavenExecutionRequest request;
private MavenExecutionResult result;
private RepositorySystemSession repositorySession;
private final Settings settings;
private Properties executionProperties;
private MavenProject currentProject;
/**
* These projects have already been topologically sorted in the {@link org.apache.maven.Maven} component before
* being passed into the session.
*/
private List projects;
private MavenProject topLevelProject;
private ProjectDependencyGraph projectDependencyGraph;
private boolean parallel;
private final Map>> pluginContextsByProjectAndPluginKey =
new ConcurrentHashMap>>();
@Deprecated
public MavenSession( PlexusContainer container, MavenExecutionRequest request, MavenExecutionResult result,
MavenProject project )
{
this( container, request, result, Arrays.asList( new MavenProject[]{project} ) );
}
@Deprecated
public MavenSession( PlexusContainer container, Settings settings, ArtifactRepository localRepository,
EventDispatcher eventDispatcher, ReactorManager unused, List goals,
String executionRootDir, Properties executionProperties, Date startTime )
{
this( container, settings, localRepository, eventDispatcher, unused, goals, executionRootDir,
executionProperties, null, startTime );
}
@Deprecated
public MavenSession( PlexusContainer container, Settings settings, ArtifactRepository localRepository,
EventDispatcher eventDispatcher, ReactorManager unused, List goals,
String executionRootDir, Properties executionProperties, Properties userProperties,
Date startTime )
{
this.container = container;
this.settings = settings;
this.executionProperties = executionProperties;
this.request = new DefaultMavenExecutionRequest();
this.request.setUserProperties( userProperties );
this.request.setLocalRepository( localRepository );
this.request.setGoals( goals );
this.request.setBaseDirectory( ( executionRootDir != null ) ? new File( executionRootDir ) : null );
this.request.setStartTime( startTime );
}
@Deprecated
public MavenSession( PlexusContainer container, MavenExecutionRequest request, MavenExecutionResult result,
List projects )
{
this.container = container;
this.request = request;
this.result = result;
this.settings = new SettingsAdapter( request );
setProjects( projects );
}
public MavenSession( PlexusContainer container, RepositorySystemSession repositorySession, MavenExecutionRequest request,
MavenExecutionResult result )
{
this.container = container;
this.request = request;
this.result = result;
this.settings = new SettingsAdapter( request );
this.repositorySession = repositorySession;
}
public void setProjects( List projects )
{
if ( !projects.isEmpty() )
{
this.currentProject = projects.get( 0 );
this.topLevelProject = currentProject;
for ( MavenProject project : projects )
{
if ( project.isExecutionRoot() )
{
topLevelProject = project;
break;
}
}
}
else
{
this.currentProject = null;
this.topLevelProject = null;
}
this.projects = projects;
}
@Deprecated
public PlexusContainer getContainer()
{
return container;
}
@Deprecated
public Object lookup( String role )
throws ComponentLookupException
{
return container.lookup( role );
}
@Deprecated
public Object lookup( String role, String roleHint )
throws ComponentLookupException
{
return container.lookup( role, roleHint );
}
@Deprecated
public List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy