mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-04-02 13:37:45 -05:00
Support Groovy 3's QName in GroovyXmlUtil (#379)
This commit is contained in:
@@ -31,6 +31,8 @@ import java.util.stream.Stream;
|
||||
import groovy.util.Node;
|
||||
import groovy.xml.QName;
|
||||
|
||||
import net.fabricmc.loom.util.gradle.GradleSupport;
|
||||
|
||||
public final class GroovyXmlUtil {
|
||||
private GroovyXmlUtil() { }
|
||||
|
||||
@@ -63,9 +65,19 @@ public final class GroovyXmlUtil {
|
||||
return ((QName) nodeName).matches(givenName);
|
||||
}
|
||||
|
||||
// New groovy 3 (gradle 7) class
|
||||
if (GradleSupport.IS_GRADLE_7_OR_NEWER && nodeName.getClass().getName().equals("groovy.namespace.QName")) {
|
||||
return isSameNameGroovy3(nodeName, givenName);
|
||||
}
|
||||
|
||||
throw new UnsupportedOperationException("Cannot determine if " + nodeName.getClass() + " is the same as a String");
|
||||
}
|
||||
|
||||
// TODO Move out of its own method when requiring gradle 7
|
||||
private static boolean isSameNameGroovy3(Object nodeName, String givenName) {
|
||||
return ((groovy.namespace.QName) nodeName).matches(givenName);
|
||||
}
|
||||
|
||||
public static Stream<Node> childrenNodesStream(Node node) {
|
||||
//noinspection unchecked
|
||||
return (Stream<Node>) (Stream) (((List<Object>) node.children()).stream().filter((i) -> i instanceof Node));
|
||||
|
||||
Reference in New Issue
Block a user