ChefCookbookAnalyzer { public CookbookParseResult compileCookbook(CookbookParseResult cookbookParseResult, boolean saveToToscaRepo) { CookbookParseResult oldParseResult = new CookbookParseResult(cookbookParseResult); List<CrawlCookbookRunnable> crawlCookbookRunnableList = new ArrayList<>(); cookbookParseResult = returnComponentTypesFromMetadata(cookbookParseResult); if ( cookbookParseResult == null) { return oldParseResult; } if (cookbookParseResult.getAllConfigsAsList().size() > 0) { LinkedHashMap<String,String> dependencies = cookbookParseResult.getAllConfigsAsList().get(0).getDepends(); String pathDependencies = cookbookParseResult.getCookbookPath() + Defaults.DEPENDENCIE_FOLDER; for (String key : dependencies.keySet()) { String versionRestriciton = dependencies.get(key); CrawlCookbookRunnable crawlDependency = new CrawlCookbookRunnable(key, versionRestriciton, pathDependencies, Defaults.TEMP_FOLDER_PATH); crawlDependency.start(); crawlCookbookRunnableList.add(crawlDependency); } } if (cookbookParseResult.isInRecursiveTransformation() == false ) { cookbookParseResult = addPlatformVersionInformationFromKitchen(cookbookParseResult); } for (int i = 0; i < crawlCookbookRunnableList.size(); i++) { try { crawlCookbookRunnableList.get(i).join(); } catch (InterruptedException e) { LOGGER.info("Crawling process of dependent cookbook " + crawlCookbookRunnableList.get(i).getThreadName() + " interrupted"); } } cookbookParseResult = returnComponentTypesFromAttributes(cookbookParseResult); cookbookParseResult = returnComponentTypesFromRecipes(cookbookParseResult); for (Map.Entry<String,String> entry : cookbookParseResult.getAllConfigsAsList().get(0).getDepends().entrySet()) { String key = entry.getKey(); LOGGER.info("Cookbook: " + key + " is resolved now"); CookbookParseResult dependentParseResult = new CookbookParseResult(cookbookParseResult); dependentParseResult.prepareForDependencie(key); if (dependentParseResult.getAllConfigsAsList().size() > 0) { compileCookbook(dependentParseResult, saveToToscaRepo); } } List<ChefCookbookConfiguration> cookbookConfigsList = cookbookParseResult.getAllConfigsAsList(); for (int count = 0; count < cookbookConfigsList.size(); count++) { cookbookConfigsList.get(count).printConfiguration(); } if (saveToToscaRepo) { new ParseResultToscaConverter().saveToscaNodeTypes(new ParseResultToscaConverter().convertCookbookConfigurationToToscaNode(cookbookParseResult)); } LOGGER.info("Finished parsing"); return cookbookParseResult; }  void main(); CookbookParseResult compileCookbook(CookbookParseResult cookbookParseResult, boolean saveToToscaRepo); static CookbookParseResult compile(CharStream input, CookbookParseResult cookbookConfigs); static CookbookParseResult getParseResultFromFile(CookbookParseResult cookbookConfigs, String rbFilePath);  }
@Test public void compileMyAppCookbook() { String cookbookName = "myapp"; String cookbookPath; ClassLoader classLoader = getClass().getClassLoader(); File file = new File(classLoader.getResource(cookbookName).getFile()); CookbookParseResult cookbookParseResult = new CookbookParseResult(cookbookName); cookbookPath = file.getAbsolutePath().replace("\\", "/"); cookbookParseResult.setCookbookPath(cookbookPath); cookbookParseResult = new ChefCookbookAnalyzer().compileCookbook(cookbookParseResult, false); cookbookParseResult.clear(); file = new File(classLoader.getResource("myapp/dependencies").getFile()); CrawledCookbooks.deleteFile(file.getPath()); }