public void loadPackageMappings(Path rulesPath) { try (GraphContext graphContext = graphContextFactory.create(false)) { WindupConfigurationModel configurationModel = WindupConfigurationService.getConfigurationModel(graphContext); FileModel windupRulesPath = new FileService(graphContext).createByFilePath(rulesPath.toString()); configurationModel.addUserRulesPath(windupRulesPath); RuleLoaderContext ruleLoaderContext = new RuleLoaderContext(Collections.singleton(rulesPath), null); RuleProviderRegistry registry = cache.getRuleProviderRegistry(ruleLoaderContext); this.event = new GraphRewrite(graphContext); RuleSubset ruleSubset = RuleSubset.create(registry.getConfiguration()); new RuleVisit(ruleSubset).accept((r) -> { if (r instanceof PackageNameMapping) { ((PackageNameMapping) r).preRulesetEvaluation(event); } }); graphContext.clear(); } catch (Exception e) { LOG.log(Level.WARNING, "Failed to load rule information due to: " + e.getMessage(), e); } } }
public void loadPackageMappings(Path rulesPath) { try (GraphContext graphContext = graphContextFactory.create(false)) { WindupConfigurationModel configurationModel = WindupConfigurationService.getConfigurationModel(graphContext); FileModel windupRulesPath = new FileService(graphContext).createByFilePath(rulesPath.toString()); configurationModel.addUserRulesPath(windupRulesPath); RuleLoaderContext ruleLoaderContext = new RuleLoaderContext(Collections.singleton(rulesPath), null); RuleProviderRegistry registry = cache.getRuleProviderRegistry(ruleLoaderContext); this.event = new GraphRewrite(graphContext); RuleSubset ruleSubset = RuleSubset.create(registry.getConfiguration()); new RuleVisit(ruleSubset).accept((r) -> { if (r instanceof PackageNameMapping) { ((PackageNameMapping) r).preRulesetEvaluation(event); } }); graphContext.clear(); } catch (Exception e) { LOG.log(Level.WARNING, "Failed to load rule information due to: " + e.getMessage(), e); } } }