Added support for adding arbitrary classpath entries.
This commit is contained in:
@@ -345,6 +345,15 @@ public class Application
|
|||||||
return _resources;
|
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}.
|
* Returns the digest of the given {@code resource}.
|
||||||
*/
|
*/
|
||||||
@@ -751,6 +760,7 @@ public class Application
|
|||||||
_jvmargs.clear();
|
_jvmargs.clear();
|
||||||
_appargs.clear();
|
_appargs.clear();
|
||||||
_txtJvmArgs.clear();
|
_txtJvmArgs.clear();
|
||||||
|
_cpdirs.clear();
|
||||||
|
|
||||||
String appPrefix = _envc.appId == null ? "" : (_envc.appId + ".");
|
String appPrefix = _envc.appId == null ? "" : (_envc.appId + ".");
|
||||||
|
|
||||||
@@ -781,6 +791,9 @@ public class Application
|
|||||||
// look for custom arguments
|
// look for custom arguments
|
||||||
fillAssignmentListFromPairs("extra.txt", _txtJvmArgs);
|
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
|
// extract some info used to configure our child process on macOS
|
||||||
_dockName = config.getString("ui.name");
|
_dockName = config.getString("ui.name");
|
||||||
_dockIconPath = config.getString("ui.mac_dock_icon", "../desktop.icns");
|
_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> _codes = new ArrayList<>();
|
||||||
protected List<Resource> _resources = new ArrayList<>();
|
protected List<Resource> _resources = new ArrayList<>();
|
||||||
|
protected List<String> _cpdirs = new ArrayList<>();
|
||||||
|
|
||||||
protected int _verifyTimeout = 60;
|
protected int _verifyTimeout = 60;
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
|
|
||||||
@@ -40,9 +41,10 @@ public class PathBuilder
|
|||||||
public static ClassPath buildDefaultClassPath (Application app)
|
public static ClassPath buildDefaultClassPath (Application app)
|
||||||
{
|
{
|
||||||
LinkedHashSet<File> classPathEntries = new LinkedHashSet<File>();
|
LinkedHashSet<File> classPathEntries = new LinkedHashSet<File>();
|
||||||
for (Resource resource: app.getActiveCodeResources()) {
|
for (Resource resource : app.getActiveCodeResources()) {
|
||||||
classPathEntries.add(resource.getFinalTarget());
|
classPathEntries.add(resource.getFinalTarget());
|
||||||
}
|
}
|
||||||
|
addClassPathDirectories(app, classPathEntries);
|
||||||
return new ClassPath(classPathEntries);
|
return new ClassPath(classPathEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,15 +66,27 @@ public class PathBuilder
|
|||||||
|
|
||||||
ResourceCache cache = new ResourceCache(codeCacheDir);
|
ResourceCache cache = new ResourceCache(codeCacheDir);
|
||||||
LinkedHashSet<File> classPathEntries = new LinkedHashSet<>();
|
LinkedHashSet<File> classPathEntries = new LinkedHashSet<>();
|
||||||
for (Resource resource: app.getActiveCodeResources()) {
|
for (Resource resource : app.getActiveCodeResources()) {
|
||||||
String digest = app.getDigest(resource);
|
String digest = app.getDigest(resource);
|
||||||
File entry = cache.cacheFile(resource.getFinalTarget(), digest.substring(0, 2), digest);
|
File entry = cache.cacheFile(resource.getFinalTarget(), digest.substring(0, 2), digest);
|
||||||
classPathEntries.add(entry);
|
classPathEntries.add(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addClassPathDirectories(app, classPathEntries);
|
||||||
|
|
||||||
return new ClassPath(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
|
* 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
|
* nresource=[native jar]), unpacking them, and referencing the locations of each of the
|
||||||
|
|||||||
Reference in New Issue
Block a user