Make sure mvnd's plexus-interactivity is not in the maven classloader, fixes #807

* the logging framework is extracted into its own jar and moved in the mvn/lib/ directory
* the other daemon jars are moved into the mvn/lib/mvnd directory and not used by maven at all
This makes maven class loader almost identical to the stock maven classloader, but for the logging framework
This commit is contained in:
Guillaume Nodet
2023-03-13 17:15:04 +01:00
parent 4d24010f55
commit 0e057cb12b
16 changed files with 83 additions and 30 deletions

View File

@@ -346,7 +346,7 @@ public class DaemonConnector {
String mvndAgentPath = null;
String plexusClassworldsPath = null;
try (DirectoryStream<Path> jarPaths = Files.newDirectoryStream(
mvndHome.resolve("mvn").resolve("lib").resolve("ext"))) {
mvndHome.resolve("mvn").resolve("lib").resolve("mvnd"))) {
for (Path jar : jarPaths) {
String s = jar.getFileName().toString();
if (s.endsWith(".jar")) {
@@ -368,7 +368,7 @@ public class DaemonConnector {
}
}
if (mvndAgentPath == null) {
throw new IllegalStateException("Could not find mvnd-agent jar in mvn/lib/ext/");
throw new IllegalStateException("Could not find mvnd-agent jar in mvn/lib/mvnd/");
}
if (plexusClassworldsPath == null) {
throw new IllegalStateException("Could not find plexus-classworlds jar in boot/");

View File

@@ -45,6 +45,10 @@
<groupId>org.apache.maven.daemon</groupId>
<artifactId>mvnd-native</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.daemon</groupId>
<artifactId>mvnd-logging</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-embedder</artifactId>
@@ -105,29 +109,6 @@
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>fallback</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>${maven-dist.required.jdk}</release>
<compileSourceRoots>
<root>${project.basedir}/src/main/java-fallback</root>
</compileSourceRoots>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>

View File

@@ -25,6 +25,9 @@
</artifactSet>
<artifactSet to="/mvn/lib">
<artifact id="org.apache.maven.daemon:mvnd-logging:${project.version}">
<exclusion id="*:*"/>
</artifact>
<artifact id="ch.qos.logback:logback-classic">
<exclusion id="*:*"/>
</artifact>
@@ -36,7 +39,7 @@
</artifact>
</artifactSet>
<artifactSet to="/mvn/lib/ext">
<artifactSet to="/mvn/lib/mvnd">
<artifact id="io.takari.maven:takari-smart-builder:${takari-smart-builder.version}">
<exclusion id="*:*"/>
</artifact>

View File

@@ -25,6 +25,9 @@
</artifactSet>
<artifactSet to="/mvn/lib">
<artifact id="org.apache.maven.daemon:mvnd-logging:${project.version}">
<exclusion id="*:*"/>
</artifact>
<artifact id="ch.qos.logback:logback-classic">
<exclusion id="*:*"/>
</artifact>
@@ -36,7 +39,7 @@
</artifact>
</artifactSet>
<artifactSet to="/mvn/lib/ext">
<artifactSet to="/mvn/lib/mvnd">
<artifact id="io.takari.maven:takari-smart-builder:${takari-smart-builder.version}">
<exclusion id="*:*"/>
</artifact>

View File

@@ -24,6 +24,7 @@ set logback.configurationFile default ${maven.conf}/logging/logback-client.xml
set logback.configurationFile.fallback default ${maven.conf}/logging/logback.xml
[plexus.core]
load ${maven.conf}/logging
load ${maven.home}/lib/ext/*.jar
load ${maven.home}/lib/*.jar
load ${maven.conf}/logging
load ${maven.home}/lib/mvnd/*.jar
optionally ${maven.home}/lib/ext/*.jar
load ${maven.home}/lib/*.jar

View File

@@ -25,5 +25,6 @@ set logback.configurationFile.fallback default ${maven.conf}/logging/logback.xml
[plexus.core]
load ${maven.conf}/logging
load ${maven.home}/lib/mvnd/*.jar
optionally ${maven.home}/lib/ext/*.jar
load ${maven.home}/lib/*.jar

58
logging/pom.xml Normal file
View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2021 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.maven.daemon</groupId>
<artifactId>mvnd</artifactId>
<version>1.0.0-m5-SNAPSHOT</version>
</parent>
<artifactId>mvnd-logging</artifactId>
<packaging>jar</packaging>
<name>Maven Daemon - Logging</name>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-embedder</artifactId>
</dependency>
<!-- Logging -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -50,6 +50,7 @@
<module>helper</module>
<module>common</module>
<module>client</module>
<module>logging</module>
<module>daemon</module>
<module>daemon-m39</module>
<module>daemon-m40</module>
@@ -240,6 +241,11 @@
<artifactId>mvnd-native</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.daemon</groupId>
<artifactId>mvnd-logging</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.daemon</groupId>
<artifactId>mvnd-agent</artifactId>