[MNG-7772] Allow to register maven core extension in .m2 directory instead of MAVEN_HOME (#1280)

This commit is contained in:
juulhobert 2023-10-18 20:06:57 +02:00 committed by GitHub
parent 251a316962
commit 7f86d1d996
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 5 deletions

View File

@ -6,6 +6,7 @@ set maven.conf default ${maven.home}/conf
load ${maven.conf}/logging
optionally ${maven.home}/lib/ext/redisson/*.jar
optionally ${maven.home}/lib/ext/hazelcast/*.jar
optionally ${user.home}/.m2/ext/*.jar
optionally ${maven.home}/lib/ext/*.jar
load ${maven.home}/lib/maven-*.jar
load ${maven.home}/lib/*.jar

View File

@ -145,7 +145,9 @@ public class MavenCli {
private static final String EXT_CLASS_PATH = "maven.ext.class.path";
private static final String EXTENSIONS_FILENAME = ".mvn/extensions.xml";
private static final String EXTENSIONS_FILENAME = "extensions.xml";
private static final String MVN_EXTENSIONS_FILENAME = ".mvn/" + EXTENSIONS_FILENAME;
private static final String MVN_MAVEN_CONFIG = ".mvn/maven.config";
@ -747,12 +749,17 @@ public class MavenCli {
return Collections.emptyList();
}
File extensionsFile = new File(cliRequest.multiModuleProjectDirectory, EXTENSIONS_FILENAME);
if (!extensionsFile.isFile()) {
return Collections.emptyList();
File extensionsFile = new File(cliRequest.multiModuleProjectDirectory, MVN_EXTENSIONS_FILENAME);
File userHomeExtensionsFile = new File(USER_MAVEN_CONFIGURATION_HOME, EXTENSIONS_FILENAME);
List<CoreExtension> extensions = new ArrayList<>();
if (extensionsFile.isFile()) {
extensions.addAll(readCoreExtensionsDescriptor(extensionsFile));
}
if (userHomeExtensionsFile.isFile()) {
extensions.addAll(readCoreExtensionsDescriptor(userHomeExtensionsFile));
}
List<CoreExtension> extensions = readCoreExtensionsDescriptor(extensionsFile);
if (extensions.isEmpty()) {
return Collections.emptyList();
}