public static List<Component> getComponents(File appDir) { List<Component> components = new ArrayList<>(); for (Bundle bundle : Bundle.getBundles(new File(appDir, ApplicationPackage.COMPONENT_DIR))) { components.add(new Component(bundle, new ComponentInfo(new File(ApplicationPackage.COMPONENT_DIR, bundle.getFile().getName()).getPath()))); } return components; }
private void addAllDefsFromBundles(Map<ConfigDefinitionKey, UnparsedConfigDefinition> defs, List<Component> components) { for (Component component : components) { Bundle bundle = component.getBundle(); for (final Bundle.DefEntry def : bundle.getDefEntries()) { final ConfigDefinitionKey defKey = new ConfigDefinitionKey(def.defName, def.defNamespace); if (!defs.containsKey(defKey)) { defs.put(defKey, new UnparsedConfigDefinition() { @Override public ConfigDefinition parse() { DefParser parser = new DefParser(defKey.getName(), new StringReader(def.contents)); return ConfigDefinitionBuilder.createConfigDefinition(parser.getTree()); } @Override public String getUnparsedContent() { return def.contents; } }); } } } }
private void copyUserDefsIntoApplication() { File destination = appSubDirs.configDefs(); destination.mkdir(); ConfigDefinitionDir defDir = new ConfigDefinitionDir(destination); // Copy the user's def files from components. List<Bundle> bundlesAdded = new ArrayList<>(); for (FilesApplicationPackage.Component component : FilesApplicationPackage.getComponents(appSubDirs.root())) { Bundle bundle = component.getBundle(); defDir.addConfigDefinitionsFromBundle(bundle, bundlesAdded); bundlesAdded.add(bundle); } }