[MNG-7564] Check if session is null when generating metadata

Closes #857.
This commit is contained in:
Abdel Hajou 2022-10-28 12:09:12 +02:00 committed by Maarten Mulders
parent 9beb2ed45d
commit bc8c6be269
1 changed files with 12 additions and 5 deletions

View File

@ -196,11 +196,18 @@ public class MavenMetadataSource
DependencyManagement dependencyManagement = model.getDependencyManagement();
managedDependencies = dependencyManagement == null ? null : dependencyManagement.getDependencies();
MavenSession session = legacySupport.getSession();
pomRepositories = session.getProjects().stream()
.filter( p -> artifact.equals( p.getArtifact() ) )
.map( MavenProject::getRemoteArtifactRepositories )
.findFirst()
.orElseGet( ArrayList::new );
if ( session != null )
{
pomRepositories = session.getProjects().stream()
.filter( p -> artifact.equals( p.getArtifact() ) )
.map( MavenProject::getRemoteArtifactRepositories )
.findFirst()
.orElseGet( ArrayList::new );
}
else
{
pomRepositories = new ArrayList<>();
}
}
else if ( artifact instanceof ArtifactWithDependencies )
{