[MNG-7759] Maven2 plugins will not have even session setter (#1084)

As setter was added in Maven3. Still, this causes unexpected NPE
during plugin execution, while Maven3 should support Maven2
plugins.

---

https://issues.apache.org/jira/browse/MNG-7759
This commit is contained in:
Tamas Cservenak 2023-04-13 11:56:13 +02:00 committed by GitHub
parent bc138dc3ba
commit eb7cdefaaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -1000,6 +1000,10 @@ public class DefaultProjectBuilder implements ProjectBuilder {
}
private ModelCache createModelCache(RepositorySystemSession session) {
// MNG-7759: very old clients (Maven2 plugins) will not even have session, as setter was added in Maven 3
if (session == null) {
return null;
}
// MNG-7693: for older clients (not injecting ModelCacheFactory), make this work OOTB w/ defaults
return modelCacheFactory != null
? modelCacheFactory.createCache(session)