Re-layout the distro so that mvn is not in bin #91

This commit is contained in:
Peter Palaga
2020-10-16 15:41:07 +02:00
parent 4ae7d3ad11
commit 56d5643ff8
12 changed files with 18 additions and 17 deletions

View File

@@ -54,7 +54,7 @@ public class ClientLayout extends Layout {
final Path mvndH = Paths.get(cmd.get()).getParent().getParent(); final Path mvndH = Paths.get(cmd.get()).getParent().getParent();
if (mvndH != null) { if (mvndH != null) {
final Path mvndDaemonLib = mvndH final Path mvndDaemonLib = mvndH
.resolve("lib/ext/mvnd-daemon-" + BuildProperties.getInstance().getVersion() .resolve("mvn/lib/ext/mvnd-daemon-" + BuildProperties.getInstance().getVersion()
+ ".jar"); + ".jar");
if (Files.exists(mvndDaemonLib)) { if (Files.exists(mvndDaemonLib)) {
return mvndH.toString(); return mvndH.toString();

View File

@@ -292,7 +292,7 @@ public class DaemonConnector {
} }
private Path findCommonJar(Path mavenHome) { private Path findCommonJar(Path mavenHome) {
final Path result = mavenHome.resolve("lib/ext/mvnd-common-" + buildProperties.getVersion() + ".jar"); final Path result = mavenHome.resolve("mvn/lib/ext/mvnd-common-" + buildProperties.getVersion() + ".jar");
if (!Files.isRegularFile(result)) { if (!Files.isRegularFile(result)) {
throw new RuntimeException("File must exist and must be a regular file: " + result); throw new RuntimeException("File must exist and must be a regular file: " + result);
} }

View File

@@ -26,11 +26,11 @@ public class ServerMain {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
final String uidStr = Environment.DAEMON_UID.systemProperty().orFail().asString(); final String uidStr = Environment.DAEMON_UID.systemProperty().orFail().asString();
final Path mavenHome = Environment.MVND_HOME.systemProperty().orFail().asPath(); final Path mvndHome = Environment.MVND_HOME.systemProperty().orFail().asPath();
URL[] classpath = Stream.concat( URL[] classpath = Stream.concat(
/* jars */ /* jars */
Stream.of("lib/ext", "lib", "boot") Stream.of("mvn/lib/ext", "mvn/lib", "mvn/boot")
.map(mavenHome::resolve) .map(mvndHome::resolve)
.flatMap((Path p) -> { .flatMap((Path p) -> {
try { try {
return Files.list(p); return Files.list(p);
@@ -41,7 +41,7 @@ public class ServerMain {
.filter(p -> p.getFileName().toString().endsWith(".jar")) .filter(p -> p.getFileName().toString().endsWith(".jar"))
.filter(Files::isRegularFile), .filter(Files::isRegularFile),
/* resources */ /* resources */
Stream.of(mavenHome.resolve("conf"), mavenHome.resolve("conf/logging"))) Stream.of(mvndHome.resolve("mvn/conf"), mvndHome.resolve("mvn/conf/logging")))
.map(Path::normalize) .map(Path::normalize)
.map(Path::toUri) .map(Path::toUri)

View File

@@ -196,7 +196,7 @@ exec "$JAVACMD" \
-Dmvnd.logging=mvns \ -Dmvnd.logging=mvns \
"-Dclassworlds.conf=${MAVEN_HOME}/bin/m2.conf" \ "-Dclassworlds.conf=${MAVEN_HOME}/bin/m2.conf" \
"-Dmvnd.home=${MAVEN_HOME}" \ "-Dmvnd.home=${MAVEN_HOME}" \
"-Dmaven.home=${MAVEN_HOME}" \ "-Dmaven.home=${MAVEN_HOME}/mvn" \
"-Dlibrary.jansi.path=${MAVEN_HOME}/lib/jansi-native" \ "-Dlibrary.jansi.path=${MAVEN_HOME}/lib/jansi-native" \
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${CLASSWORLDS_LAUNCHER} --builder smart --threads 0.5C "$@" ${CLASSWORLDS_LAUNCHER} --builder smart --threads 0.5C "$@"

View File

@@ -200,11 +200,11 @@ public class DaemonMavenCli {
// Make sure the Maven home directory is an absolute path to save us from confusion with say drive-relative // Make sure the Maven home directory is an absolute path to save us from confusion with say drive-relative
// Windows paths. // Windows paths.
// //
String mavenHome = System.getProperty("mvnd.home"); String mvndHome = System.getProperty("mvnd.home");
if (mavenHome != null) { if (mvndHome != null) {
System.setProperty("mvnd.home", new File(mavenHome).getAbsolutePath()); System.setProperty("mvnd.home", new File(mvndHome).getAbsolutePath());
System.setProperty("maven.home", new File(mavenHome).getAbsolutePath()); System.setProperty("maven.home", new File(mvndHome + "/mvn").getAbsolutePath());
} }
} }

View File

@@ -17,14 +17,14 @@
--> -->
<assembly> <assembly>
<artifactSet to="mvnd-${project.version}-${os.detected.name}-${os.detected.arch}"> <artifactSet to="mvnd-${project.version}-${os.detected.name}-${os.detected.arch}/mvn">
<artifact id="org.apache.maven:apache-maven:tar.gz:bin"> <artifact id="org.apache.maven:apache-maven:tar.gz:bin">
<unpack useRoot="false" <unpack useRoot="false"
excludes="lib/slf4j*,conf/logging/*,lib/maven-slf4j-provider*,bin/mvn*,lib/jansi-*.jar,lib/jansi-native/*"/> excludes="lib/slf4j*,conf/logging/*,lib/maven-slf4j-provider*,bin/mvn*,lib/jansi-*.jar,lib/jansi-native/*"/>
</artifact> </artifact>
</artifactSet> </artifactSet>
<artifactSet to="mvnd-${project.version}-${os.detected.name}-${os.detected.arch}/lib/ext"> <artifactSet to="mvnd-${project.version}-${os.detected.name}-${os.detected.arch}/mvn/lib/ext">
<artifact id="org.jboss.fuse.mvnd:mvnd-daemon:${project.version}"> <artifact id="org.jboss.fuse.mvnd:mvnd-daemon:${project.version}">
<exclusion id="org.codehaus.plexus:plexus-classworlds"/> <exclusion id="org.codehaus.plexus:plexus-classworlds"/>
<exclusion id="*:cdi-api"/> <exclusion id="*:cdi-api"/>

View File

@@ -37,17 +37,18 @@ public class DistroIT {
@Test @Test
void noDuplicateJars() { void noDuplicateJars() {
final Path mavenHome = Paths.get(System.getProperty("mvnd.home")); final Path mavenHome = Paths.get(System.getProperty("mvnd.home"));
Set<Avc> mavenLibs = streamJars(mavenHome, "lib", "boot").collect(Collectors.toCollection(TreeSet::new)); Set<Avc> mavenLibs = streamJars(mavenHome, "mvn/lib", "mvn/boot").collect(Collectors.toCollection(TreeSet::new));
Assertions.assertFalse(mavenLibs.isEmpty()); Assertions.assertFalse(mavenLibs.isEmpty());
final List<Avc> mvndJars = streamJars(mavenHome, "lib/ext").collect(Collectors.toList()); final List<Avc> mvndJars = streamJars(mavenHome, "mvn/lib/ext").collect(Collectors.toList());
Assertions.assertFalse(mvndJars.isEmpty()); Assertions.assertFalse(mvndJars.isEmpty());
final List<Avc> dups = mvndJars.stream() final List<Avc> dups = mvndJars.stream()
.filter(avc -> mavenLibs.stream().anyMatch(mvnAvc -> mvnAvc.sameArtifactId(avc))) .filter(avc -> mavenLibs.stream().anyMatch(mvnAvc -> mvnAvc.sameArtifactId(avc)))
.collect(Collectors.toList()); .collect(Collectors.toList());
final String msg = mavenHome.resolve("lib/ext") + " contains duplicates available in " + mavenHome.resolve("lib") final String msg = mavenHome.resolve("mvn/lib/ext") + " contains duplicates available in "
+ " or " + mavenHome.resolve("lib"); + mavenHome.resolve("mvn/lib")
+ " or " + mavenHome.resolve("mvn/lib");
Assertions.assertEquals(new ArrayList<String>(), dups, msg); Assertions.assertEquals(new ArrayList<String>(), dups, msg);
} }