Skip to content

Commit

Permalink
Make sure mvnd's plexus-interactivity is not in the maven classloader,
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
gnodet committed Mar 14, 2023
1 parent 4d24010 commit 0e057cb
Show file tree
Hide file tree
Showing 16 changed files with 83 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ private Process startDaemonProcess(String daemonId, ClientOutput output) {
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")) {
Expand All @@ -368,7 +368,7 @@ private Process startDaemonProcess(String daemonId, ClientOutput output) {
}
}
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/");
Expand Down
27 changes: 4 additions & 23 deletions daemon/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
5 changes: 4 additions & 1 deletion dist-m39/src/main/provisio/maven-distro.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down
5 changes: 4 additions & 1 deletion dist-m40/src/main/provisio/maven-distro.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down
7 changes: 4 additions & 3 deletions dist/src/main/distro/bin/mvnd-client.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions dist/src/main/distro/bin/mvnd-daemon.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 58 additions & 0 deletions logging/pom.xml
Original file line number Diff line number Diff line change
@@ -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>
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 0e057cb

Please sign in to comment.