430747 - jetty-start / Allow --lib and module [lib] to recursively add jars
+ --lib={pattern} now supported + regular searching rules (for BaseHome) apply + even supporting multiple lib pattern entries via File.pathSeparator separation, resulting in support for command lines like this: --lib=/opt/common/lib/**.jar:lib/db/*.jar + {pattern} can be any valid java.nio.file.PathMatcher of syntax "glob:" (since we rely on File.pathSeparator to break apart the --lib line the existence of that same char in "glob:" and "regex:" means that supporting both syntaxes of (regex and glob) isn't going to make writing this line easy for the user. opting for glob only seems like a good compromise)
This commit is contained in:
parent
dfbe5c92c6
commit
2f6f210174
|
@ -217,6 +217,7 @@ public class BaseHome
|
||||||
if (FS.isValidDirectory(root))
|
if (FS.isValidDirectory(root))
|
||||||
{
|
{
|
||||||
PathFinder finder = new PathFinder();
|
PathFinder finder = new PathFinder();
|
||||||
|
finder.setIncludeDirsInResults(true);
|
||||||
finder.setFileMatcher(matcher);
|
finder.setFileMatcher(matcher);
|
||||||
finder.setBase(root);
|
finder.setBase(root);
|
||||||
Files.walkFileTree(root,SEARCH_VISIT_OPTIONS,MAX_SEARCH_DEPTH,finder);
|
Files.walkFileTree(root,SEARCH_VISIT_OPTIONS,MAX_SEARCH_DEPTH,finder);
|
||||||
|
@ -228,6 +229,7 @@ public class BaseHome
|
||||||
Path relativePath = PathMatchers.getSearchRoot(pattern);
|
Path relativePath = PathMatchers.getSearchRoot(pattern);
|
||||||
PathMatcher matcher = PathMatchers.getMatcher(pattern);
|
PathMatcher matcher = PathMatchers.getMatcher(pattern);
|
||||||
PathFinder finder = new PathFinder();
|
PathFinder finder = new PathFinder();
|
||||||
|
finder.setIncludeDirsInResults(true);
|
||||||
finder.setFileMatcher(matcher);
|
finder.setFileMatcher(matcher);
|
||||||
|
|
||||||
Path homePath = homeDir.toPath().resolve(relativePath);
|
Path homePath = homeDir.toPath().resolve(relativePath);
|
||||||
|
|
|
@ -568,6 +568,7 @@ public class Main
|
||||||
List<Module> activeModules = modules.resolveEnabled();
|
List<Module> activeModules = modules.resolveEnabled();
|
||||||
|
|
||||||
// 7) Lib & XML Expansion / Resolution
|
// 7) Lib & XML Expansion / Resolution
|
||||||
|
args.expandLibs(baseHome);
|
||||||
args.expandModules(baseHome,activeModules);
|
args.expandModules(baseHome,activeModules);
|
||||||
|
|
||||||
// 8) Resolve Extra XMLs
|
// 8) Resolve Extra XMLs
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class PathFinder extends SimpleFileVisitor<Path>
|
||||||
if (dirMatcher.matches(dir))
|
if (dirMatcher.matches(dir))
|
||||||
{
|
{
|
||||||
StartLog.debug("Following dir: " + dir);
|
StartLog.debug("Following dir: " + dir);
|
||||||
if (includeDirsInResults)
|
if (includeDirsInResults && fileMatcher.matches(dir))
|
||||||
{
|
{
|
||||||
addHit(dir);
|
addHit(dir);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import org.eclipse.jetty.start.Props.Prop;
|
import org.eclipse.jetty.start.Props.Prop;
|
||||||
|
|
||||||
|
@ -77,6 +78,7 @@ public class StartArgs
|
||||||
private Props properties = new Props();
|
private Props properties = new Props();
|
||||||
private Set<String> systemPropertyKeys = new HashSet<>();
|
private Set<String> systemPropertyKeys = new HashSet<>();
|
||||||
private List<String> jvmArgs = new ArrayList<>();
|
private List<String> jvmArgs = new ArrayList<>();
|
||||||
|
private List<String> rawLibs = new ArrayList<>();
|
||||||
private List<String> moduleStartdIni = new ArrayList<>();
|
private List<String> moduleStartdIni = new ArrayList<>();
|
||||||
private List<String> moduleStartIni = new ArrayList<>();
|
private List<String> moduleStartIni = new ArrayList<>();
|
||||||
private Map<String, String> propertySource = new HashMap<>();
|
private Map<String, String> propertySource = new HashMap<>();
|
||||||
|
@ -308,6 +310,27 @@ public class StartArgs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expand any command line added <code>--lib</code> lib references.
|
||||||
|
*
|
||||||
|
* @param baseHome
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public void expandLibs(BaseHome baseHome) throws IOException
|
||||||
|
{
|
||||||
|
for (String rawlibref : rawLibs)
|
||||||
|
{
|
||||||
|
StartLog.debug("rawlibref = " + rawlibref);
|
||||||
|
String libref = properties.expand(rawlibref);
|
||||||
|
StartLog.debug("expanded = " + libref);
|
||||||
|
|
||||||
|
for (Path libpath : baseHome.getPaths(libref))
|
||||||
|
{
|
||||||
|
classpath.addComponent(libpath.toFile());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build up the Classpath and XML file references based on enabled Module list.
|
* Build up the Classpath and XML file references based on enabled Module list.
|
||||||
*
|
*
|
||||||
|
@ -715,7 +738,15 @@ public class StartArgs
|
||||||
if (arg.startsWith("--lib="))
|
if (arg.startsWith("--lib="))
|
||||||
{
|
{
|
||||||
String cp = getValue(arg);
|
String cp = getValue(arg);
|
||||||
classpath.addClasspath(cp);
|
|
||||||
|
if (cp != null)
|
||||||
|
{
|
||||||
|
StringTokenizer t = new StringTokenizer(cp,File.pathSeparator);
|
||||||
|
while (t.hasMoreTokens())
|
||||||
|
{
|
||||||
|
rawLibs.add(t.nextToken());
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue