mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-09-10 21:22:03 +00:00
Merge pull request #57 from ppalaga/i56
Fix #56 Require Java 8+ instead of Java 11+ at runtime
This commit is contained in:
@@ -30,38 +30,21 @@
|
||||
<packaging>jar</packaging>
|
||||
<name>Maven Daemon - Client</name>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-compress</artifactId>
|
||||
<groupId>org.jboss.fuse.mvnd</groupId>
|
||||
<artifactId>mvnd-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.graalvm.nativeimage</groupId>
|
||||
<artifactId>svm</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jline</groupId>
|
||||
<artifactId>jline-terminal</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jline</groupId>
|
||||
<artifactId>jline-terminal-jansi</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@@ -84,6 +67,15 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<compilerArgs>
|
||||
<arg>--add-exports=java.base/sun.nio.ch=ALL-UNNAMED</arg>
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
@@ -114,7 +106,6 @@
|
||||
--allow-incomplete-classpath
|
||||
-H:IncludeResources=org/jboss/fuse/mvnd/.*
|
||||
-H:IncludeResources=org/jline/utils/.*
|
||||
-H:EnableURLProtocols=https
|
||||
</buildArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
@@ -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<Properties> 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<String> 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,
|
||||
|
@@ -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;
|
||||
|
@@ -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.
|
||||
*/
|
||||
|
@@ -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<String> 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);
|
||||
}
|
||||
|
@@ -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();
|
||||
|
||||
}
|
@@ -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<ClientLayout> 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;
|
||||
|
@@ -1,104 +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.svm;
|
||||
|
||||
import com.oracle.svm.core.annotate.Alias;
|
||||
import com.oracle.svm.core.annotate.KeepOriginal;
|
||||
import com.oracle.svm.core.annotate.RecomputeFieldValue;
|
||||
import com.oracle.svm.core.annotate.RecomputeFieldValue.Kind;
|
||||
import com.oracle.svm.core.annotate.Substitute;
|
||||
import com.oracle.svm.core.annotate.TargetClass;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.zip.ZipException;
|
||||
import org.apache.commons.compress.archivers.zip.AsiExtraField;
|
||||
import org.apache.commons.compress.archivers.zip.ExtraFieldParsingBehavior;
|
||||
import org.apache.commons.compress.archivers.zip.ExtraFieldUtils;
|
||||
import org.apache.commons.compress.archivers.zip.ExtraFieldUtils.UnparseableExtraField;
|
||||
import org.apache.commons.compress.archivers.zip.ZipExtraField;
|
||||
import org.apache.commons.compress.archivers.zip.ZipShort;
|
||||
|
||||
@TargetClass(ExtraFieldUtils.class)
|
||||
@Substitute
|
||||
public final class ExtraFieldUtilsSubstitution {
|
||||
|
||||
@Alias
|
||||
@RecomputeFieldValue(kind = Kind.None)
|
||||
private static final Map<ZipShort, Class<?>> implementations;
|
||||
|
||||
static {
|
||||
implementations = new ConcurrentHashMap<>();
|
||||
registerInst(new AsiExtraField());
|
||||
}
|
||||
|
||||
public static void registerInst(ZipExtraField ze) {
|
||||
implementations.put(ze.getHeaderId(), ze.getClass());
|
||||
}
|
||||
|
||||
@KeepOriginal
|
||||
public static ZipExtraField createExtraField(final ZipShort headerId)
|
||||
throws InstantiationException, IllegalAccessException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@KeepOriginal
|
||||
public static ZipExtraField createExtraFieldNoDefault(final ZipShort headerId)
|
||||
throws InstantiationException, IllegalAccessException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@KeepOriginal
|
||||
public static ZipExtraField[] parse(final byte[] data) throws ZipException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@KeepOriginal
|
||||
public static ZipExtraField[] parse(final byte[] data, final boolean local)
|
||||
throws ZipException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@KeepOriginal
|
||||
public static ZipExtraField[] parse(final byte[] data, final boolean local,
|
||||
final UnparseableExtraField onUnparseableData)
|
||||
throws ZipException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@KeepOriginal
|
||||
public static ZipExtraField[] parse(final byte[] data, final boolean local,
|
||||
final ExtraFieldParsingBehavior parsingBehavior)
|
||||
throws ZipException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@KeepOriginal
|
||||
public static byte[] mergeLocalFileDataData(final ZipExtraField[] data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@KeepOriginal
|
||||
public static byte[] mergeCentralDirectoryData(final ZipExtraField[] data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@KeepOriginal
|
||||
public static ZipExtraField fillExtraField(final ZipExtraField ze, final byte[] data, final int off,
|
||||
final int len, final boolean local) throws ZipException {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@@ -1,5 +0,0 @@
|
||||
# An absolute path to your Maven Daemon installation
|
||||
mvnd.home = %s
|
||||
|
||||
# java.home is optional if you have JAVA_HOME environment variable set
|
||||
%s
|
79
common/pom.xml
Normal file
79
common/pom.xml
Normal file
@@ -0,0 +1,79 @@
|
||||
<!--
|
||||
|
||||
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.
|
||||
|
||||
-->
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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.jboss.fuse.mvnd</groupId>
|
||||
<artifactId>mvnd</artifactId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mvnd-common</artifactId>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
<name>Maven Daemon - Common</name>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jline</groupId>
|
||||
<artifactId>jline-terminal</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jline</groupId>
|
||||
<artifactId>jline-terminal-jansi</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${basedir}/src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>io.takari.maven.plugins</groupId>
|
||||
<artifactId>takari-lifecycle-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>sisu-index</goal>
|
||||
</goals>
|
||||
<phase>process-classes</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jboss.fuse.mvnd.client;
|
||||
package org.jboss.fuse.mvnd.common;
|
||||
|
||||
import java.nio.Buffer;
|
||||
|
@@ -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;
|
@@ -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;
|
@@ -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;
|
@@ -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;
|
@@ -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 {
|
||||
|
@@ -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.
|
@@ -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:
|
@@ -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.
|
@@ -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
|
@@ -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;
|
@@ -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<String> 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<String> defaultSupplier) {
|
@@ -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<Properties> lazyMvndProperties(Path mvndPropertiesPath) {
|
||||
public static Supplier<Properties> lazyMvndProperties(Path mvndPropertiesPath) {
|
||||
return new Supplier<Properties>() {
|
||||
|
||||
private volatile Properties properties;
|
@@ -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;
|
@@ -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;
|
@@ -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;
|
@@ -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;
|
@@ -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;
|
@@ -37,7 +37,7 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jboss.fuse.mvnd</groupId>
|
||||
<artifactId>mvnd-client</artifactId>
|
||||
<artifactId>mvnd-common</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
|
@@ -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;
|
||||
|
||||
/**
|
||||
|
@@ -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 {
|
||||
|
@@ -30,6 +30,8 @@
|
||||
<name>Maven Daemon - Integration Tests</name>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<mvnd.home>${project.basedir}/../daemon/target/maven-distro/mvnd-${project.version}-${os.detected.name}-${os.arch}</mvnd.home>
|
||||
</properties>
|
||||
|
||||
@@ -49,6 +51,16 @@
|
||||
<artifactId>mvnd-daemon</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.fuse.mvnd</groupId>
|
||||
<artifactId>mvnd-common</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.fuse.mvnd</groupId>
|
||||
<artifactId>mvnd-client</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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.
|
||||
|
15
pom.xml
15
pom.xml
@@ -30,8 +30,8 @@
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
|
||||
<!-- dependency versions a..z -->
|
||||
<assertj.version>3.16.1</assertj.version>
|
||||
@@ -62,6 +62,7 @@
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>common</module>
|
||||
<module>client</module>
|
||||
<module>daemon</module>
|
||||
<module>integration-tests</module>
|
||||
@@ -154,6 +155,11 @@
|
||||
<artifactId>mvnd-client</artifactId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.fuse.mvnd</groupId>
|
||||
<artifactId>mvnd-common</artifactId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.fuse.mvnd</groupId>
|
||||
<artifactId>mvnd-daemon</artifactId>
|
||||
@@ -277,11 +283,6 @@ limitations under the License.</inlineHeader>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${compiler.version}</version>
|
||||
<configuration>
|
||||
<compilerArgs>
|
||||
<arg>--add-exports=java.base/sun.nio.ch=ALL-UNNAMED</arg>
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
Reference in New Issue
Block a user