}
private static File processArgs(String[] args, Map<String, String> config, Collection<? super File> fileList, BundleContext context) throws Exception {
File output = new File(DEFAULT_FILENAME_COMPRESSED);
KnownBundleAnalyzer knownBundleAnalyzer = null;
File knownBundlesExtraFile = null;
for (int i = 0; i < args.length; i++) {
try {
if (args[i].startsWith("-n")) {
String repoName = args[++i];
config.put(ResourceIndexer.REPOSITORY_NAME, repoName);
} else if (args[i].equals("-stylesheet")) {
String styleSheet = args[++i];
config.put(ResourceIndexer.STYLESHEET, styleSheet);
} else if (args[i].startsWith("-r")) {
output = new File(args[++i]);
} else if (args[i].startsWith("-v")) {
config.put(ResourceIndexer.VERBOSE, Boolean.TRUE.toString());
} else if (args[i].startsWith("-d")) {
config.put(ResourceIndexer.ROOT_URL, args[++i]);
} else if (args[i].startsWith("-t")) {
String urlTemplate = args[++i];
config.put(ResourceIndexer.URL_TEMPLATE, urlTemplate);
} else if (args[i].startsWith("-l")) {
String licenceUrl = args[++i];
config.put(ResourceIndexer.LICENSE_URL, licenceUrl);
} else if (args[i].equalsIgnoreCase("--pretty")) {
output = new File(DEFAULT_FILENAME_UNCOMPRESSED);
config.put(ResourceIndexer.PRETTY, Boolean.toString(true));
} else if (args[i].equals("-K")) {
knownBundleAnalyzer = new KnownBundleAnalyzer(new Properties());
} else if (args[i].equals("-k")) {
knownBundlesExtraFile = new File(args[++i]);
} else if(args[i].equalsIgnoreCase("--noincrement")) {
config.put("-repository.increment.override", "");
} else if (args[i].startsWith("-h")) {
printUsage();
} else if (args[i].startsWith("-")) {
throw new Exception("Unknown argument");
} else {
fileList.add(new File(args[i]));
}
} catch (Exception e) {
System.err.println("Error in " + args[i] + " : " + e.getMessage());
System.exit(1);
}
}
if (knownBundleAnalyzer == null)
knownBundleAnalyzer = new KnownBundleAnalyzer();
if (knownBundlesExtraFile != null) {
Properties props = loadPropertiesFile(knownBundlesExtraFile);
knownBundleAnalyzer.setKnownBundlesExtra(props);
}
context.registerService(ResourceAnalyzer.class.getName(), knownBundleAnalyzer, null);
return output;