]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc/src/main/java/org/argeo/slc/ant/AntRegistryUtil.java
Revert HSQL DB changes (still force shutdown, but reuse connection)
[gpl/argeo-slc.git] / org.argeo.slc / src / main / java / org / argeo / slc / ant / AntRegistryUtil.java
index a8fe8bf296392fa1aa08051bb3a1589bbebb81be..7b827935b02d94b558f7f7fafea230e190e985a6 100644 (file)
@@ -9,11 +9,10 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.tools.ant.Project;\r
 import org.apache.tools.ant.ProjectHelper;\r
 \r
-import org.argeo.slc.core.structure.StructureElement;\r
 import org.argeo.slc.core.structure.StructurePath;\r
 import org.argeo.slc.core.structure.StructureRegistry;\r
 \r
-/** Utilities to manipulate the structure registry in SLC Ant.*/\r
+/** Utilities to manipulate the structure registry in SLC Ant. */\r
 public class AntRegistryUtil {\r
        private static Log log = LogFactory.getLog(AntRegistryUtil.class);\r
 \r
@@ -22,6 +21,7 @@ public class AntRegistryUtil {
 \r
                Project p = new Project();\r
                p.setUserProperty("ant.file", antFile.getAbsolutePath());\r
+               p.setBaseDir(antFile.getParentFile());\r
                p.init();\r
                ProjectHelper helper = new SlcProjectHelper();\r
                p.addReference("ant.projectHelper", helper);\r
@@ -35,11 +35,12 @@ public class AntRegistryUtil {
                return registry;\r
        }\r
 \r
-       /** Execute only the active paths of teh Ant files. */\r
+       /** Execute only the active paths of the Ant file. */\r
        public static void runActive(File antFile, List<StructurePath> activePaths) {\r
 \r
                Project p = new Project();\r
                p.setUserProperty("ant.file", antFile.getAbsolutePath());\r
+               p.setBaseDir(antFile.getParentFile());\r
                p.init();\r
                ProjectHelper helper = new SlcProjectHelper();\r
                p.addReference("ant.projectHelper", helper);\r
@@ -52,24 +53,33 @@ public class AntRegistryUtil {
                p.executeTarget(p.getDefaultTarget());\r
        }\r
 \r
+       /** Execute all paths of the default target of the Ant file. */\r
+       public static void runAll(File antFile) {\r
+               Project p = new Project();\r
+               p.setUserProperty("ant.file", antFile.getAbsolutePath());\r
+               p.setBaseDir(antFile.getParentFile());\r
+               p.init();\r
+               ProjectHelper helper = new SlcProjectHelper();\r
+               p.addReference("ant.projectHelper", helper);\r
+               helper.parse(p, antFile);\r
+               p.executeTarget(p.getDefaultTarget());\r
+       }\r
+\r
        public static void main(String[] args) {\r
                File antFile = new File(\r
-                               "C:/dev/workspaces/default/org.argeo.slc/src/test/ant/build.xml");\r
-               System\r
-                               .setProperty(SlcAntConfig.APPLICATION_CONTEXT_PROPERTY,\r
-                                               "C:/dev/workspaces/default/org.argeo.slc/src/test/ant/applicationContext.xml");\r
+                               "C:/dev/workspaces/default/org.argeo.slc/src/test/slc/root/Category1/SubCategory2/build.xml");\r
                StructureRegistry registry = AntRegistryUtil.readRegistry(antFile);\r
 \r
                StringBuffer buf = new StringBuffer("");\r
 \r
                int count = 0;\r
                List<StructurePath> activePaths = new Vector<StructurePath>();\r
-               for (StructureElement element : registry.listElements()) {\r
-                       buf.append(element.getPath());\r
+               for (StructurePath path : registry.listPaths()) {\r
+                       buf.append(path);\r
                        if (count != 0 && count % 3 == 0) {\r
                                // skip\r
                        } else {\r
-                               activePaths.add(element.getPath());\r
+                               activePaths.add(path);\r
                                buf.append(" <");\r
                        }\r
                        buf.append('\n');\r
@@ -80,5 +90,4 @@ public class AntRegistryUtil {
                runActive(antFile, activePaths);\r
 \r
        }\r
-\r
 }\r