434505 Allow property files on start.jar command line
Signed-off-by: Tom Zeller<tzeller@dragonacea.biz>
This commit is contained in:
parent
ed33bca02e
commit
d621df3c34
|
@ -195,6 +195,11 @@ public class FS
|
|||
return filename.toLowerCase(Locale.ENGLISH).endsWith(".xml");
|
||||
}
|
||||
|
||||
public static boolean isPropertyFile(String filename)
|
||||
{
|
||||
return filename.toLowerCase(Locale.ENGLISH).endsWith(".properties");
|
||||
}
|
||||
|
||||
public static String toRelativePath(File baseDir, File path)
|
||||
{
|
||||
return baseDir.toURI().relativize(path.toURI()).toASCIIString();
|
||||
|
|
|
@ -578,6 +578,9 @@ public class Main
|
|||
|
||||
// 8) Resolve Extra XMLs
|
||||
args.resolveExtraXmls(baseHome);
|
||||
|
||||
// 9) Resolve Property Files
|
||||
args.resolvePropertyFiles(baseHome);
|
||||
|
||||
return args;
|
||||
}
|
||||
|
|
|
@ -74,6 +74,8 @@ public class StartArgs
|
|||
private Classpath classpath;
|
||||
private List<String> xmlRefs = new ArrayList<>();
|
||||
private List<File> xmls = new ArrayList<>();
|
||||
private List<String> propertyFileRefs = new ArrayList<>();
|
||||
private List<File> propertyFiles = new ArrayList<>();
|
||||
private Props properties = new Props();
|
||||
private Set<String> systemPropertyKeys = new HashSet<>();
|
||||
private List<String> jvmArgs = new ArrayList<>();
|
||||
|
@ -129,6 +131,19 @@ public class StartArgs
|
|||
xmls.add(xmlfile);
|
||||
}
|
||||
}
|
||||
|
||||
private void addUniquePropertyFile(String propertyFileRef, File propertyFile) throws IOException
|
||||
{
|
||||
if (!FS.canReadFile(propertyFile))
|
||||
{
|
||||
throw new IOException("Cannot read file: " + propertyFileRef);
|
||||
}
|
||||
propertyFile = propertyFile.getCanonicalFile();
|
||||
if (!propertyFiles.contains(propertyFile))
|
||||
{
|
||||
propertyFiles.add(propertyFile);
|
||||
}
|
||||
}
|
||||
|
||||
public void dumpActiveXmls(BaseHome baseHome)
|
||||
{
|
||||
|
@ -482,6 +497,11 @@ public class StartArgs
|
|||
{
|
||||
cmd.addRawArg(xml.getAbsolutePath());
|
||||
}
|
||||
|
||||
for (File propertyFile : propertyFiles)
|
||||
{
|
||||
cmd.addRawArg(propertyFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
@ -896,6 +916,16 @@ public class StartArgs
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (FS.isPropertyFile(arg))
|
||||
{
|
||||
// only add non-duplicates
|
||||
if (!propertyFileRefs.contains(arg))
|
||||
{
|
||||
propertyFileRefs.add(arg);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Anything else is unrecognized
|
||||
throw new UsageException(ERR_BAD_ARG,"Unrecognized argument: \"%s\" in %s",arg,source);
|
||||
|
@ -925,6 +955,21 @@ public class StartArgs
|
|||
addUniqueXmlFile(xmlRef,xmlfile);
|
||||
}
|
||||
}
|
||||
|
||||
public void resolvePropertyFiles(BaseHome baseHome) throws IOException
|
||||
{
|
||||
// Find and Expand property files
|
||||
for (String propertyFileRef : propertyFileRefs)
|
||||
{
|
||||
// Straight Reference
|
||||
File propertyFile = baseHome.getFile(propertyFileRef);
|
||||
if (!propertyFile.exists())
|
||||
{
|
||||
propertyFile = baseHome.getFile("etc/" + propertyFileRef);
|
||||
}
|
||||
addUniquePropertyFile(propertyFileRef,propertyFile);
|
||||
}
|
||||
}
|
||||
|
||||
public void setAllModules(Modules allModules)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue