mirror of https://github.com/apache/maven.git
[MNG-7600] LocalRepositoryManager is created too early
LocalRepositoryManager needs configurations from RepositorySystemSession so must be created after session configuration is finished.
This commit is contained in:
parent
dc88c6193c
commit
b1c1f7556d
|
@ -174,27 +174,6 @@ public class DefaultRepositorySystemSessionFactory
|
|||
|
||||
session.setArtifactTypeRegistry( RepositoryUtils.newArtifactTypeRegistry( artifactHandlerManager ) );
|
||||
|
||||
LocalRepository localRepo = new LocalRepository( request.getLocalRepository().getBasedir() );
|
||||
|
||||
if ( request.isUseLegacyLocalRepository() )
|
||||
{
|
||||
try
|
||||
{
|
||||
session.setLocalRepositoryManager( simpleLocalRepoMgrFactory.newInstance( session, localRepo ) );
|
||||
logger.info( "Disabling enhanced local repository: using legacy is strongly discouraged to ensure"
|
||||
+ " build reproducibility." );
|
||||
}
|
||||
catch ( NoLocalRepositoryManagerException e )
|
||||
{
|
||||
logger.error( "Failed to configure legacy local repository: falling back to default" );
|
||||
session.setLocalRepositoryManager( repoSystem.newLocalRepositoryManager( session, localRepo ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
session.setLocalRepositoryManager( repoSystem.newLocalRepositoryManager( session, localRepo ) );
|
||||
}
|
||||
|
||||
session.setWorkspaceReader(
|
||||
request.getWorkspaceReader() != null ? request.getWorkspaceReader() : workspaceRepository );
|
||||
|
||||
|
@ -309,6 +288,8 @@ public class DefaultRepositorySystemSessionFactory
|
|||
mavenRepositorySystem.injectProxy( session, request.getPluginArtifactRepositories() );
|
||||
mavenRepositorySystem.injectAuthentication( session, request.getPluginArtifactRepositories() );
|
||||
|
||||
setUpLocalRepositoryManager( request, session );
|
||||
|
||||
if ( Features.buildConsumer( request.getUserProperties() ).isActive() )
|
||||
{
|
||||
session.setFileTransformerManager( a -> getTransformersForArtifact( a, session.getData() ) );
|
||||
|
@ -317,6 +298,30 @@ public class DefaultRepositorySystemSessionFactory
|
|||
return session;
|
||||
}
|
||||
|
||||
private void setUpLocalRepositoryManager( MavenExecutionRequest request, DefaultRepositorySystemSession session )
|
||||
{
|
||||
LocalRepository localRepo = new LocalRepository( request.getLocalRepository().getBasedir() );
|
||||
|
||||
if ( request.isUseLegacyLocalRepository() )
|
||||
{
|
||||
try
|
||||
{
|
||||
session.setLocalRepositoryManager( simpleLocalRepoMgrFactory.newInstance( session, localRepo ) );
|
||||
logger.info( "Disabling enhanced local repository: using legacy is strongly discouraged to ensure"
|
||||
+ " build reproducibility." );
|
||||
}
|
||||
catch ( NoLocalRepositoryManagerException e )
|
||||
{
|
||||
logger.error( "Failed to configure legacy local repository: falling back to default" );
|
||||
session.setLocalRepositoryManager( repoSystem.newLocalRepositoryManager( session, localRepo ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
session.setLocalRepositoryManager( repoSystem.newLocalRepositoryManager( session, localRepo ) );
|
||||
}
|
||||
}
|
||||
|
||||
private Map<?, ?> getPropertiesFromRequestedProfiles( MavenExecutionRequest request )
|
||||
{
|
||||
|
||||
|
|
Loading…
Reference in New Issue