diff options
author | Jan Srnicek <jsrnicek@cisco.com> | 2017-07-10 15:03:37 +0200 |
---|---|---|
committer | Jan Srnicek <jsrnicek@cisco.com> | 2017-07-10 15:03:37 +0200 |
commit | f6a03970c2e59d040012b6a457997361a318e8b2 (patch) | |
tree | d13c0a5775a7e23dd71b385b326306e69331ee4c /common/common-scripts | |
parent | ebe59de368dc1971b8a3460c17a561cec5c3a928 (diff) |
HONEYCOMB-373 - Remove local module mapping
Change-Id: Ic3a8a843168baed85cc31e0a09f9aa21cf691d1a
Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'common/common-scripts')
-rw-r--r-- | common/common-scripts/src/main/groovy/io/fd/honeycomb/common/scripts/ModuleYangIndexGenerator.groovy | 49 |
1 files changed, 3 insertions, 46 deletions
diff --git a/common/common-scripts/src/main/groovy/io/fd/honeycomb/common/scripts/ModuleYangIndexGenerator.groovy b/common/common-scripts/src/main/groovy/io/fd/honeycomb/common/scripts/ModuleYangIndexGenerator.groovy index 21877c51c..042ce6132 100644 --- a/common/common-scripts/src/main/groovy/io/fd/honeycomb/common/scripts/ModuleYangIndexGenerator.groovy +++ b/common/common-scripts/src/main/groovy/io/fd/honeycomb/common/scripts/ModuleYangIndexGenerator.groovy @@ -91,21 +91,10 @@ class ModuleYangIndexGenerator { log.info "Pairing distribution modules ${modules} to yang modules" def moduleToYangModulesIndex = new HashMap<String, String>() - def outputDir = project.getBuild().getOutputDirectory() - // TODO - HONEYCOMB-373 - eliminate local matching after distribution modules are moved to separate project - // first ,matches modules against local files, helps to filter local classpath modules, to reduce scope - // of dependency scanning that is more performance heavy - log.info "Pairing against local classpath" - pairAgainsLocalFiles(outputDir, modules, moduleToYangModulesIndex, log) - - // go to dependencies only if some modules are left. this occurs for modules - // started by distribution that are not part of its classpath(basically all plugin modules) - if (!modules.isEmpty()) { - log.info "Pairing against dependencies" - // The rest of the modules is looked up in dependencies - pairAgainsDependencyArtifacts(project, modules, log, moduleToYangModulesIndex) - } + log.info "Pairing against dependencies" + // The rest of the modules is looked up in dependencies + pairAgainsDependencyArtifacts(project, modules, log, moduleToYangModulesIndex) // for ex.: /target/honeycomb-minimal-resources/yang-mapping def yangMappingFolder = Paths.get(project.getBuild().getOutputDirectory(), StartupScriptGenerator.MINIMAL_RESOURCES_FOLDER, YANG_MAPPING_FOLDER).toFile() @@ -180,38 +169,6 @@ class ModuleYangIndexGenerator { log.info "Modules left after dependency pairing $modules" } - // TODO - HONEYCOMB-373 - eliminate local matching - private static void pairAgainsLocalFiles(outputDir, modules, HashMap<String, String> index, log) { - // Pairs modules that are part of distribution classpath - def yangModulesLocalConfig = Paths.get(outputDir, YANG_MODULES_FOLDER, YANG_MODULES_FILE_NAME).toFile() - if (!yangModulesLocalConfig.exists()) { - log.debug "Local configuration for yang modules does not exist, skiping local matching" - return - } - - log.info "Local file ${yangModulesLocalConfig}" - def localYangModules = fixDelimiters(FileUtils.readFileToString(yangModulesLocalConfig, StandardCharsets.UTF_8)) - - log.info "Output dir $outputDir" - FileUtils.listFiles(Paths.get(outputDir).toFile(), EXTENSIONS, true) - .stream() - .map { file -> file.getPath() } - .map { path -> relativizePath(path, outputDir) } - .forEach { path -> - for (String module : modules) { - if (path.equals(classNameToPath(module))) { - log.info "Module $module found in local classpath" - // mapping by standard class name - index.put(module, localYangModules) - } - } - } - - // remove all matching modules to reduce scope of search - modules.removeAll(index.keySet()); - log.info "Modules left after local classpath pairing $modules" - } - private static String relativizePath(String path, String outputDir) { return path.replace(outputDir, "").substring(1).trim(); } |