From e544191f1d59dbaf9aec6e1bd708bbe013c6661a Mon Sep 17 00:00:00 2001 From: Mark Payne Date: Tue, 9 Dec 2014 14:37:31 -0500 Subject: [PATCH] NIFIDEV-145: Bug fixes and pulled bootstrap into the assembly pom --- assemblies/nifi/pom.xml | 5 +++++ .../org/apache/nifi/bootstrap/RunNiFi.java | 22 ++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/assemblies/nifi/pom.xml b/assemblies/nifi/pom.xml index ec06a2327d..556b8fed70 100644 --- a/assemblies/nifi/pom.xml +++ b/assemblies/nifi/pom.xml @@ -119,6 +119,11 @@ nifi-runtime ${framework.version} + + org.apache.nifi + nifi-bootstrap + 0.0.1-SNAPSHOT + org.apache.nifi nifi-resources diff --git a/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/RunNiFi.java b/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/RunNiFi.java index ea3e5661bf..54932c8e8a 100644 --- a/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/RunNiFi.java +++ b/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/RunNiFi.java @@ -30,7 +30,6 @@ import java.net.InetSocketAddress; import java.net.Socket; import java.nio.charset.StandardCharsets; import java.nio.file.Files; -import java.nio.file.Path; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -250,7 +249,13 @@ public class RunNiFi { builder.directory(new File(specifiedWorkingDir)); } - final File workingDir = builder.directory(); + final File bootstrapConfigAbsoluteFile = bootstrapConfigFile.getAbsoluteFile(); + final File binDir = bootstrapConfigAbsoluteFile.getParentFile(); + final File workingDir = binDir.getParentFile(); + + if ( specifiedWorkingDir == null ) { + builder.directory(workingDir); + } final String libFilename = replaceNull(props.get("lib.dir"), "./lib").trim(); File libDir = getFile(libFilename, workingDir); @@ -295,13 +300,10 @@ public class RunNiFi { throw new RuntimeException("Could not find conf directory at " + confDir.getAbsolutePath()); } - final Path workingDirPath = workingDir.toPath(); final List cpFiles = new ArrayList<>(confFiles.length + libFiles.length); cpFiles.add(confDir.getAbsolutePath()); for ( final File file : libFiles ) { - final Path path = workingDirPath.relativize(file.toPath()); - final String cpPath = path.toString(); - cpFiles.add(cpPath); + cpFiles.add(file.getAbsolutePath()); } final StringBuilder classPathBuilder = new StringBuilder(); @@ -380,12 +382,12 @@ public class RunNiFi { } private File getFile(final String filename, final File workingDir) { - File libDir = new File(filename); - if ( !libDir.isAbsolute() ) { - libDir = new File(workingDir, filename); + File file = new File(filename); + if ( !file.isAbsolute() ) { + file = new File(workingDir, filename); } - return libDir; + return file; } private String replaceNull(final String value, final String replacement) {