Skip to content

Commit

Permalink
Small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Sep 30, 2019
1 parent a57bbff commit 9805f61
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 24 deletions.
16 changes: 9 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<artifactId>mvnd</artifactId>
<version>0.1-SNAPSHOT</version>

<packaging>takari-maven-component</packaging>
<packaging>jar</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -85,12 +85,14 @@
<groupId>io.takari.maven.plugins</groupId>
<artifactId>takari-lifecycle-plugin</artifactId>
<version>${takariLifecycleVersion}</version>
<extensions>true</extensions>
<configuration>
<proc>none</proc>
<source>1.8</source>
<target>1.8</target>
</configuration>
<executions>
<execution>
<goals>
<goal>sisu-index</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/distro/bin/mvnd
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,4 @@ exec "$JAVACMD" \
"-Dmaven.home=${MAVEN_HOME}" \
"-Dlibrary.jansi.path=${MAVEN_HOME}/lib/jansi-native" \
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${DAEMON_LAUNCHER} -T2C --builder smart "$@"
${DAEMON_LAUNCHER} -T1C --builder smart "$@"
24 changes: 14 additions & 10 deletions src/main/java/org/jboss/fuse/mvnd/daemon/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -46,19 +45,18 @@ public class Client {
public static final String DAEMON_DEBUG = "daemon.debug";

public static void main(String[] args) throws Exception {
LOGGER.debug("Starting client");

Path javaHome = Paths.get(System.getProperty("java.home")).normalize();
Path mavenHome = Paths.get(System.getProperty("maven.home"));
Path registryFile = mavenHome.resolve("daemon/registry.bin");
DaemonRegistry registry = new DaemonRegistry(registryFile);
Path javaHome = Layout.javaHome();
DaemonRegistry registry = DaemonRegistry.getDefault();
DaemonConnector connector = new DaemonConnector(registry, Client::startDaemon, new MessageSerializer());
List<String> opts = new ArrayList<>();
DaemonClientConnection daemon = connector.connect(new DaemonCompatibilitySpec(javaHome.toString(), opts));

daemon.dispatch(new Message.BuildRequest(
Arrays.asList(args),
System.getProperty("user.dir"),
System.getProperty("maven.multiModuleProjectDirectory")));
Layout.getProperty("user.dir"),
Layout.getProperty("maven.multiModuleProjectDirectory")));

List<String> log = new ArrayList<>();
LinkedHashMap<String, String> projects = new LinkedHashMap<>();
Expand Down Expand Up @@ -95,8 +93,13 @@ public static void main(String[] args) throws Exception {
}
}
display.update(Collections.emptyList(), 0);

LOGGER.debug("Done receiving, printing log");

log.forEach(terminal.writer()::println);
terminal.flush();

LOGGER.debug("Done !");
}

public static String startDaemon() {
Expand All @@ -111,9 +114,9 @@ public static String startDaemon() {
// args.add(classpath);

String uid = UUID.randomUUID().toString();
Path mavenHome = Paths.get(System.getProperty("maven.home")).normalize();
Path javaHome = Paths.get(System.getProperty("java.home")).normalize();
Path workingDir = Paths.get(System.getProperty("user.dir")).normalize();
Path mavenHome = Layout.mavenHome();
Path javaHome = Layout.javaHome();
Path workingDir = Layout.userDir();
String command = "";
try {
String classpath =
Expand All @@ -137,6 +140,7 @@ public static String startDaemon() {
args.add("-Dmaven.home=\"" + mavenHome + "\"");
args.add("-Dlogback.configurationFile=logback.xml");
args.add("-Ddaemon.uid=" + uid);
args.add("-Xmx4g");
if (System.getProperty(Server.DAEMON_IDLE_TIMEOUT) != null) {
args.add("-D" + Server.DAEMON_IDLE_TIMEOUT + "=" + System.getProperty(Server.DAEMON_IDLE_TIMEOUT));
}
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/org/jboss/fuse/mvnd/daemon/DaemonInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,20 @@ public DaemonInfo withState(DaemonState state) {
idleTimeout, locale, options, state, li, lb);
}

@Override
public String toString() {
return "DaemonInfo{" +
"uid='" + uid + '\'' +
", javaHome='" + javaHome + '\'' +
", mavenHome='" + mavenHome + '\'' +
", pid=" + pid +
", address=" + address +
", idleTimeout=" + idleTimeout +
", locale='" + locale + '\'' +
", options=" + options +
", state=" + state +
", lastIdle=" + lastIdle +
", lastBusy=" + lastBusy +
'}';
}
}
20 changes: 14 additions & 6 deletions src/main/java/org/jboss/fuse/mvnd/daemon/Layout.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,22 @@

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

public class Layout {

private static final Path MAVEN_HOME = Paths.get(System.getProperty("maven.home")).toAbsolutePath().normalize();

private static final Path JAVA_HOME = Paths.get(System.getProperty("java.home")).toAbsolutePath().normalize();

public static Path javaHome() {
return JAVA_HOME;
return Paths.get(getProperty("java.home")).toAbsolutePath().normalize();
}

public static Path mavenHome() {
return MAVEN_HOME;
return Paths.get(getProperty("maven.home")).toAbsolutePath().normalize();
}

public static Path userDir() {
return Paths.get(getProperty("user.dir")).toAbsolutePath().normalize();
}

public static Path registry() {
Expand All @@ -39,4 +42,9 @@ public static Path registry() {
public static Path daemonLog(String daemon) {
return mavenHome().resolve("daemon/daemon-" + daemon + ".log");
}

public static String getProperty(String key) {
return Objects.requireNonNull(System.getProperty(key), "Undefined system property: " + key);
}

}

0 comments on commit 9805f61

Please sign in to comment.