You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2023/02/17 21:03:06 UTC
[maven] branch maven-3.8.x updated: [MNG-7564] Check if session is null when generating metadata
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch maven-3.8.x
in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/maven-3.8.x by this push:
new 7ec2c66b5 [MNG-7564] Check if session is null when generating metadata
7ec2c66b5 is described below
commit 7ec2c66b536ad4577c9cbcfcad096149ea120289
Author: Abdel Hajou <ab...@gmail.com>
AuthorDate: Fri Oct 28 12:09:12 2022 +0200
[MNG-7564] Check if session is null when generating metadata
Backported (and adapted) from master.
---
.../project/artifact/MavenMetadataSource.java | 23 ++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
index 124e8b8fe..481d3a37f 100644
--- a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
+++ b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
@@ -204,18 +204,25 @@ public class MavenMetadataSource
DependencyManagement dependencyManagement = model.getDependencyManagement();
managedDependencies = dependencyManagement == null ? null : dependencyManagement.getDependencies();
MavenSession session = legacySupport.getSession();
- Map<String, MavenProject> projectMap = session.getProjectMap();
- MavenProject project = projectMap == null ? null
- : projectMap.get( ArtifactUtils.key( artifact.getGroupId(), artifact.getArtifactId(),
- artifact.getVersion() ) );
- if ( project == null )
+ if ( session != null )
{
- // if the project is not on the project map, read the repositories from the model itself!
- pomRepositories = getRepositoriesFromModel( repositorySession, model );
+ Map<String, MavenProject> projectMap = session.getProjectMap();
+ MavenProject project = projectMap == null ? null
+ : projectMap.get( ArtifactUtils.key( artifact.getGroupId(), artifact.getArtifactId(),
+ artifact.getVersion() ) );
+ if ( project == null )
+ {
+ // if the project is not on the project map, read the repositories from the model itself!
+ pomRepositories = getRepositoriesFromModel( repositorySession, model );
+ }
+ else
+ {
+ pomRepositories = project.getRemoteArtifactRepositories();
+ }
}
else
{
- pomRepositories = project.getRemoteArtifactRepositories();
+ pomRepositories = new ArrayList<>();
}
}
else if ( artifact instanceof ArtifactWithDependencies )