Skip to content

Commit

Permalink
Merge pull request #96 from ppalaga/i91
Browse files Browse the repository at this point in the history
Re-layout the distro so that mvn is not in bin
  • Loading branch information
ppalaga authored Oct 16, 2020
2 parents f558784 + 56d5643 commit c4ec6c1
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static ClientLayout getEnvInstance() {
final Path mvndH = Paths.get(cmd.get()).getParent().getParent();
if (mvndH != null) {
final Path mvndDaemonLib = mvndH
.resolve("lib/ext/mvnd-daemon-" + BuildProperties.getInstance().getVersion()
.resolve("mvn/lib/ext/mvnd-daemon-" + BuildProperties.getInstance().getVersion()
+ ".jar");
if (Files.exists(mvndDaemonLib)) {
return mvndH.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ private String startDaemon() {
}

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)) {
throw new RuntimeException("File must exist and must be a regular file: " + result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ private void update(Runnable updater) {
}

private void doUpdate(Runnable updater) {
if (!Files.isReadable(getRegistryFile())) {
if (!Files.isReadable(registryFile)) {
throw new DaemonException("Registry became unaccessible");
}
try {
Expand Down Expand Up @@ -350,7 +350,8 @@ public void busyLockLong(long offset) throws InterruptedException, IllegalStateE
if (currentThread().isInterrupted())
throw new InterruptedException();
else
throw new IllegalStateException("Failed to acquire lock after " + BUSY_LOCK_LIMIT / 1e9 + " seconds.");
throw new IllegalStateException("Failed to lock offset " + offset + " of " + registryFile + " within "
+ BUSY_LOCK_LIMIT / 1e9 + " seconds.");
}

public void unlockLong(long offset) throws IllegalMonitorStateException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public class ServerMain {

public static void main(String[] args) throws Exception {
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(
/* jars */
Stream.of("lib/ext", "lib", "boot")
.map(mavenHome::resolve)
Stream.of("mvn/lib/ext", "mvn/lib", "mvn/boot")
.map(mvndHome::resolve)
.flatMap((Path p) -> {
try {
return Files.list(p);
Expand All @@ -41,7 +41,7 @@ public static void main(String[] args) throws Exception {
.filter(p -> p.getFileName().toString().endsWith(".jar"))
.filter(Files::isRegularFile),
/* 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::toUri)
Expand Down
2 changes: 1 addition & 1 deletion daemon/src/main/distro/bin/mvns
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ exec "$JAVACMD" \
-Dmvnd.logging=mvns \
"-Dclassworlds.conf=${MAVEN_HOME}/bin/m2.conf" \
"-Dmvnd.home=${MAVEN_HOME}" \
"-Dmaven.home=${MAVEN_HOME}" \
"-Dmaven.home=${MAVEN_HOME}/mvn" \
"-Dlibrary.jansi.path=${MAVEN_HOME}/lib/jansi-native" \
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${CLASSWORLDS_LAUNCHER} --builder smart --threads 0.5C "$@"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions daemon/src/main/java/org/apache/maven/cli/DaemonMavenCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,11 @@ void initialize(CliRequest cliRequest)
// Make sure the Maven home directory is an absolute path to save us from confusion with say drive-relative
// Windows paths.
//
String mavenHome = System.getProperty("mvnd.home");
String mvndHome = System.getProperty("mvnd.home");

if (mavenHome != null) {
System.setProperty("mvnd.home", new File(mavenHome).getAbsolutePath());
System.setProperty("maven.home", new File(mavenHome).getAbsolutePath());
if (mvndHome != null) {
System.setProperty("mvnd.home", new File(mvndHome).getAbsolutePath());
System.setProperty("maven.home", new File(mvndHome + "/mvn").getAbsolutePath());
}
}

Expand Down
4 changes: 2 additions & 2 deletions daemon/src/main/provisio/maven-distro.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
-->
<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">
<unpack useRoot="false"
excludes="lib/slf4j*,conf/logging/*,lib/maven-slf4j-provider*,bin/mvn*,lib/jansi-*.jar,lib/jansi-native/*"/>
</artifact>
</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}">
<exclusion id="org.codehaus.plexus:plexus-classworlds"/>
<exclusion id="*:cdi-api"/>
Expand Down
9 changes: 5 additions & 4 deletions daemon/src/test/java/org/jboss/fuse/mvnd/dist/DistroIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@ public class DistroIT {
@Test
void noDuplicateJars() {
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());
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());

final List<Avc> dups = mvndJars.stream()
.filter(avc -> mavenLibs.stream().anyMatch(mvnAvc -> mvnAvc.sameArtifactId(avc)))
.collect(Collectors.toList());

final String msg = mavenHome.resolve("lib/ext") + " contains duplicates available in " + mavenHome.resolve("lib")
+ " or " + mavenHome.resolve("lib");
final String msg = mavenHome.resolve("mvn/lib/ext") + " contains duplicates available in "
+ mavenHome.resolve("mvn/lib")
+ " or " + mavenHome.resolve("mvn/lib");
Assertions.assertEquals(new ArrayList<String>(), dups, msg);
}

Expand Down

0 comments on commit c4ec6c1

Please sign in to comment.