package jetbrains.mps.project.persistence; /*Generated by MPS */ import jetbrains.mps.project.structure.modules.DeploymentDescriptor; import jetbrains.mps.vfs.IFile; import org.jdom.Document; import jetbrains.mps.util.JDOMUtil; import org.jdom.Element; import jetbrains.mps.baseLanguage.closures.runtime._FunctionTypes; import jetbrains.mps.project.ModuleId; import jetbrains.mps.internal.collections.runtime.Sequence; import jetbrains.mps.util.xml.XmlUtil; import jetbrains.mps.project.structure.modules.Dependency; import org.jetbrains.mps.openapi.module.SModuleReference; import org.jetbrains.mps.openapi.persistence.PersistenceFacade; public class DeploymentDescriptorPersistence { public DeploymentDescriptorPersistence() { } public static DeploymentDescriptor loadDeploymentDescriptor(final IFile file) { DeploymentDescriptor descriptor; try { Document document = JDOMUtil.loadDocument(file); final Element rootElement = document.getRootElement(); descriptor = new _FunctionTypes._return_P0_E0<DeploymentDescriptor>() { public DeploymentDescriptor invoke() { final DeploymentDescriptor result_wu2j1h_a0a0d0c0b = new DeploymentDescriptor(); final String result_wu2j1h_a0a0a0d0c0b = rootElement.getAttributeValue("namespace"); result_wu2j1h_a0a0d0c0b.setNamespace(result_wu2j1h_a0a0a0d0c0b); String uuid = rootElement.getAttributeValue("uuid"); if (uuid != null) { final ModuleId result_wu2j1h_a0a2a0a0d0c0b = ModuleId.fromString(uuid); result_wu2j1h_a0a0d0c0b.setId(result_wu2j1h_a0a2a0a0d0c0b); } final String result_wu2j1h_a3a0a0d0c0b = rootElement.getAttributeValue("type"); result_wu2j1h_a0a0d0c0b.setType(result_wu2j1h_a3a0a0d0c0b); for (Element a : Sequence.fromIterable(XmlUtil.children(rootElement, "dependencies"))) { for (final Element module : Sequence.fromIterable(XmlUtil.children(a, "module"))) { result_wu2j1h_a0a0d0c0b.getDependencies().add(new _FunctionTypes._return_P0_E0<Dependency>() { public Dependency invoke() { final Dependency result_wu2j1h_a0a0a0a0a5a0a0d0c0b = new Dependency(); final SModuleReference result_wu2j1h_a0a0a0a0a0a5a0a0d0c0b = PersistenceFacade.getInstance().createModuleReference(module.getAttributeValue("ref")); result_wu2j1h_a0a0a0a0a5a0a0d0c0b.setModuleRef(result_wu2j1h_a0a0a0a0a0a5a0a0d0c0b); final boolean result_wu2j1h_a1a0a0a0a0a5a0a0d0c0b = false; result_wu2j1h_a0a0a0a0a5a0a0d0c0b.setReexport(result_wu2j1h_a1a0a0a0a0a5a0a0d0c0b); return result_wu2j1h_a0a0a0a0a5a0a0d0c0b; } }.invoke()); } } for (Element b : Sequence.fromIterable(XmlUtil.children(rootElement, "library"))) { result_wu2j1h_a0a0d0c0b.getLibraries().add(b.getAttributeValue("jar")); } Element classpath = XmlUtil.first(rootElement, "classpath"); if (classpath == null) { // compatibility with DD produced prior to introduction of the element. // now we use empty tag to indicate no classpath. Once 3.5 is out, remove this code and // fix build language not to inject empty <classpath/> tag for modules without classes result_wu2j1h_a0a0d0c0b.getClasspath().add("."); } else { for (Element e : Sequence.fromIterable(XmlUtil.children(classpath, "entry"))) { result_wu2j1h_a0a0d0c0b.getClasspath().add(e.getAttributeValue("path")); } } Element sources = XmlUtil.first(rootElement, "sources"); if (sources != null) { final String result_wu2j1h_a0a31a0a0d0c0b = sources.getAttributeValue("jar"); result_wu2j1h_a0a0d0c0b.setSourcesJar(result_wu2j1h_a0a31a0a0d0c0b); final String result_wu2j1h_a1a31a0a0d0c0b = sources.getAttributeValue("descriptor"); result_wu2j1h_a0a0d0c0b.setDescriptorFile(result_wu2j1h_a1a31a0a0d0c0b); } return result_wu2j1h_a0a0d0c0b; } }.invoke(); } catch (Exception e) { throw new ModuleReadException(e); } ModuleDescriptorPersistence.setTimestamp(descriptor, file); return descriptor; } }