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