Search in sources :

Example 6 with NodeList

use of groovy.util.NodeList in project gradle by gradle.

the class AbstractClasspathEntry method writeAccessRules.

private void writeAccessRules(Node node) {
    if (accessRules == null || accessRules.isEmpty()) {
        return;
    }
    Node accessRulesNode;
    NodeList accessRulesNodes = (NodeList) node.get("accessrules");
    if (accessRulesNodes.size() == 0) {
        accessRulesNode = node.appendNode("accessrules");
    } else {
        accessRulesNode = (Node) accessRulesNodes.get(0);
    }
    for (AccessRule rule : accessRules) {
        Map<String, Object> attributes = Maps.newLinkedHashMap();
        attributes.put("kind", rule.getKind());
        attributes.put("pattern", rule.getPattern());
        accessRulesNode.appendNode("accessrule", attributes);
    }
}
Also used : Node(groovy.util.Node) NodeList(groovy.util.NodeList)

Example 7 with NodeList

use of groovy.util.NodeList in project gradle by gradle.

the class AbstractClasspathEntry method readEntryAttributes.

private Map<String, Object> readEntryAttributes(Node node) {
    Map<String, Object> attributes = Maps.newLinkedHashMap();
    NodeList attributesNodes = (NodeList) node.get("attributes");
    for (Object attributesEntry : attributesNodes) {
        NodeList attributeNodes = (NodeList) ((Node) attributesEntry).get("attribute");
        for (Object attributeEntry : attributeNodes) {
            Node attributeNode = (Node) attributeEntry;
            attributes.put((String) attributeNode.attribute("name"), attributeNode.attribute("value"));
        }
    }
    return attributes;
}
Also used : NodeList(groovy.util.NodeList) Node(groovy.util.Node)

Example 8 with NodeList

use of groovy.util.NodeList in project gradle by gradle.

the class Classpath method load.

@Override
protected void load(Node xml) {
    for (Object e : (NodeList) xml.get("classpathentry")) {
        Node entryNode = (Node) e;
        Object kind = entryNode.attribute("kind");
        if ("src".equals(kind)) {
            String path = (String) entryNode.attribute("path");
            entries.add(path.startsWith("/") ? new ProjectDependency(entryNode) : new SourceFolder(entryNode));
        } else if ("var".equals(kind)) {
            entries.add(new Variable(entryNode, fileReferenceFactory));
        } else if ("con".equals(kind)) {
            entries.add(new Container(entryNode));
        } else if ("lib".equals(kind)) {
            entries.add(new Library(entryNode, fileReferenceFactory));
        } else if ("output".equals(kind)) {
            entries.add(new Output(entryNode));
        }
    }
}
Also used : NodeList(groovy.util.NodeList) Node(groovy.util.Node) XmlPersistableConfigurationObject(org.gradle.plugins.ide.internal.generator.XmlPersistableConfigurationObject)

Aggregations

Node (groovy.util.Node)8 NodeList (groovy.util.NodeList)8 XmlPersistableConfigurationObject (org.gradle.plugins.ide.internal.generator.XmlPersistableConfigurationObject)3