/** * Convert path from sources module descriptor for using on distribution /classes && /classes_gen * converts to bundle home path * * @param originalPath Original path from sources module descriptor * @return Converted path, null if path meaningless on packaged module */ @Nullable private String convertPath( String originalPath, IFile bundleHome, IFile sourcesDescriptorFile, ModuleDescriptor descriptor) { MacroHelper macroHelper = MacrosFactory.forModuleFile(sourcesDescriptorFile); String canonicalPath = FileUtil.getCanonicalPath(originalPath).toLowerCase(); // /classes && /classes_gen hack String suffix = descriptor.getCompileInMPS() ? CLASSES_GEN : CLASSES; if (canonicalPath.endsWith(suffix)) { // MacrosFactory based on original descriptor file because we use original descriptor file for // ModuleDescriptor reading, so all paths expanded to original descriptor file String classes = macroHelper.expandPath("${module}/" + suffix); if (FileUtil.getCanonicalPath(classes).equalsIgnoreCase(canonicalPath)) { return bundleHome.getPath(); } } else if (FileUtil.getCanonicalPath(bundleHome.getPath()).equalsIgnoreCase(canonicalPath)) { return bundleHome.getPath(); } // ${mps_home}/lib String mpsHomeLibPath = FileUtil.getCanonicalPath(PathManager.getHomePath() + File.separator + "lib").toLowerCase(); if (canonicalPath.startsWith(mpsHomeLibPath)) { return canonicalPath; } // we used to keep originalPath if it has a macro not known to MPS here. // However, the check has been deprecated in 2012 and thus removed. I'm not 100% sure what // 'meaningless' in the contract of the method means. Of course, unknown macros make no sense // for us // and thus null is legitimate answer, OTOH, custom macros might have a lot of meaning to // someone else. // // ignore paths starts from ${module}/${project} etc return null; }
private void fill(SNode module, ModuleDescriptor source) { SPropertyOperations.set(module, "uuid", source.getUUID()); SPropertyOperations.set(module, "namespace", source.getNamespace()); SPropertyOperations.set(module, "compileInMPS", "" + source.getCompileInMPS()); for (ModelRoot root : source.getModelRoots()) { SLinkOperations.getTargets(module, "modelRoots", true).add(convert(root)); } for (Dependency mdep : source.getDependencies()) { SLinkOperations.getTargets(module, "dependencies", true).add(convert(mdep)); } for (ModuleReference ref : source.getUsedDevkits()) { SLinkOperations.getTargets(module, "usedDevkits", true).add(convert(ref)); } for (ModuleReference ref : source.getUsedLanguages()) { SLinkOperations.getTargets(module, "usedLanguages", true).add(convert(ref)); } for (ModelRoot entry : source.getStubModelEntries()) { SLinkOperations.getTargets(module, "stubModels", true).add(convert(entry)); } for (String s : source.getSourcePaths()) { SLinkOperations.getTargets(module, "sourcePaths", true).add(convertSourcePath(s)); } }