Move back mvn script into the mvn/bin folder to avoid conflicts, fixes #787 (#803)

This commit is contained in:
Guillaume Nodet
2023-03-10 12:59:04 +01:00
committed by GitHub
parent c2e4ee2f00
commit d771375870
17 changed files with 32 additions and 21 deletions

View File

@@ -345,8 +345,8 @@ public class DaemonConnector {
// classpath // classpath
String mvndAgentPath = null; String mvndAgentPath = null;
String plexusClassworldsPath = null; String plexusClassworldsPath = null;
try (DirectoryStream<Path> jarPaths = try (DirectoryStream<Path> jarPaths = Files.newDirectoryStream(
Files.newDirectoryStream(mvndHome.resolve("lib").resolve("ext"))) { mvndHome.resolve("mvn").resolve("lib").resolve("ext"))) {
for (Path jar : jarPaths) { for (Path jar : jarPaths) {
String s = jar.getFileName().toString(); String s = jar.getFileName().toString();
if (s.endsWith(".jar")) { if (s.endsWith(".jar")) {
@@ -356,7 +356,8 @@ public class DaemonConnector {
} }
} }
} }
try (DirectoryStream<Path> jarPaths = Files.newDirectoryStream(mvndHome.resolve("boot"))) { try (DirectoryStream<Path> jarPaths =
Files.newDirectoryStream(mvndHome.resolve("mvn").resolve("boot"))) {
for (Path jar : jarPaths) { for (Path jar : jarPaths) {
String s = jar.getFileName().toString(); String s = jar.getFileName().toString();
if (s.endsWith(".jar")) { if (s.endsWith(".jar")) {
@@ -367,7 +368,7 @@ public class DaemonConnector {
} }
} }
if (mvndAgentPath == null) { if (mvndAgentPath == null) {
throw new IllegalStateException("Could not find mvnd-agent jar in lib/ext/"); throw new IllegalStateException("Could not find mvnd-agent jar in mvn/lib/ext/");
} }
if (plexusClassworldsPath == null) { if (plexusClassworldsPath == null) {
throw new IllegalStateException("Could not find plexus-classworlds jar in boot/"); throw new IllegalStateException("Could not find plexus-classworlds jar in boot/");
@@ -428,8 +429,8 @@ public class DaemonConnector {
} }
Environment.MVND_HOME.addSystemProperty(args, mvndHome.toString()); Environment.MVND_HOME.addSystemProperty(args, mvndHome.toString());
args.add("-Dmaven.home=" + mvndHome); args.add("-Dmaven.home=" + mvndHome.resolve("mvn"));
args.add("-Dmaven.conf=" + mvndHome.resolve("conf")); args.add("-Dmaven.conf=" + mvndHome.resolve("mvn").resolve("conf"));
args.add("-Dclassworlds.conf=" + mvndHome.resolve("bin").resolve("mvnd-server.conf")); args.add("-Dclassworlds.conf=" + mvndHome.resolve("bin").resolve("mvnd-server.conf"));
Environment.MVND_JAVA_HOME.addSystemProperty( Environment.MVND_JAVA_HOME.addSystemProperty(

View File

@@ -124,8 +124,11 @@ public class DaemonParameters {
if (mvndH != null) { if (mvndH != null) {
Path mvndDaemon = Path mvndDaemon =
Paths.get("mvnd-daemon-" + BuildProperties.getInstance().getVersion() + ".jar"); Paths.get("mvnd-daemon-" + BuildProperties.getInstance().getVersion() + ".jar");
if (Files.exists(mvndH.resolve("lib").resolve(mvndDaemon)) if (Files.exists(mvndH.resolve("mvn").resolve("lib").resolve(mvndDaemon))
|| Files.exists(mvndH.resolve("lib").resolve("ext").resolve(mvndDaemon))) { || Files.exists(mvndH.resolve("mvn")
.resolve("lib")
.resolve("ext")
.resolve(mvndDaemon))) {
return mvndH.toString(); return mvndH.toString();
} }
} }
@@ -239,8 +242,9 @@ public class DaemonParameters {
public Path logbackConfigurationPath() { public Path logbackConfigurationPath() {
return property(Environment.MVND_LOGBACK) return property(Environment.MVND_LOGBACK)
.orDefault(() -> .orDefault(() -> mvndHome()
mvndHome().resolve("conf/logging/logback-mvnd.xml").toString()) .resolve("mvn/conf/logging/logback-server.xml")
.toString())
.orFail() .orFail()
.asPath(); .asPath();
} }

View File

@@ -17,14 +17,14 @@
--> -->
<assembly> <assembly>
<artifactSet to="/"> <artifactSet to="/mvn">
<artifact id="org.apache.maven:apache-maven:tar.gz:bin:${maven3.version}"> <artifact id="org.apache.maven:apache-maven:tar.gz:bin:${maven3.version}">
<unpack useRoot="false" <unpack useRoot="false"
excludes="conf/logging/*,lib/maven-slf4j-provider*" /> excludes="conf/logging/*,lib/maven-slf4j-provider*" />
</artifact> </artifact>
</artifactSet> </artifactSet>
<artifactSet to="/lib"> <artifactSet to="/mvn/lib">
<artifact id="ch.qos.logback:logback-classic"> <artifact id="ch.qos.logback:logback-classic">
<exclusion id="*:*"/> <exclusion id="*:*"/>
</artifact> </artifact>
@@ -33,7 +33,7 @@
</artifact> </artifact>
</artifactSet> </artifactSet>
<artifactSet to="/lib/ext"> <artifactSet to="/mvn/lib/ext">
<artifact id="io.takari.maven:takari-smart-builder:${takari-smart-builder.version}"> <artifact id="io.takari.maven:takari-smart-builder:${takari-smart-builder.version}">
<exclusion id="*:*"/> <exclusion id="*:*"/>
</artifact> </artifact>

View File

@@ -17,14 +17,14 @@
--> -->
<assembly> <assembly>
<artifactSet to="/"> <artifactSet to="/mvn">
<artifact id="org.apache.maven:apache-maven:tar.gz:bin:${maven4.version}"> <artifact id="org.apache.maven:apache-maven:tar.gz:bin:${maven4.version}">
<unpack useRoot="false" <unpack useRoot="false"
excludes="conf/logging/*,lib/maven-slf4j-provider*,lib/plexus-utils-3.*" /> excludes="conf/logging/*,lib/maven-slf4j-provider*,lib/plexus-utils-3.*" />
</artifact> </artifact>
</artifactSet> </artifactSet>
<artifactSet to="/lib"> <artifactSet to="/mvn/lib">
<artifact id="ch.qos.logback:logback-classic"> <artifact id="ch.qos.logback:logback-classic">
<exclusion id="*:*"/> <exclusion id="*:*"/>
</artifact> </artifact>
@@ -33,7 +33,7 @@
</artifact> </artifact>
</artifactSet> </artifactSet>
<artifactSet to="/lib/ext"> <artifactSet to="/mvn/lib/ext">
<artifact id="io.takari.maven:takari-smart-builder:${takari-smart-builder.version}"> <artifact id="io.takari.maven:takari-smart-builder:${takari-smart-builder.version}">
<exclusion id="*:*"/> <exclusion id="*:*"/>
</artifact> </artifact>

View File

@@ -16,7 +16,7 @@
# under the License. # under the License.
main is org.mvndaemon.mvnd.client.DefaultClient from plexus.core main is org.mvndaemon.mvnd.client.DefaultClient from plexus.core
set maven.home default ${mvnd.home} set maven.home default ${mvnd.home}/mvn
set maven.conf default ${maven.home}/conf set maven.conf default ${maven.home}/conf
set logback.configurationFile default ${maven.conf}/logging/logback-client.xml set logback.configurationFile default ${maven.conf}/logging/logback-client.xml

View File

@@ -16,9 +16,12 @@
# under the License. # under the License.
main is org.mvndaemon.mvnd.daemon.Server from plexus.core main is org.mvndaemon.mvnd.daemon.Server from plexus.core
set maven.home default ${mvnd.home} set maven.home default ${mvnd.home}/mvn
set maven.conf default ${maven.home}/conf set maven.conf default ${maven.home}/conf
set logback.configurationFile default ${maven.conf}/logging/logback-server.xml
set logback.configurationFile.fallback default ${maven.conf}/logging/logback.xml
[plexus.core] [plexus.core]
load ${maven.conf}/logging load ${maven.conf}/logging
optionally ${maven.home}/lib/ext/*.jar optionally ${maven.home}/lib/ext/*.jar

View File

@@ -197,7 +197,7 @@ set CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
%MAVEN_OPTS% ^ %MAVEN_OPTS% ^
%MAVEN_DEBUG_OPTS% ^ %MAVEN_DEBUG_OPTS% ^
-classpath %CLASSWORLDS_JAR% ^ -classpath %CLASSWORLDS_JAR% ^
"-Dclassworlds.conf=%MVND_HOME%\bin\mvnd.conf" "-Dclassworlds.conf=%MVND_HOME%\bin\mvnd-client.conf" ^
"-Dmvnd.home=%MVND_HOME%" ^ "-Dmvnd.home=%MVND_HOME%" ^
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
%CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS% %CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS%

View File

@@ -219,7 +219,7 @@ exec "$JAVACMD" \
$MAVEN_OPTS \ $MAVEN_OPTS \
$MAVEN_DEBUG_OPTS \ $MAVEN_DEBUG_OPTS \
-classpath "${CLASSWORLDS_JAR}" \ -classpath "${CLASSWORLDS_JAR}" \
"-Dclassworlds.conf=${MVND_HOME}/bin/mvnd.conf" \ "-Dclassworlds.conf=${MVND_HOME}/bin/mvnd-client.conf" \
"-Dmvnd.home=${MVND_HOME}" \ "-Dmvnd.home=${MVND_HOME}" \
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${CLASSWORLDS_LAUNCHER} "$@" ${CLASSWORLDS_LAUNCHER} "$@"

View File

@@ -18,6 +18,9 @@ main is org.apache.maven.cli.MavenCli from plexus.core
set maven.conf default ${maven.home}/conf set maven.conf default ${maven.home}/conf
set logback.configurationFile default ${maven.conf}/logging/logback-mvn.xml
set logback.configurationFile.fallback default ${maven.conf}/logging/logback.xml
[plexus.core] [plexus.core]
load ${maven.conf}/logging load ${maven.conf}/logging
optionally ${maven.home}/lib/ext/*.jar optionally ${maven.home}/lib/ext/*.jar

View File

@@ -52,7 +52,7 @@ public class MavenConfNativeIT {
"-DforceStdout", "-DforceStdout",
"--raw-streams") "--raw-streams")
.assertSuccess(); .assertSuccess();
String conf = parameters.mvndHome().resolve("conf").toString(); String conf = parameters.mvndHome().resolve("mvn").resolve("conf").toString();
assertTrue( assertTrue(
o.getMessages().stream().anyMatch(m -> m.toString().contains(conf)), "Output should contain " + conf); o.getMessages().stream().anyMatch(m -> m.toString().contains(conf)), "Output should contain " + conf);
} }