introduced RepositorySessionDecorator

Signed-off-by: Igor Fedorenko <ifedorenko@apache.org>
This commit is contained in:
Igor Fedorenko 2014-11-25 15:50:12 -05:00
parent 1e95aa1524
commit 369889296e
2 changed files with 54 additions and 5 deletions

View File

@ -21,6 +21,7 @@ package org.apache.maven.project;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.maven.RepositoryUtils; import org.apache.maven.RepositoryUtils;
@ -66,15 +67,21 @@ public class DefaultProjectDependenciesResolver
@Requirement @Requirement
private RepositorySystem repoSystem; private RepositorySystem repoSystem;
@Requirement
private List<RepositorySessionDecorator> decorators;
public DependencyResolutionResult resolve( DependencyResolutionRequest request ) public DependencyResolutionResult resolve( DependencyResolutionRequest request )
throws DependencyResolutionException throws DependencyResolutionException
{ {
RequestTrace trace = RequestTrace.newChild( null, request ); final RequestTrace trace = RequestTrace.newChild( null, request );
DefaultDependencyResolutionResult result = new DefaultDependencyResolutionResult(); final DefaultDependencyResolutionResult result = new DefaultDependencyResolutionResult();
MavenProject project = request.getMavenProject(); final MavenProject project = request.getMavenProject();
final DependencyFilter filter = request.getResolutionFilter();
RepositorySystemSession session = request.getRepositorySession(); RepositorySystemSession session = request.getRepositorySession();
ArtifactTypeRegistry stereotypes = session.getArtifactTypeRegistry();
if ( logger.isDebugEnabled() if ( logger.isDebugEnabled()
&& session.getConfigProperties().get( DependencyManagerUtils.CONFIG_PROP_VERBOSE ) == null ) && session.getConfigProperties().get( DependencyManagerUtils.CONFIG_PROP_VERBOSE ) == null )
{ {
@ -82,9 +89,15 @@ public class DefaultProjectDependenciesResolver
verbose.setConfigProperty( DependencyManagerUtils.CONFIG_PROP_VERBOSE, Boolean.TRUE ); verbose.setConfigProperty( DependencyManagerUtils.CONFIG_PROP_VERBOSE, Boolean.TRUE );
session = verbose; session = verbose;
} }
DependencyFilter filter = request.getResolutionFilter();
ArtifactTypeRegistry stereotypes = session.getArtifactTypeRegistry(); for ( RepositorySessionDecorator decorator : decorators )
{
RepositorySystemSession decorated = decorator.decorate( project, session );
if ( decorated != null )
{
session = decorated;
}
}
CollectRequest collect = new CollectRequest(); CollectRequest collect = new CollectRequest();
collect.setRootArtifact( RepositoryUtils.toArtifact( project.getArtifact() ) ); collect.setRootArtifact( RepositoryUtils.toArtifact( project.getArtifact() ) );

View File

@ -0,0 +1,36 @@
package org.apache.maven.project;
/*
* 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 org.eclipse.aether.RepositorySystemSession;
/**
* Component interface that allows per-project customization of Aether repository system sessions.
*
* @since 3.2.4
* @provisional This interface is part of work in progress and can be changed or removed without notice.
*/
public interface RepositorySessionDecorator
{
/**
* Returns possibly {@code null} Aether repository system session to be used to resolve project dependencies.
*/
RepositorySystemSession decorate( MavenProject project, RepositorySystemSession session );
}