Search in sources :

Example 11 with Artifact

use of com.ibm.uma.om.Artifact in project openj9 by eclipse.

the class Parser method resolveModuleHierarchy.

void resolveModuleHierarchy() throws UMAException {
    generator.validateArtifactLocations();
    // Make sure that all modules have parents all the way to the root.
    // If a hole is found and a module with artifacts of type subdir.
    // System.out.println("resolveModuleHierarchy");
    boolean modulesToBeChecked = true;
    while (modulesToBeChecked) {
        // root/gc/modron/base/module.xml is 'gc/modron/base'
        for (Module module : modules) {
            if (!module.evaluate())
                continue;
            addModuleByLogicalFullname(module);
        }
        Vector<Module> newModules = new Vector<Module>();
        modulesToBeChecked = false;
        for (Module module : modules) {
            if (!module.evaluate())
                continue;
            // ensure each parent of a module exists.
            if (module.isTopLevel())
                continue;
            String[] parents = module.getParents();
            for (int depth = 0; depth < module.getModuleDepth(); depth++) {
                Module parentMod = getModuleByLogicalFullname(parents[depth]);
                if (parentMod == null) {
                    // need to create the parent
                    String moduleXmlFilename = UMA.getUma().getRootDirectory();
                    for (int d = 1; d <= depth; d++) {
                        moduleXmlFilename = moduleXmlFilename + module.moduleNameAtDepth(d) + "/";
                    }
                    moduleXmlFilename = moduleXmlFilename + getConfiguration().getMetadataFilename();
                    parentMod = new Module(moduleXmlFilename);
                    addModuleByLogicalFullname(parentMod);
                    newModules.add(parentMod);
                    modulesToBeChecked = true;
                }
            }
        }
        modules.addAll(newModules);
        for (Module module : modules) {
            if (!module.evaluate())
                continue;
            // ensure each parent of a module exists.
            if (module.isTopLevel())
                continue;
            String[] parents = module.getParents();
            for (int depth = 0; depth < module.getModuleDepth(); depth++) {
                Module parentMod = getModuleByLogicalFullname(parents[depth]);
                boolean found = false;
                String child = module.moduleNameAtDepth(depth + 1);
                for (Artifact artifact : parentMod.getArtifacts()) {
                    if (!artifact.evaluate())
                        continue;
                    if (artifact.getType() == Artifact.TYPE_SUBDIR) {
                        if (artifact.getTargetName().equalsIgnoreCase(child)) {
                            found = true;
                        }
                    }
                }
                if (!found && !child.equalsIgnoreCase(UMA.getUma().getConfiguration().getMetadataFilename())) {
                    Module subdirModule = getModuleByLogicalFullname(parentMod.getLogicalFullName() + "/" + child);
                    Artifact artifact = new SubdirArtifact(child, subdirModule, parentMod);
                    parentMod.addArtifact(artifact);
                }
            }
        }
    }
}
Also used : SubdirArtifact(com.ibm.uma.om.SubdirArtifact) Module(com.ibm.uma.om.Module) Vector(java.util.Vector) SubdirArtifact(com.ibm.uma.om.SubdirArtifact) Artifact(com.ibm.uma.om.Artifact)

Example 12 with Artifact

use of com.ibm.uma.om.Artifact in project openj9 by eclipse.

the class ModuleParser method parse.

public static Module parse(Document moduleXml, String modulePath) throws UMAException {
    Module module = new Module(modulePath);
    // Initialize the Module based on the XML document
    Element elem = moduleXml.getDocumentElement();
    NodeList nodeList = elem.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node node = nodeList.item(i);
        String nodeName = node.getLocalName();
        if (nodeName == null)
            continue;
        if (nodeName.equalsIgnoreCase("artifact")) {
            Artifact artifact = ArtifactParser.parse(node, module);
            module.addArtifact(artifact);
            UMA.getUma().addArtifact(artifact);
        } else if (nodeName.equalsIgnoreCase("exports")) {
            Exports exps = ExportsParser.parse(node, module.getContainingFile());
            module.addExports(exps.getGroup(), exps);
        } else if (nodeName.equalsIgnoreCase("objects")) {
            Objects objs = ObjectsParser.parse(node, module.getContainingFile());
            module.addObjects(objs.getGroup(), objs);
        } else if (nodeName.equalsIgnoreCase("exportlists")) {
            Vector<Exports> exports = ExportlistsParser.parse(node, module.getContainingFile());
            for (Exports exps : exports) {
                module.addExports(exps.getGroup(), exps);
            }
        } else if (nodeName.equalsIgnoreCase("objectlists")) {
            Vector<Objects> objects = ObjectlistsParser.parse(node, module.getContainingFile());
            for (Objects objs : objects) {
                module.addObjects(objs.getGroup(), objs);
            }
        } else if (nodeName.equalsIgnoreCase("flaglists")) {
            Vector<Flags> flags = FlaglistsParser.parse(node, module.getContainingFile());
            for (Flags f : flags) {
                // System.out.println("Flag: " + (f == null ? "null" : f.getGroup()));
                module.addFlags(f.getGroup(), f);
            }
        } else if (nodeName.equalsIgnoreCase("flags")) {
            Flags flags = FlagsParser.parse(node, module.getContainingFile());
            // System.out.println("GROUP: " + flags.getGroup());
            for (Flag f : flags.getFlags()) {
            /*
					if (f != null) {
						System.out.println("FLAG: "+ f.getName());
					} else {
						System.out.println("NULL FLAG");
					}
					*/
            }
            module.addFlags(flags.getGroup(), flags);
        }
    }
    Parser.populatePredicateList(nodeList, module);
    return module;
}
Also used : Element(org.w3c.dom.Element) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Flags(com.ibm.uma.om.Flags) Flag(com.ibm.uma.om.Flag) Artifact(com.ibm.uma.om.Artifact) Exports(com.ibm.uma.om.Exports) Objects(com.ibm.uma.om.Objects) Module(com.ibm.uma.om.Module) Vector(java.util.Vector)

Aggregations

Artifact (com.ibm.uma.om.Artifact)12 SubdirArtifact (com.ibm.uma.om.SubdirArtifact)8 Library (com.ibm.uma.om.Library)5 Vector (java.util.Vector)5 Dependency (com.ibm.uma.om.Dependency)3 Module (com.ibm.uma.om.Module)3 FileAssistant (com.ibm.uma.util.FileAssistant)3 Command (com.ibm.uma.om.Command)2 Export (com.ibm.uma.om.Export)2 Flag (com.ibm.uma.om.Flag)2 File (java.io.File)2 Hashtable (java.util.Hashtable)2 Node (org.w3c.dom.Node)2 NodeList (org.w3c.dom.NodeList)2 UMABadPhaseNameException (com.ibm.uma.UMABadPhaseNameException)1 UMAException (com.ibm.uma.UMAException)1 Exports (com.ibm.uma.om.Exports)1 Flags (com.ibm.uma.om.Flags)1 Include (com.ibm.uma.om.Include)1 MakefileStub (com.ibm.uma.om.MakefileStub)1