adds documnt/groovy_hardfail with transcript
authorThomas Walker Lynch <xtujpz@reasoningtechnology.com>
Mon, 7 Oct 2024 08:15:23 +0000 (08:15 +0000)
committerThomas Walker Lynch <xtujpz@reasoningtechnology.com>
Mon, 7 Oct 2024 08:15:23 +0000 (08:15 +0000)
developer/javac/Build.java [new file with mode: 0644]
developer/jvm/Ariadne.jar
document/goovy_hardfail.txt

diff --git a/developer/javac/Build.java b/developer/javac/Build.java
new file mode 100644 (file)
index 0000000..b0cdab3
--- /dev/null
@@ -0,0 +1,76 @@
+import java.util.List;
+
+public class Build {
+
+    // Function to load the graph class dynamically
+    public static Class<?> includeAClass(String aClassFp) {
+        ClassLoader classLoader = Build.class.getClassLoader();
+        String className = aClassFp.replace('/', '.').replace(".class", "");
+        try {
+            return classLoader.loadClass(className);
+        } catch (Exception e) {
+            System.out.println("Error loading class '" + className + "': " + e.getMessage());
+            return null;
+        }
+    }
+
+    // Build function
+    public static void build(String graphDefinitionFp, List<String> rootNodeLabels) {
+        // Print summary of what we are doing
+        System.out.println("build:: Building targets for graph '" + graphDefinitionFp + ".class'");
+        if (rootNodeLabels.isEmpty()) {
+            System.out.println("No build targets specified. Please provide root node labels to build.");
+            System.exit(0);
+        }
+        System.out.println("Building targets: " + String.join(", ", rootNodeLabels));
+
+        // Load the dependency graph class from arg[1]
+        Class<?> graphDefinitionClass = includeAClass(graphDefinitionFp);
+        if (graphDefinitionClass != null) {
+            System.out.println("build:: loaded " + graphDefinitionFp + ".class");
+        } else {
+            System.out.println("build:: failed to load " + graphDefinitionFp + ".class");
+            System.exit(1);
+        }
+
+        // Get the node_map and node_f_list from the graph class
+        // Assuming these methods are static and return the appropriate types
+        // Replace with actual method calls if they are different
+        Object nodeMap = null;
+        Object nodeFList = null;
+        try {
+            nodeMap = graphDefinitionClass.getMethod("getNodeMap").invoke(null);
+            nodeFList = graphDefinitionClass.getMethod("getNodeFList").invoke(null);
+        } catch (Exception e) {
+            System.out.println("Error invoking methods on graphDefinitionClass: " + e.getMessage());
+            System.exit(1);
+        }
+        System.out.println("node_map: " + nodeMap);
+        System.out.println("node_f_list: " + nodeFList);
+
+        // Create an instance of AriadneGraph, and run the build scripts
+        // Assuming AriadneGraph has a constructor that takes nodeMap and nodeFList
+        // Replace with actual constructor call if it is different
+        try {
+            Class<?> ariadneGraphClass = Class.forName("AriadneGraph");
+            Object graph = ariadneGraphClass.getConstructor(nodeMap.getClass(), nodeFList.getClass()).newInstance(nodeMap, nodeFList);
+            ariadneGraphClass.getMethod("runBuildScriptsF", List.class).invoke(graph, rootNodeLabels);
+        } catch (Exception e) {
+            System.out.println("Error creating or invoking AriadneGraph: " + e.getMessage());
+            System.exit(1);
+        }
+    }
+
+    // Entry point when run as a script
+    public static void main(String[] args) {
+        if (args.length == 0) {
+            System.out.println("Usage: ./build <graph_definition.class> [root_node_labels...]");
+            System.exit(1);
+        }
+
+        // Get graph definition file and root node labels
+        String graphDefinitionFp = args[0];
+        List<String> rootNodeLabels = args.length > 1 ? List.of(args).subList(1, args.length) : List.of();
+        build(graphDefinitionFp, rootNodeLabels);
+    }
+}
index c679924..42313a5 100644 (file)
Binary files a/developer/jvm/Ariadne.jar and b/developer/jvm/Ariadne.jar differ
index a7d221a..0703abc 100644 (file)
@@ -1,3 +1,4 @@
+
 Tried many variations, including using 'groovy' instead of java to run it.
 Also did -cp on the command line. Nothing can convince `java` to find
 the class created by groovyc.  When build is instead made into a script