Added support for adding arbitrary classpath entries.

This commit is contained in:
Michael Bayne
2020-01-06 14:14:52 -08:00
parent 0c8a29deb0
commit bb995508d9
2 changed files with 30 additions and 2 deletions
@@ -345,6 +345,15 @@ public class Application
return _resources;
}
/**
* Returns a list of strings (usually file paths relative to the app root dir) to add to the
* classpath.
*/
public List<String> getClassPathDirectories ()
{
return _cpdirs;
}
/**
* Returns the digest of the given {@code resource}.
*/
@@ -751,6 +760,7 @@ public class Application
_jvmargs.clear();
_appargs.clear();
_txtJvmArgs.clear();
_cpdirs.clear();
String appPrefix = _envc.appId == null ? "" : (_envc.appId + ".");
@@ -781,6 +791,9 @@ public class Application
// look for custom arguments
fillAssignmentListFromPairs("extra.txt", _txtJvmArgs);
// add any extra classpath entries
addAll(config.getMultiValue(appPrefix + "classpath"), _cpdirs);
// extract some info used to configure our child process on macOS
_dockName = config.getString("ui.name");
_dockIconPath = config.getString("ui.mac_dock_icon", "../desktop.icns");
@@ -1758,6 +1771,7 @@ public class Application
protected List<Resource> _codes = new ArrayList<>();
protected List<Resource> _resources = new ArrayList<>();
protected List<String> _cpdirs = new ArrayList<>();
protected int _verifyTimeout = 60;
@@ -9,6 +9,7 @@ import java.io.File;
import java.io.IOException;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.zip.ZipFile;
@@ -43,6 +44,7 @@ public class PathBuilder
for (Resource resource : app.getActiveCodeResources()) {
classPathEntries.add(resource.getFinalTarget());
}
addClassPathDirectories(app, classPathEntries);
return new ClassPath(classPathEntries);
}
@@ -70,9 +72,21 @@ public class PathBuilder
classPathEntries.add(entry);
}
addClassPathDirectories(app, classPathEntries);
return new ClassPath(classPathEntries);
}
private static void addClassPathDirectories (Application app, Set<File> classPathEntries) {
for (String cpdir : app.getClassPathDirectories()) {
File cpfile = new File(cpdir);
if (!cpfile.isAbsolute()) {
cpfile = new File(app.getAppDir(), cpdir);
}
classPathEntries.add(cpfile);
}
}
/**
* Builds a {@link ClassPath} instance by first caching all native jars (indicated by
* nresource=[native jar]), unpacking them, and referencing the locations of each of the