diff --git a/client/pom.xml b/client/pom.xml index 1e269768..112d5498 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -30,38 +30,21 @@ jar Maven Daemon - Client + + 11 + 11 + + - - org.apache.commons - commons-compress + org.jboss.fuse.mvnd + mvnd-common - org.graalvm.nativeimage svm provided - - - org.jline - jline-terminal - - - org.jline - jline-terminal-jansi - - - - org.slf4j - slf4j-simple - - - - org.junit.jupiter - junit-jupiter - test - @@ -84,6 +67,15 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + + --add-exports=java.base/sun.nio.ch=ALL-UNNAMED + + + diff --git a/client/src/main/java/org/jboss/fuse/mvnd/client/ClientLayout.java b/client/src/main/java/org/jboss/fuse/mvnd/client/ClientLayout.java index dd08abff..f3562d6c 100644 --- a/client/src/main/java/org/jboss/fuse/mvnd/client/ClientLayout.java +++ b/client/src/main/java/org/jboss/fuse/mvnd/client/ClientLayout.java @@ -15,11 +15,17 @@ */ package org.jboss.fuse.mvnd.client; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Objects; +import java.util.Optional; import java.util.Properties; import java.util.function.Supplier; +import org.jboss.fuse.mvnd.common.BuildProperties; +import org.jboss.fuse.mvnd.common.Environment; +import org.jboss.fuse.mvnd.common.Environment.ValueSource; +import org.jboss.fuse.mvnd.common.Layout; /** * Local paths relevant for the {@link DefaultClient}. @@ -38,7 +44,28 @@ public class ClientLayout extends Layout { final Path mvndPropertiesPath = Environment.findMvndPropertiesPath(); final Supplier mvndProperties = lazyMvndProperties(mvndPropertiesPath); final Path pwd = Paths.get(".").toAbsolutePath().normalize(); - final Path mvndHome = Environment.findMavenHome(mvndProperties, mvndPropertiesPath); + final Path mvndHome = Environment.findBasicMavenHome() + .orLocalProperty(mvndProperties, mvndPropertiesPath) + .or(new ValueSource( + description -> description.append("path relative to the mvnd executable"), + () -> { + Optional cmd = ProcessHandle.current().info().command(); + if (Environment.isNative() && cmd.isPresent()) { + final Path mvndH = Paths.get(cmd.get()).getParent().getParent(); + if (mvndH != null) { + final Path mvndDaemonLib = mvndH + .resolve("lib/ext/mvnd-daemon-" + BuildProperties.getInstance().getVersion() + + ".jar"); + if (Files.exists(mvndDaemonLib)) { + return mvndH.toString(); + } + } + } + return null; + })) + .orFail() + .asPath() + .toAbsolutePath().normalize(); ENV_INSTANCE = new ClientLayout( mvndPropertiesPath, mvndHome, diff --git a/client/src/main/java/org/jboss/fuse/mvnd/client/ClientOutput.java b/client/src/main/java/org/jboss/fuse/mvnd/client/ClientOutput.java index fa8db03a..ceb0d5c1 100644 --- a/client/src/main/java/org/jboss/fuse/mvnd/client/ClientOutput.java +++ b/client/src/main/java/org/jboss/fuse/mvnd/client/ClientOutput.java @@ -30,7 +30,7 @@ import java.util.Map.Entry; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingDeque; import java.util.function.Consumer; -import org.jboss.fuse.mvnd.client.Message.BuildException; +import org.jboss.fuse.mvnd.common.Message.BuildException; import org.jline.terminal.Size; import org.jline.terminal.Terminal; import org.jline.terminal.TerminalBuilder; diff --git a/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonClientConnection.java b/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonClientConnection.java index 51df6f07..0339db9e 100644 --- a/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonClientConnection.java +++ b/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonClientConnection.java @@ -17,6 +17,13 @@ package org.jboss.fuse.mvnd.client; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; +import org.jboss.fuse.mvnd.common.DaemonConnection; +import org.jboss.fuse.mvnd.common.DaemonException; +import org.jboss.fuse.mvnd.common.DaemonException.ConnectException; +import org.jboss.fuse.mvnd.common.DaemonException.MessageIOException; +import org.jboss.fuse.mvnd.common.DaemonException.StaleAddressException; +import org.jboss.fuse.mvnd.common.DaemonInfo; +import org.jboss.fuse.mvnd.common.Message; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -83,7 +90,7 @@ public class DaemonClientConnection { connection.close(); } - interface StaleAddressDetector { + public interface StaleAddressDetector { /** * @return true if the failure should be considered due to a stale address. */ diff --git a/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonConnector.java b/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonConnector.java index e0b03c74..c7204dbc 100644 --- a/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonConnector.java +++ b/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonConnector.java @@ -30,14 +30,27 @@ import java.util.Optional; import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; -import org.jboss.fuse.mvnd.client.DaemonCompatibilitySpec.Result; +import org.jboss.fuse.mvnd.common.BuildProperties; +import org.jboss.fuse.mvnd.common.DaemonCompatibilitySpec; +import org.jboss.fuse.mvnd.common.DaemonCompatibilitySpec.Result; +import org.jboss.fuse.mvnd.common.DaemonConnection; +import org.jboss.fuse.mvnd.common.DaemonDiagnostics; +import org.jboss.fuse.mvnd.common.DaemonException; +import org.jboss.fuse.mvnd.common.DaemonInfo; +import org.jboss.fuse.mvnd.common.DaemonRegistry; +import org.jboss.fuse.mvnd.common.DaemonState; +import org.jboss.fuse.mvnd.common.DaemonStopEvent; +import org.jboss.fuse.mvnd.common.Environment; +import org.jboss.fuse.mvnd.common.Message; +import org.jboss.fuse.mvnd.common.Serializer; +import org.jboss.fuse.mvnd.common.ServerMain; import org.jboss.fuse.mvnd.jpm.Process; import org.jboss.fuse.mvnd.jpm.ScriptUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import static java.lang.Thread.sleep; -import static org.jboss.fuse.mvnd.client.DaemonState.Canceled; +import static org.jboss.fuse.mvnd.common.DaemonState.Canceled; /** * File origin: @@ -238,7 +251,7 @@ public class DaemonConnector { final Path workingDir = layout.userDir(); String command = ""; try { - String classpath = findClientJar(mavenHome).toString(); + String classpath = findCommonJar(mavenHome).toString(); final String java = ScriptUtils.isWindows() ? "bin\\java.exe" : "bin/java"; List args = new ArrayList<>(); args.add("\"" + layout.javaHome().resolve(java) + "\""); @@ -270,8 +283,8 @@ public class DaemonConnector { } } - private Path findClientJar(Path mavenHome) { - final Path result = mavenHome.resolve("lib/ext/mvnd-client-" + buildProperties.getVersion() + ".jar"); + private Path findCommonJar(Path mavenHome) { + final Path result = mavenHome.resolve("lib/ext/mvnd-common-" + buildProperties.getVersion() + ".jar"); if (!Files.isRegularFile(result)) { throw new RuntimeException("File must exist and must be a regular file: " + result); } diff --git a/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonStarter.java b/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonStarter.java deleted file mode 100644 index 1f99d2fc..00000000 --- a/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonStarter.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2019 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. - */ -package org.jboss.fuse.mvnd.client; - -public interface DaemonStarter { - - String startDaemon(); - -} diff --git a/client/src/main/java/org/jboss/fuse/mvnd/client/DefaultClient.java b/client/src/main/java/org/jboss/fuse/mvnd/client/DefaultClient.java index a8dfa438..38466c01 100644 --- a/client/src/main/java/org/jboss/fuse/mvnd/client/DefaultClient.java +++ b/client/src/main/java/org/jboss/fuse/mvnd/client/DefaultClient.java @@ -24,14 +24,19 @@ import java.time.ZoneId; import java.util.ArrayList; import java.util.List; import java.util.Properties; -import java.util.concurrent.TimeUnit; import java.util.function.Supplier; import org.fusesource.jansi.Ansi; import org.jboss.fuse.mvnd.client.ClientOutput.TerminalOutput; -import org.jboss.fuse.mvnd.client.Message.BuildEvent; -import org.jboss.fuse.mvnd.client.Message.BuildException; -import org.jboss.fuse.mvnd.client.Message.BuildMessage; -import org.jboss.fuse.mvnd.client.Message.MessageSerializer; +import org.jboss.fuse.mvnd.common.BuildProperties; +import org.jboss.fuse.mvnd.common.DaemonCompatibilitySpec; +import org.jboss.fuse.mvnd.common.DaemonInfo; +import org.jboss.fuse.mvnd.common.DaemonRegistry; +import org.jboss.fuse.mvnd.common.Environment; +import org.jboss.fuse.mvnd.common.Message; +import org.jboss.fuse.mvnd.common.Message.BuildEvent; +import org.jboss.fuse.mvnd.common.Message.BuildException; +import org.jboss.fuse.mvnd.common.Message.BuildMessage; +import org.jboss.fuse.mvnd.common.Message.MessageSerializer; import org.jboss.fuse.mvnd.jpm.ProcessImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,7 +44,6 @@ import org.slf4j.LoggerFactory; public class DefaultClient implements Client { private static final Logger LOGGER = LoggerFactory.getLogger(DefaultClient.class); - public static final int DEFAULT_IDLE_TIMEOUT = (int) TimeUnit.HOURS.toMillis(3); public static final int DEFAULT_PERIODIC_CHECK_INTERVAL_MILLIS = 10 * 1000; public static final int CANCEL_TIMEOUT = 10 * 1000; private final Supplier lazyLayout; @@ -200,10 +204,10 @@ public class DefaultClient implements Client { case ProjectStarted: case MojoStarted: case MojoStopped: - output.projectStateChanged(be.projectId, be.display); + output.projectStateChanged(be.getProjectId(), be.getDisplay()); break; case ProjectStopped: - output.projectFinished(be.projectId); + output.projectFinished(be.getProjectId()); } } else if (m instanceof BuildMessage) { BuildMessage bm = (BuildMessage) m; diff --git a/common/pom.xml b/common/pom.xml new file mode 100644 index 00000000..58bf95b8 --- /dev/null +++ b/common/pom.xml @@ -0,0 +1,84 @@ + + + + 4.0.0 + + org.jboss.fuse.mvnd + mvnd + 0.1.0-SNAPSHOT + + + mvnd-common + + jar + Maven Daemon - Common + + + + + org.apache.commons + commons-compress + + + + org.jline + jline-terminal + + + org.jline + jline-terminal-jansi + + + + org.slf4j + slf4j-simple + + + + org.junit.jupiter + junit-jupiter + test + + + + + + + ${basedir}/src/main/resources + true + + + + + io.takari.maven.plugins + takari-lifecycle-plugin + + + + sisu-index + + process-classes + + + + + + + \ No newline at end of file diff --git a/client/src/main/java/org/jboss/fuse/mvnd/client/BufferCaster.java b/common/src/main/java/org/jboss/fuse/mvnd/common/BufferCaster.java similarity index 97% rename from client/src/main/java/org/jboss/fuse/mvnd/client/BufferCaster.java rename to common/src/main/java/org/jboss/fuse/mvnd/common/BufferCaster.java index 66792aac..e8719b21 100644 --- a/client/src/main/java/org/jboss/fuse/mvnd/client/BufferCaster.java +++ b/common/src/main/java/org/jboss/fuse/mvnd/common/BufferCaster.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.jboss.fuse.mvnd.client; +package org.jboss.fuse.mvnd.common; import java.nio.Buffer; diff --git a/client/src/main/java/org/jboss/fuse/mvnd/client/BuildProperties.java b/common/src/main/java/org/jboss/fuse/mvnd/common/BuildProperties.java similarity index 97% rename from client/src/main/java/org/jboss/fuse/mvnd/client/BuildProperties.java rename to common/src/main/java/org/jboss/fuse/mvnd/common/BuildProperties.java index 7044dec8..e0728504 100644 --- a/client/src/main/java/org/jboss/fuse/mvnd/client/BuildProperties.java +++ b/common/src/main/java/org/jboss/fuse/mvnd/common/BuildProperties.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jboss.fuse.mvnd.client; +package org.jboss.fuse.mvnd.common; import java.io.IOException; import java.io.InputStream; diff --git a/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonCompatibilitySpec.java b/common/src/main/java/org/jboss/fuse/mvnd/common/DaemonCompatibilitySpec.java similarity index 98% rename from client/src/main/java/org/jboss/fuse/mvnd/client/DaemonCompatibilitySpec.java rename to common/src/main/java/org/jboss/fuse/mvnd/common/DaemonCompatibilitySpec.java index de0d2e8d..5d5ab8e3 100644 --- a/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonCompatibilitySpec.java +++ b/common/src/main/java/org/jboss/fuse/mvnd/common/DaemonCompatibilitySpec.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jboss.fuse.mvnd.client; +package org.jboss.fuse.mvnd.common; import java.nio.file.Path; import java.nio.file.Paths; diff --git a/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonConnection.java b/common/src/main/java/org/jboss/fuse/mvnd/common/DaemonConnection.java similarity index 99% rename from client/src/main/java/org/jboss/fuse/mvnd/client/DaemonConnection.java rename to common/src/main/java/org/jboss/fuse/mvnd/common/DaemonConnection.java index 0bd4e282..f533077f 100755 --- a/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonConnection.java +++ b/common/src/main/java/org/jboss/fuse/mvnd/common/DaemonConnection.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.jboss.fuse.mvnd.client; +package org.jboss.fuse.mvnd.common; import java.io.Closeable; import java.io.DataInputStream; diff --git a/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonDiagnostics.java b/common/src/main/java/org/jboss/fuse/mvnd/common/DaemonDiagnostics.java similarity index 98% rename from client/src/main/java/org/jboss/fuse/mvnd/client/DaemonDiagnostics.java rename to common/src/main/java/org/jboss/fuse/mvnd/common/DaemonDiagnostics.java index 4852c2bb..f0749aca 100644 --- a/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonDiagnostics.java +++ b/common/src/main/java/org/jboss/fuse/mvnd/common/DaemonDiagnostics.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jboss.fuse.mvnd.client; +package org.jboss.fuse.mvnd.common; import java.io.BufferedReader; import java.io.IOException; diff --git a/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonException.java b/common/src/main/java/org/jboss/fuse/mvnd/common/DaemonException.java similarity index 98% rename from client/src/main/java/org/jboss/fuse/mvnd/client/DaemonException.java rename to common/src/main/java/org/jboss/fuse/mvnd/common/DaemonException.java index 09feb92e..06b7c06c 100644 --- a/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonException.java +++ b/common/src/main/java/org/jboss/fuse/mvnd/common/DaemonException.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jboss.fuse.mvnd.client; +package org.jboss.fuse.mvnd.common; public class DaemonException extends RuntimeException { diff --git a/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonExpirationStatus.java b/common/src/main/java/org/jboss/fuse/mvnd/common/DaemonExpirationStatus.java similarity index 96% rename from client/src/main/java/org/jboss/fuse/mvnd/client/DaemonExpirationStatus.java rename to common/src/main/java/org/jboss/fuse/mvnd/common/DaemonExpirationStatus.java index 97d608d7..22207579 100644 --- a/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonExpirationStatus.java +++ b/common/src/main/java/org/jboss/fuse/mvnd/common/DaemonExpirationStatus.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jboss.fuse.mvnd.client; +package org.jboss.fuse.mvnd.common; /** * Expiration status for daemon expiration check results. diff --git a/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonInfo.java b/common/src/main/java/org/jboss/fuse/mvnd/common/DaemonInfo.java similarity index 96% rename from client/src/main/java/org/jboss/fuse/mvnd/client/DaemonInfo.java rename to common/src/main/java/org/jboss/fuse/mvnd/common/DaemonInfo.java index d6816622..97c9ba0b 100644 --- a/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonInfo.java +++ b/common/src/main/java/org/jboss/fuse/mvnd/common/DaemonInfo.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jboss.fuse.mvnd.client; +package org.jboss.fuse.mvnd.common; import java.util.List; -import static org.jboss.fuse.mvnd.client.DaemonState.Busy; -import static org.jboss.fuse.mvnd.client.DaemonState.Idle; +import static org.jboss.fuse.mvnd.common.DaemonState.Busy; +import static org.jboss.fuse.mvnd.common.DaemonState.Idle; /** * File origin: diff --git a/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonRegistry.java b/common/src/main/java/org/jboss/fuse/mvnd/common/DaemonRegistry.java similarity index 99% rename from client/src/main/java/org/jboss/fuse/mvnd/client/DaemonRegistry.java rename to common/src/main/java/org/jboss/fuse/mvnd/common/DaemonRegistry.java index 9d24d68c..64c022cc 100644 --- a/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonRegistry.java +++ b/common/src/main/java/org/jboss/fuse/mvnd/common/DaemonRegistry.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.jboss.fuse.mvnd.client; +package org.jboss.fuse.mvnd.common; import java.io.File; import java.io.IOException; @@ -41,8 +41,8 @@ import org.slf4j.LoggerFactory; import sun.misc.Unsafe; import sun.nio.ch.DirectBuffer; -import static org.jboss.fuse.mvnd.client.DaemonState.Canceled; -import static org.jboss.fuse.mvnd.client.DaemonState.Idle; +import static org.jboss.fuse.mvnd.common.DaemonState.Canceled; +import static org.jboss.fuse.mvnd.common.DaemonState.Idle; /** * Access to daemon registry files. Useful also for testing. diff --git a/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonState.java b/common/src/main/java/org/jboss/fuse/mvnd/common/DaemonState.java similarity index 96% rename from client/src/main/java/org/jboss/fuse/mvnd/client/DaemonState.java rename to common/src/main/java/org/jboss/fuse/mvnd/common/DaemonState.java index e0364da2..6fd9256d 100644 --- a/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonState.java +++ b/common/src/main/java/org/jboss/fuse/mvnd/common/DaemonState.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jboss.fuse.mvnd.client; +package org.jboss.fuse.mvnd.common; /** * File origin diff --git a/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonStopEvent.java b/common/src/main/java/org/jboss/fuse/mvnd/common/DaemonStopEvent.java similarity index 98% rename from client/src/main/java/org/jboss/fuse/mvnd/client/DaemonStopEvent.java rename to common/src/main/java/org/jboss/fuse/mvnd/common/DaemonStopEvent.java index 51dbadcd..e8c26c84 100644 --- a/client/src/main/java/org/jboss/fuse/mvnd/client/DaemonStopEvent.java +++ b/common/src/main/java/org/jboss/fuse/mvnd/common/DaemonStopEvent.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.jboss.fuse.mvnd.client; +package org.jboss.fuse.mvnd.common; import java.io.Serializable; import java.text.DateFormat; diff --git a/client/src/main/java/org/jboss/fuse/mvnd/client/Environment.java b/common/src/main/java/org/jboss/fuse/mvnd/common/Environment.java similarity index 88% rename from client/src/main/java/org/jboss/fuse/mvnd/client/Environment.java rename to common/src/main/java/org/jboss/fuse/mvnd/common/Environment.java index f2969926..e622f627 100644 --- a/client/src/main/java/org/jboss/fuse/mvnd/client/Environment.java +++ b/common/src/main/java/org/jboss/fuse/mvnd/common/Environment.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jboss.fuse.mvnd.client; +package org.jboss.fuse.mvnd.common; import java.io.IOException; import java.nio.file.Files; @@ -110,8 +110,7 @@ public enum Environment { public static EnvValue findBasicMavenHome() { return MVND_HOME .environmentVariable() - .orSystemProperty() - .orRelativeMvndHome(); + .orSystemProperty(); } public static Path findMultiModuleProjectDirectory(Path pwd) { @@ -226,27 +225,8 @@ public enum Environment { return new EnvValue(this, envKey, envKey.environmentVariableSource()); } - /** - * @return mvnd home autodetected from the location of the currently running mvnd native executable or nothing - * if we do not run in native or if {@code ProcessHandle.current().info().command()} is not available. - */ - public EnvValue orRelativeMvndHome() { - return new EnvValue(this, envKey, new ValueSource( - description -> description.append("path relative to the mvnd executable"), - () -> { - Optional cmd = ProcessHandle.current().info().command(); - if (isNative() && cmd.isPresent()) { - final Path mvndHome = Paths.get(cmd.get()).getParent().getParent(); - if (mvndHome != null) { - final Path mvndDaemonLib = mvndHome - .resolve("lib/ext/mvnd-daemon-" + BuildProperties.getInstance().getVersion() + ".jar"); - if (Files.exists(mvndDaemonLib)) { - return mvndHome.toString(); - } - } - } - return null; - })); + public EnvValue or(ValueSource source) { + return new EnvValue(this, envKey, source); } public Environment.EnvValue orDefault(Supplier defaultSupplier) { diff --git a/client/src/main/java/org/jboss/fuse/mvnd/client/Layout.java b/common/src/main/java/org/jboss/fuse/mvnd/common/Layout.java similarity index 89% rename from client/src/main/java/org/jboss/fuse/mvnd/client/Layout.java rename to common/src/main/java/org/jboss/fuse/mvnd/common/Layout.java index 3164977c..daf1d36c 100644 --- a/client/src/main/java/org/jboss/fuse/mvnd/client/Layout.java +++ b/common/src/main/java/org/jboss/fuse/mvnd/common/Layout.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jboss.fuse.mvnd.client; +package org.jboss.fuse.mvnd.common; import java.io.IOException; import java.io.InputStream; @@ -72,14 +72,18 @@ public class Layout { ENV_INSTANCE = new Layout( mvndPropertiesPath, - Environment.findMavenHome(mvndProperties, mvndPropertiesPath), + Environment.findBasicMavenHome() + .orLocalProperty(mvndProperties, mvndPropertiesPath) + .orFail() + .asPath() + .toAbsolutePath().normalize(), pwd, Environment.findMultiModuleProjectDirectory(pwd)); } return ENV_INSTANCE; } - static Supplier lazyMvndProperties(Path mvndPropertiesPath) { + public static Supplier lazyMvndProperties(Path mvndPropertiesPath) { return new Supplier() { private volatile Properties properties; diff --git a/client/src/main/java/org/jboss/fuse/mvnd/client/Message.java b/common/src/main/java/org/jboss/fuse/mvnd/common/Message.java similarity index 99% rename from client/src/main/java/org/jboss/fuse/mvnd/client/Message.java rename to common/src/main/java/org/jboss/fuse/mvnd/common/Message.java index dccad5fa..07b00319 100644 --- a/client/src/main/java/org/jboss/fuse/mvnd/client/Message.java +++ b/common/src/main/java/org/jboss/fuse/mvnd/common/Message.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jboss.fuse.mvnd.client; +package org.jboss.fuse.mvnd.common; import java.io.DataInputStream; import java.io.DataOutputStream; diff --git a/client/src/main/java/org/jboss/fuse/mvnd/client/Serializer.java b/common/src/main/java/org/jboss/fuse/mvnd/common/Serializer.java similarity index 97% rename from client/src/main/java/org/jboss/fuse/mvnd/client/Serializer.java rename to common/src/main/java/org/jboss/fuse/mvnd/common/Serializer.java index 456041b9..33d0e1b7 100644 --- a/client/src/main/java/org/jboss/fuse/mvnd/client/Serializer.java +++ b/common/src/main/java/org/jboss/fuse/mvnd/common/Serializer.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jboss.fuse.mvnd.client; +package org.jboss.fuse.mvnd.common; import java.io.DataInputStream; import java.io.DataOutputStream; diff --git a/client/src/main/java/org/jboss/fuse/mvnd/client/ServerMain.java b/common/src/main/java/org/jboss/fuse/mvnd/common/ServerMain.java similarity index 98% rename from client/src/main/java/org/jboss/fuse/mvnd/client/ServerMain.java rename to common/src/main/java/org/jboss/fuse/mvnd/common/ServerMain.java index f5866a7c..c4a0d88b 100644 --- a/client/src/main/java/org/jboss/fuse/mvnd/client/ServerMain.java +++ b/common/src/main/java/org/jboss/fuse/mvnd/common/ServerMain.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jboss.fuse.mvnd.client; +package org.jboss.fuse.mvnd.common; import java.net.MalformedURLException; import java.net.URL; diff --git a/client/src/main/resources/org/jboss/fuse/mvnd/client/build.properties b/common/src/main/resources/org/jboss/fuse/mvnd/common/build.properties similarity index 100% rename from client/src/main/resources/org/jboss/fuse/mvnd/client/build.properties rename to common/src/main/resources/org/jboss/fuse/mvnd/common/build.properties diff --git a/client/src/main/resources/org/jboss/fuse/mvnd/client/mvnd.properties.template b/common/src/main/resources/org/jboss/fuse/mvnd/common/mvnd.properties.template similarity index 100% rename from client/src/main/resources/org/jboss/fuse/mvnd/client/mvnd.properties.template rename to common/src/main/resources/org/jboss/fuse/mvnd/common/mvnd.properties.template diff --git a/client/src/test/java/org/jboss/fuse/mvnd/client/DaemonRegistryTest.java b/common/src/test/java/org/jboss/fuse/mvnd/common/DaemonRegistryTest.java similarity index 98% rename from client/src/test/java/org/jboss/fuse/mvnd/client/DaemonRegistryTest.java rename to common/src/test/java/org/jboss/fuse/mvnd/common/DaemonRegistryTest.java index 7a9037da..f8f81210 100644 --- a/client/src/test/java/org/jboss/fuse/mvnd/client/DaemonRegistryTest.java +++ b/common/src/test/java/org/jboss/fuse/mvnd/common/DaemonRegistryTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jboss.fuse.mvnd.client; +package org.jboss.fuse.mvnd.common; import java.io.File; import java.io.IOException; diff --git a/client/src/test/java/org/jboss/fuse/mvnd/client/EnvironmentTest.java b/common/src/test/java/org/jboss/fuse/mvnd/common/EnvironmentTest.java similarity index 99% rename from client/src/test/java/org/jboss/fuse/mvnd/client/EnvironmentTest.java rename to common/src/test/java/org/jboss/fuse/mvnd/common/EnvironmentTest.java index 625fa1b7..0fe66850 100644 --- a/client/src/test/java/org/jboss/fuse/mvnd/client/EnvironmentTest.java +++ b/common/src/test/java/org/jboss/fuse/mvnd/common/EnvironmentTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jboss.fuse.mvnd.client; +package org.jboss.fuse.mvnd.common; import java.nio.file.Paths; import java.util.HashMap; diff --git a/daemon/pom.xml b/daemon/pom.xml index 6c9c6381..86347901 100644 --- a/daemon/pom.xml +++ b/daemon/pom.xml @@ -37,7 +37,7 @@ org.jboss.fuse.mvnd - mvnd-client + mvnd-common org.slf4j diff --git a/daemon/src/main/java/org/jboss/fuse/mvnd/daemon/DaemonExpiration.java b/daemon/src/main/java/org/jboss/fuse/mvnd/daemon/DaemonExpiration.java index ba5ce028..242f7d0c 100644 --- a/daemon/src/main/java/org/jboss/fuse/mvnd/daemon/DaemonExpiration.java +++ b/daemon/src/main/java/org/jboss/fuse/mvnd/daemon/DaemonExpiration.java @@ -23,15 +23,15 @@ import java.util.List; import java.util.Objects; import java.util.function.ToLongFunction; import java.util.stream.Collectors; -import org.jboss.fuse.mvnd.client.DaemonCompatibilitySpec; -import org.jboss.fuse.mvnd.client.DaemonCompatibilitySpec.Result; -import org.jboss.fuse.mvnd.client.DaemonExpirationStatus; -import org.jboss.fuse.mvnd.client.DaemonInfo; -import org.jboss.fuse.mvnd.client.DaemonState; +import org.jboss.fuse.mvnd.common.DaemonCompatibilitySpec; +import org.jboss.fuse.mvnd.common.DaemonCompatibilitySpec.Result; +import org.jboss.fuse.mvnd.common.DaemonExpirationStatus; +import org.jboss.fuse.mvnd.common.DaemonInfo; +import org.jboss.fuse.mvnd.common.DaemonState; -import static org.jboss.fuse.mvnd.client.DaemonExpirationStatus.DO_NOT_EXPIRE; -import static org.jboss.fuse.mvnd.client.DaemonExpirationStatus.GRACEFUL_EXPIRE; -import static org.jboss.fuse.mvnd.client.DaemonExpirationStatus.QUIET_EXPIRE; +import static org.jboss.fuse.mvnd.common.DaemonExpirationStatus.DO_NOT_EXPIRE; +import static org.jboss.fuse.mvnd.common.DaemonExpirationStatus.GRACEFUL_EXPIRE; +import static org.jboss.fuse.mvnd.common.DaemonExpirationStatus.QUIET_EXPIRE; import static org.jboss.fuse.mvnd.daemon.DaemonExpiration.DaemonExpirationResult.NOT_TRIGGERED; /** diff --git a/daemon/src/main/java/org/jboss/fuse/mvnd/daemon/Server.java b/daemon/src/main/java/org/jboss/fuse/mvnd/daemon/Server.java index 8db11966..5a1d91c5 100644 --- a/daemon/src/main/java/org/jboss/fuse/mvnd/daemon/Server.java +++ b/daemon/src/main/java/org/jboss/fuse/mvnd/daemon/Server.java @@ -37,36 +37,37 @@ import java.util.concurrent.locks.ReentrantLock; import org.apache.maven.cli.CliRequest; import org.apache.maven.cli.CliRequestBuilder; import org.apache.maven.cli.DaemonMavenCli; -import org.jboss.fuse.mvnd.client.DaemonConnection; -import org.jboss.fuse.mvnd.client.DaemonException; -import org.jboss.fuse.mvnd.client.DaemonExpirationStatus; -import org.jboss.fuse.mvnd.client.DaemonInfo; -import org.jboss.fuse.mvnd.client.DaemonRegistry; -import org.jboss.fuse.mvnd.client.DaemonState; -import org.jboss.fuse.mvnd.client.DaemonStopEvent; -import org.jboss.fuse.mvnd.client.DefaultClient; -import org.jboss.fuse.mvnd.client.Environment; -import org.jboss.fuse.mvnd.client.Layout; -import org.jboss.fuse.mvnd.client.Message; -import org.jboss.fuse.mvnd.client.Message.BuildEvent; -import org.jboss.fuse.mvnd.client.Message.BuildEvent.Type; -import org.jboss.fuse.mvnd.client.Message.BuildException; -import org.jboss.fuse.mvnd.client.Message.BuildMessage; -import org.jboss.fuse.mvnd.client.Message.BuildRequest; -import org.jboss.fuse.mvnd.client.Message.MessageSerializer; +import org.jboss.fuse.mvnd.common.DaemonConnection; +import org.jboss.fuse.mvnd.common.DaemonException; +import org.jboss.fuse.mvnd.common.DaemonExpirationStatus; +import org.jboss.fuse.mvnd.common.DaemonInfo; +import org.jboss.fuse.mvnd.common.DaemonRegistry; +import org.jboss.fuse.mvnd.common.DaemonState; +import org.jboss.fuse.mvnd.common.DaemonStopEvent; +import org.jboss.fuse.mvnd.common.Environment; +import org.jboss.fuse.mvnd.common.Layout; +import org.jboss.fuse.mvnd.common.Message; +import org.jboss.fuse.mvnd.common.Message.BuildEvent; +import org.jboss.fuse.mvnd.common.Message.BuildEvent.Type; +import org.jboss.fuse.mvnd.common.Message.BuildException; +import org.jboss.fuse.mvnd.common.Message.BuildMessage; +import org.jboss.fuse.mvnd.common.Message.BuildRequest; +import org.jboss.fuse.mvnd.common.Message.MessageSerializer; import org.jboss.fuse.mvnd.daemon.DaemonExpiration.DaemonExpirationResult; import org.jboss.fuse.mvnd.daemon.DaemonExpiration.DaemonExpirationStrategy; import org.jboss.fuse.mvnd.logging.smart.AbstractLoggingSpy; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static org.jboss.fuse.mvnd.client.DaemonState.Busy; -import static org.jboss.fuse.mvnd.client.DaemonState.StopRequested; -import static org.jboss.fuse.mvnd.client.DaemonState.Stopped; +import static org.jboss.fuse.mvnd.common.DaemonState.Busy; +import static org.jboss.fuse.mvnd.common.DaemonState.StopRequested; +import static org.jboss.fuse.mvnd.common.DaemonState.Stopped; public class Server implements AutoCloseable, Runnable { private static final Logger LOGGER = LoggerFactory.getLogger(Server.class); + public static final int CANCEL_TIMEOUT = 10 * 1000; + public static final int DEFAULT_IDLE_TIMEOUT = (int) TimeUnit.HOURS.toMillis(3); private String uid; private ServerSocketChannel socket; @@ -92,7 +93,7 @@ public class Server implements AutoCloseable, Runnable { final int idleTimeout = Environment.DAEMON_IDLE_TIMEOUT .systemProperty() - .orDefault(() -> String.valueOf(DefaultClient.DEFAULT_IDLE_TIMEOUT)) + .orDefault(() -> String.valueOf(DEFAULT_IDLE_TIMEOUT)) .asInt(); executor = Executors.newScheduledThreadPool(1); strategy = DaemonExpiration.master(); @@ -336,7 +337,7 @@ public class Server implements AutoCloseable, Runnable { } private void cancelNow() { - long time = System.currentTimeMillis() + DefaultClient.CANCEL_TIMEOUT; + long time = System.currentTimeMillis() + CANCEL_TIMEOUT; // LOGGER.debug("Cancel requested: will wait for daemon to become idle."); // try { diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 53a89532..413e9e1c 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -30,6 +30,8 @@ Maven Daemon - Integration Tests + 11 + 11 ${project.basedir}/../daemon/target/maven-distro/mvnd-${project.version}-${os.detected.name}-${os.arch} @@ -49,6 +51,16 @@ mvnd-daemon test + + org.jboss.fuse.mvnd + mvnd-common + test + + + org.jboss.fuse.mvnd + mvnd-client + test + org.junit.jupiter junit-jupiter diff --git a/integration-tests/src/test/java/org/jboss/fuse/mvnd/it/StopStatusTest.java b/integration-tests/src/test/java/org/jboss/fuse/mvnd/it/StopStatusTest.java index 756148aa..325a730f 100644 --- a/integration-tests/src/test/java/org/jboss/fuse/mvnd/it/StopStatusTest.java +++ b/integration-tests/src/test/java/org/jboss/fuse/mvnd/it/StopStatusTest.java @@ -22,9 +22,9 @@ import org.assertj.core.api.Assertions; import org.jboss.fuse.mvnd.assertj.MatchInOrderAmongOthers; import org.jboss.fuse.mvnd.client.Client; import org.jboss.fuse.mvnd.client.ClientOutput; -import org.jboss.fuse.mvnd.client.DaemonInfo; -import org.jboss.fuse.mvnd.client.DaemonRegistry; -import org.jboss.fuse.mvnd.client.DaemonState; +import org.jboss.fuse.mvnd.common.DaemonInfo; +import org.jboss.fuse.mvnd.common.DaemonRegistry; +import org.jboss.fuse.mvnd.common.DaemonState; import org.jboss.fuse.mvnd.junit.MvndTest; import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; diff --git a/integration-tests/src/test/java/org/jboss/fuse/mvnd/junit/MvndNativeTest.java b/integration-tests/src/test/java/org/jboss/fuse/mvnd/junit/MvndNativeTest.java index 8c85b3ce..a16768ff 100644 --- a/integration-tests/src/test/java/org/jboss/fuse/mvnd/junit/MvndNativeTest.java +++ b/integration-tests/src/test/java/org/jboss/fuse/mvnd/junit/MvndNativeTest.java @@ -34,7 +34,7 @@ public @interface MvndNativeTest { String projectDir(); /** - * Timeout for {@link Client#execute(org.jboss.fuse.mvnd.client.ClientOutput, java.util.List)} in seconds + * Timeout for {@link Client#execute(org.jboss.fuse.mvnd.common.ClientOutput, java.util.List)} in seconds */ long timeoutSec() default 300; } diff --git a/integration-tests/src/test/java/org/jboss/fuse/mvnd/junit/MvndTestExtension.java b/integration-tests/src/test/java/org/jboss/fuse/mvnd/junit/MvndTestExtension.java index 17e15e84..5084e69c 100644 --- a/integration-tests/src/test/java/org/jboss/fuse/mvnd/junit/MvndTestExtension.java +++ b/integration-tests/src/test/java/org/jboss/fuse/mvnd/junit/MvndTestExtension.java @@ -25,13 +25,13 @@ import java.util.Comparator; import java.util.List; import java.util.Objects; import java.util.stream.Stream; -import org.jboss.fuse.mvnd.client.BuildProperties; import org.jboss.fuse.mvnd.client.Client; -import org.jboss.fuse.mvnd.client.DaemonInfo; -import org.jboss.fuse.mvnd.client.DaemonRegistry; import org.jboss.fuse.mvnd.client.DefaultClient; -import org.jboss.fuse.mvnd.client.Environment; -import org.jboss.fuse.mvnd.client.Layout; +import org.jboss.fuse.mvnd.common.BuildProperties; +import org.jboss.fuse.mvnd.common.DaemonInfo; +import org.jboss.fuse.mvnd.common.DaemonRegistry; +import org.jboss.fuse.mvnd.common.Environment; +import org.jboss.fuse.mvnd.common.Layout; import org.jboss.fuse.mvnd.jpm.ProcessImpl; import org.junit.jupiter.api.extension.AfterAllCallback; import org.junit.jupiter.api.extension.BeforeAllCallback; diff --git a/integration-tests/src/test/java/org/jboss/fuse/mvnd/junit/NativeTestClient.java b/integration-tests/src/test/java/org/jboss/fuse/mvnd/junit/NativeTestClient.java index 268cbcf3..837d1406 100644 --- a/integration-tests/src/test/java/org/jboss/fuse/mvnd/junit/NativeTestClient.java +++ b/integration-tests/src/test/java/org/jboss/fuse/mvnd/junit/NativeTestClient.java @@ -30,8 +30,8 @@ import java.util.stream.Collectors; import org.jboss.fuse.mvnd.client.Client; import org.jboss.fuse.mvnd.client.ClientLayout; import org.jboss.fuse.mvnd.client.ClientOutput; -import org.jboss.fuse.mvnd.client.Environment; import org.jboss.fuse.mvnd.client.ExecutionResult; +import org.jboss.fuse.mvnd.common.Environment; /** * A wrapper around the native executable. diff --git a/pom.xml b/pom.xml index 9ec5a980..438656ba 100644 --- a/pom.xml +++ b/pom.xml @@ -30,8 +30,8 @@ UTF-8 - 11 - 11 + 8 + 8 3.16.1 @@ -62,6 +62,7 @@ + common client daemon integration-tests @@ -154,6 +155,11 @@ mvnd-client 0.1.0-SNAPSHOT + + org.jboss.fuse.mvnd + mvnd-common + 0.1.0-SNAPSHOT + org.jboss.fuse.mvnd mvnd-daemon @@ -277,11 +283,6 @@ limitations under the License. org.apache.maven.plugins maven-compiler-plugin ${compiler.version} - - - --add-exports=java.base/sun.nio.ch=ALL-UNNAMED - - org.apache.maven.plugins