Skip to content

Commit

Permalink
Merge pull request nats-io#125 from nats-io/externalize-gnatsd
Browse files Browse the repository at this point in the history
Cross platform build fixes
  • Loading branch information
Colin Sullivan authored Jul 25, 2017
2 parents 51f8ee9 + 5c36607 commit e10590d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 29 deletions.
24 changes: 0 additions & 24 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,6 @@
<!-- Only unit tests are run by default. -->
<skip.integration.tests>true</skip.integration.tests>
<skip.unit.tests>false</skip.unit.tests>

<!-- Used for downloading and installing a server binary for tests -->
<server.version>0.9.6</server.version>
<server.exec.name>gnatsd</server.exec.name>
<server.exec.pkg>${server.exec.name}-v${server.version}-${nats.os}-${nats.arch}
</server.exec.pkg>
<server.exec.pkg.url>
https://github.com/nats-io/${server.exec.name}/releases/download/v${server.version}/${server.exec.pkg}.zip
</server.exec.pkg.url>
</properties>

<build>
Expand Down Expand Up @@ -177,21 +168,6 @@
</configuration>
<executions>
<execution>
<id>prepare</id>
<phase>pre-integration-test</phase>
<configuration>
<target xmlns:unless="ant:unless" xmlns:if="ant:if" name="copy-server-exec" unless:true="${server.installed}">
<condition property="server.installed" else="false">
<available file="${server.exec.name}" filepath="${project.build.directory}" type="file" />
</condition>
<echo if:true="${server.installed}" message="${server.exec.name} is already installed. Skipping download..." />
<echo unless:true="${server.installed}" message="Installing ${server.exec.pkg} as ${project.build.directory}/${server.exec.name}..." />
<get unless:true="${server.installed}" src="${server.exec.pkg.url}" dest="${project.build.directory}" skipexisting="true" />
<unzip unless:true="${server.installed}" src="${project.build.directory}/${server.exec.pkg}.zip" dest="${project.build.directory}" overwrite="false" />
<move unless:true="${server.installed}" file="${project.build.directory}/${server.exec.pkg}/${server.exec.name}" tofile="${project.build.directory}/${server.exec.name}" overwrite="false" />
<chmod perm="+x" file="${project.build.directory}/${server.exec.name}" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
Expand Down
22 changes: 17 additions & 5 deletions src/test/java/io/nats/client/NatsServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ public NatsServer(String configFile, boolean debug) {
}

private ProcessStartInfo createProcessStartInfo() {
String path = Paths.get("target", "/", GNATSD).toAbsolutePath().toString();
psInfo = new ProcessStartInfo(path);

// The NATS server must be on the path.
psInfo = new ProcessStartInfo(GNATSD);

if (debug) {
psInfo.addArgument("-DV");
Expand All @@ -106,15 +107,26 @@ private void start() {
System.err.println("Inheriting IO, psInfo =" + psInfo);
pb.inheritIO();
} else {
pb.redirectError(new File("/dev/null"));
pb.redirectOutput(new File("/dev/null"));
// All NATS server output goes to stderr
String errFile = "/dev/null";

String osName = System.getProperty("os.name");
if (osName != null && osName.contains("Windows")) {
// Windows uses the "nul" file.
errFile = "nul";
}

pb.redirectError(new File(errFile));
}
p = pb.start();
if (debug) {
System.out.println("Started [" + psInfo + "]");
}
} catch (IOException e) {
e.printStackTrace();
System.out.println("Unable to start [" + psInfo + "]. The NATS server " +
"must be installed and found in the path.\n" +
"See https://github.com/nats-io/gnatsd");
System.out.println(e.getMessage());
}
}

Expand Down

0 comments on commit e10590d

Please sign in to comment.