]> git.argeo.org Git - gpl/argeo-slc.git/commitdiff
Remove old runtime
authorMathieu Baudier <mbaudier@argeo.org>
Sat, 21 Jun 2008 18:14:17 +0000 (18:14 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Sat, 21 Jun 2008 18:14:17 +0000 (18:14 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@1277 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

16 files changed:
org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/AntRegistryUtil.java [deleted file]
org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/AntRunner.java
org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/AntSlcApplication.java
org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/BasicSlcProjectHelper.java [deleted file]
org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/ProjectRelatedBuildListener.java [deleted file]
org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/SlcAntConfig.java [deleted file]
org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/SlcExecutionBuildListener.java
org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/SlcProjectHelper.java [deleted file]
org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/deploy/SlcDeployTask.java
org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/test/SlcTestTask.java
org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/unit/SlcAntAppliTestCase.java
org.argeo.slc.agent/src/main/java/org/argeo/slc/cli/DefaultSlcRuntime.java
org.argeo.slc.agent/src/main/java/org/argeo/slc/cli/SlcMain.java
org.argeo.slc.agent/src/main/java/org/argeo/slc/maven/MavenDeployEnvironment.java
org.argeo.slc.agent/src/main/resources/META-INF/services/org.apache.tools.ant.ProjectHelper [deleted file]
org.argeo.slc.agent/src/test/java/org/argeo/slc/ws/SlcAntWsIntegrationTest.java

diff --git a/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/AntRegistryUtil.java b/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/AntRegistryUtil.java
deleted file mode 100644 (file)
index 476384c..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-package org.argeo.slc.ant;\r
-\r
-import java.io.File;\r
-import java.net.URL;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Properties;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-import org.apache.tools.ant.Project;\r
-import org.apache.tools.ant.ProjectHelper;\r
-import org.apache.tools.ant.listener.CommonsLoggingListener;\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
-public class AntRegistryUtil {\r
-       private static Log log = LogFactory.getLog(AntRegistryUtil.class);\r
-\r
-       /** Reads a structure registry from an Ant file without executing it. */\r
-       public static StructureRegistry readRegistry(File antFile) {\r
-               if (log.isDebugEnabled())\r
-                       log.debug("Reads registry for Ant 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(ProjectHelper.PROJECTHELPER_REFERENCE, helper);\r
-               helper.parse(p, antFile);\r
-\r
-               StructureRegistry registry = (StructureRegistry) p\r
-                               .getReference(SlcAntConstants.REF_STRUCTURE_REGISTRY);\r
-               registry.setMode(StructureRegistry.READ);\r
-\r
-               p.executeTarget(p.getDefaultTarget());\r
-               return registry;\r
-       }\r
-\r
-       /** Executes only the active paths of the Ant file. */\r
-       public static Project runActive(File antFile,\r
-                       List<StructurePath> activePaths) {\r
-               if (log.isDebugEnabled())\r
-                       log.debug("Runs the " + activePaths.size()\r
-                                       + " provided active paths of Ant 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(ProjectHelper.PROJECTHELPER_REFERENCE, helper);\r
-               helper.parse(p, antFile);\r
-\r
-               StructureRegistry registry = (StructureRegistry) p\r
-                               .getReference(SlcAntConstants.REF_STRUCTURE_REGISTRY);\r
-               registry.setMode(StructureRegistry.ACTIVE);\r
-               registry.setActivePaths(activePaths);\r
-\r
-               runProject(p, null);\r
-               return p;\r
-       }\r
-\r
-       /** Executes all paths of the provided target of the Ant file. */\r
-       public static Project runAll(File antFile, String target) {\r
-               if (log.isDebugEnabled())\r
-                       log.debug("Runs all paths of Ant 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(ProjectHelper.PROJECTHELPER_REFERENCE, helper);\r
-               helper.parse(p, antFile);\r
-\r
-               runProject(p, target);\r
-               return p;\r
-       }\r
-\r
-       /** Executes all paths of the provided target of the Ant URL. */\r
-       public static Project runAll(URL url, String target, Properties properties) {\r
-               if (log.isDebugEnabled())\r
-                       log.debug("Runs all paths of Ant URL " + url);\r
-               Project p = new Project();\r
-               p.setUserProperty("ant.file", url.toString());\r
-               // p.setBaseDir(url.toString());\r
-               p.addBuildListener(new CommonsLoggingListener());\r
-               p.init();\r
-               ProjectHelper helper = new SlcProjectHelper();\r
-               p.addReference(ProjectHelper.PROJECTHELPER_REFERENCE, helper);\r
-               helper.parse(p, url);\r
-\r
-               if (properties != null) {\r
-                       for (Map.Entry<Object, Object> entry : properties.entrySet()) {\r
-                               p.setUserProperty(entry.getKey().toString(), entry.getValue()\r
-                                               .toString());\r
-                       }\r
-               }\r
-\r
-               runProject(p, target);\r
-               return p;\r
-       }\r
-\r
-       /** Executes all paths of the default target of the Ant file. */\r
-       public static Project runAll(File antFile) {\r
-               return runAll(antFile, null);\r
-       }\r
-\r
-       protected static void runProject(Project p, String target) {\r
-               p.fireBuildStarted();\r
-               Throwable exception = null;\r
-               try {\r
-                       p.executeTarget(target != null ? target : p.getDefaultTarget());\r
-               } catch (Throwable e) {\r
-                       exception = e;\r
-                       log.error("Exception when running Ant: ", e);\r
-               } finally {\r
-                       p.fireBuildFinished(exception);\r
-               }\r
-       }\r
-}\r
index 5ce4b53b79794ed8bb5bfcec5522cadefa83413e..4bedc9bace8a0af2a255f78d6642315327afb150 100644 (file)
@@ -9,12 +9,10 @@ import java.util.Vector;
 \r
 import org.apache.tools.ant.Project;\r
 import org.apache.tools.ant.ProjectHelper;\r
-import org.springframework.context.ApplicationContext;\r
+import org.apache.tools.ant.helper.ProjectHelper2;\r
 \r
-/** @deprecated */\r
+/** Run regular Ant script (that is, not SLC instrumented) */\r
 public class AntRunner {\r
-       private ApplicationContext context;\r
-       private ProjectHelper projectHelper;\r
        private URL buildFile;\r
        private String[] targets;\r
        private Properties properties;\r
@@ -23,25 +21,14 @@ public class AntRunner {
 \r
        }\r
 \r
-       public AntRunner(ApplicationContext context, ProjectHelper projectHelper,\r
-                       URL buildFile, String[] targets) {\r
-               super();\r
-               this.context = context;\r
-               this.projectHelper = projectHelper;\r
-               this.buildFile = buildFile;\r
-               this.targets = targets;\r
+       public AntRunner(URL buildFile, String target, Properties properties) {\r
+               this(buildFile, new String[] { target }, properties);\r
        }\r
 \r
-       public AntRunner(ApplicationContext context, URL buildFile, String target) {\r
-               super();\r
-               this.context = context;\r
-\r
-               BasicSlcProjectHelper basicSlcProjectHelper = new BasicSlcProjectHelper();\r
-               this.projectHelper = basicSlcProjectHelper;\r
-               basicSlcProjectHelper.setContext(context);\r
-\r
+       public AntRunner(URL buildFile, String[] targets, Properties properties) {\r
                this.buildFile = buildFile;\r
-               this.targets = new String[] { target };\r
+               this.targets = targets;\r
+               this.properties = properties;\r
        }\r
 \r
        public void run() {\r
@@ -52,6 +39,7 @@ public class AntRunner {
                p.setBaseDir(extractBaseDir(path));\r
 \r
                p.init();\r
+               ProjectHelper projectHelper = new ProjectHelper2();\r
                p.addReference(ProjectHelper.PROJECTHELPER_REFERENCE, projectHelper);\r
                projectHelper.parse(p, buildFile);\r
 \r
@@ -100,9 +88,4 @@ public class AntRunner {
                }\r
        }\r
 \r
-       public static void main(String[] args) {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
-\r
 }\r
index ab2316ae02600cb703001625a0dfcd2b991fd5f6..ed214b49e0d38955a1b8028798522d7b79407404 100644 (file)
@@ -20,16 +20,13 @@ import org.apache.tools.ant.Project;
 import org.apache.tools.ant.ProjectHelper;
 import org.apache.tools.ant.helper.ProjectHelper2;
 import org.apache.tools.ant.listener.CommonsLoggingListener;
-import org.argeo.slc.core.SlcException;
 import org.argeo.slc.core.process.SlcExecution;
 import org.argeo.slc.core.structure.SimpleSElement;
 import org.argeo.slc.core.structure.StructureRegistry;
 import org.argeo.slc.core.structure.tree.TreeSPath;
 import org.argeo.slc.core.structure.tree.TreeSRegistry;
 import org.argeo.slc.logging.Log4jUtils;
-import org.argeo.slc.runtime.SlcExecutionContext;
 import org.argeo.slc.runtime.SlcExecutionOutput;
-import org.springframework.beans.factory.BeanDefinitionStoreException;
 import org.springframework.beans.factory.ListableBeanFactory;
 import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
diff --git a/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/BasicSlcProjectHelper.java b/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/BasicSlcProjectHelper.java
deleted file mode 100644 (file)
index 7a797d6..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.argeo.slc.ant;\r
-\r
-import org.springframework.context.ApplicationContext;\r
-\r
-import org.apache.tools.ant.BuildException;\r
-import org.apache.tools.ant.Project;\r
-import org.apache.tools.ant.helper.ProjectHelper2;\r
-\r
-import org.argeo.slc.core.structure.SimpleSElement;\r
-import org.argeo.slc.core.structure.tree.TreeSPath;\r
-import org.argeo.slc.core.structure.tree.TreeSRegistry;\r
-\r
-/** @deprecated */\r
-public class BasicSlcProjectHelper extends ProjectHelper2 {\r
-       private ApplicationContext context;\r
-\r
-       private String projectRootPath = "/project";\r
-\r
-       @Override\r
-       public void parse(Project project, Object source) throws BuildException {\r
-               TreeSRegistry registry = new TreeSRegistry();\r
-               TreeSPath projectPath = TreeSPath.parseToCreatePath(projectRootPath);\r
-\r
-               // FIXME\r
-               registry.register(projectPath, new SimpleSElement("ROOT"));\r
-\r
-               project.addReference(SlcAntConstants.REF_STRUCTURE_REGISTRY, registry);\r
-               project.addReference(SlcAntConstants.REF_PROJECT_PATH, projectPath);\r
-\r
-               super.parse(project, source);\r
-\r
-               project.addReference(SlcAntConstants.REF_ROOT_CONTEXT, context);\r
-               SlcProjectHelper.createAndRegisterSlcExecution(project);\r
-\r
-               SlcProjectHelper.addCustomTaskAndTypes(project);\r
-       }\r
-\r
-       public void setContext(ApplicationContext context) {\r
-               this.context = context;\r
-       }\r
-\r
-}\r
diff --git a/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/ProjectRelatedBuildListener.java b/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/ProjectRelatedBuildListener.java
deleted file mode 100644 (file)
index f6077b3..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.argeo.slc.ant;\r
-\r
-import org.apache.tools.ant.BuildListener;\r
-import org.apache.tools.ant.Project;\r
-\r
-/** @deprecated */\r
-public interface ProjectRelatedBuildListener extends BuildListener {\r
-       public Project getProject();\r
-\r
-       /** SlcExecution must already have been registered in project */\r
-       public void init(Project project);\r
-}\r
diff --git a/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/SlcAntConfig.java b/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/SlcAntConfig.java
deleted file mode 100644 (file)
index 4c8981c..0000000
+++ /dev/null
@@ -1,334 +0,0 @@
-package org.argeo.slc.ant;\r
-\r
-import java.io.File;\r
-import java.io.FileInputStream;\r
-import java.io.IOException;\r
-import java.util.Map;\r
-import java.util.Properties;\r
-import java.util.StringTokenizer;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-import org.apache.tools.ant.Project;\r
-import org.argeo.slc.core.test.WritableTestRun;\r
-import org.springframework.util.Log4jConfigurer;\r
-\r
-/**\r
- * <p>\r
- * Manager and initializer of the properties required by SLC Ant.\r
- * </p>\r
- * \r
- * <p>\r
- * All properties described here will get a value one way or another (see below\r
- * for details)/ Each property will be accessible via Ant or Spring properties.\r
- * </p>\r
- * \r
- * <p>\r
- * The property <i>slc.rootFile</i> is set based on the location of the SLC\r
- * root property file found in the directory structure of a called Ant file. The\r
- * default name of this file is <b>slcRoot.properties</b> (can be set by\r
- * {@link #setSlcRootFileName(String)}). <br>\r
- * This property provides the absolute path to the unique SLC root property file\r
- * which marks the root of an Ant SLC tree structure.\r
- * </p>\r
- * \r
- * <p>\r
- * The property <i>slc.rootDir</i> is inferred from <i>slc.rootFile</i> and\r
- * provides a convenient shortcut to the root directory of the Ant files\r
- * directory structure.\r
- * </p>\r
- * \r
- * <p>\r
- * A few directory and file related properties can be set in the SLC root\r
- * property file (if they are not explicitly set their default values will be\r
- * used):\r
- * \r
- * <table border="1" cellspacing="0">\r
- * <tr>\r
- * <th>Property</th>\r
- * <th>Description</th>\r
- * <th>Default</th>\r
- * </tr>\r
- * <tr>\r
- * <td><i>slc.confDir</i></td>\r
- * <td>Directory where to find the various configuration files of a given SLC\r
- * Ant deployment</td>\r
- * <td>${slc.rootDir}/../conf</td>\r
- * </tr>\r
- * <tr>\r
- * <td><i>slc.workDir</i></td>\r
- * <td>Directory where data can be retrieved or generated: build outputs, test\r
- * inputs/outputs, test results, etc. The underlying directory structure is\r
- * specified by the specific SLC application.</td>\r
- * <td>${slc.rootDir}/../work</td>\r
- * </tr>\r
- * <tr>\r
- * <td><i>slc.propertyFileNames</i></td>\r
- * <td>Comma-separated list of the files names of the property files to load\r
- * from the conf directory. Having various files allows to separate between SLC\r
- * framework properties and properties specific to a given application built on\r
- * top of SLC. All will be available across Ant and Spring.</td>\r
- * <td>slc.properties</td>\r
- * </tr>\r
- * </table> <b>Note:</b> Only the properties above can be set in the SLC root\r
- * properties file. All other properties should be defined in the registered\r
- * conf files.\r
- * </p>\r
- * \r
- * <p>\r
- * Any property can be defined in the conf files defined in the SLC root\r
- * properties file (see above). SLC expects some which will have defaults but\r
- * can be overriden there. By convention they should be defined in the\r
- * <b>slc.properties</b> file, while application specific properties should be\r
- * defined in other conf files. This allows for a clean spearation between SLC\r
- * and the applications built on top of it:\r
- * \r
- * <table border="1" cellspacing="0">\r
- * <tr>\r
- * <th>Property</th>\r
- * <th>Description</th>\r
- * <th>Default</th>\r
- * </tr>\r
- * <tr>\r
- * <td><i>slc.applicationContext</i></td>\r
- * <td>Path to the root Spring application context file used by SLC Ant.</td>\r
- * <td>${slc.confDir}/applicationContext.xml</td>\r
- * </tr>\r
- * <tr>\r
- * <td><i>slc.defaultTestRun</i></td>\r
- * <td>Name of the {@link WritableTestRun} Spring bean that the\r
- * <code>slc.test</code> task will use by default. This can be overridden when\r
- * calling the task from Ant.</td>\r
- * <td>defaultTestRun</td>\r
- * </tr>\r
- * </table>\r
- * </p>\r
- */\r
-public class SlcAntConfig {\r
-       // SLC ROOT PROPERTIES\r
-       /** Property for the root file (SLC root property file). */\r
-       public final static String ROOT_FILE_PROPERTY = "slc.rootFile";\r
-       /**\r
-        * Comma-separated list of property file names to load from the conf dir and\r
-        * add to project user properties\r
-        */\r
-       public final static String PROPERTY_FILE_NAMES_PROPERTY = "slc.propertyFileNames";\r
-\r
-       // SLC CONF PROPERTIES\r
-       /** Path to the root Spring application context */\r
-       public static String APPLICATION_CONTEXT_PROPERTY = "slc.applicationContext";\r
-       // SLC LOCAL PROPERTIES\r
-       /** Property for the dir label (SLC local property file). */\r
-       public static String DIR_LABEL_PROPERTY = "slc.dirLabel";\r
-\r
-       private String slcRootFileName = "slcRoot.properties";\r
-       private String slcLocalFileName = "slcLocal.properties";\r
-\r
-       /**\r
-        * Retrieves or infers all properties and set them as project user\r
-        * properties. All these properties will be set as project properties <b>if\r
-        * they had not been set as project properties before</b> (like by\r
-        * overriding through the standard Ant mechanisms).\r
-        * \r
-        * @param project\r
-        *            the Ant <code>Project</code> being run.\r
-        * @return whether the project could be initialized for SLC usage (e.g.\r
-        *         presence of an SLC root file)\r
-        */\r
-       public boolean initProject(Project project) {\r
-               File projectBaseDir = project.getBaseDir();\r
-               File slcRootFile = findSlcRootFile(projectBaseDir);\r
-               if (slcRootFile == null) {\r
-                       return false;\r
-               }\r
-\r
-               // pass the project properties through the System properties\r
-               System.getProperties().putAll((Map<?, ?>) project.getUserProperties());\r
-               Properties all = new Properties();\r
-               all.putAll(System.getProperties());\r
-               prepareAllProperties(slcRootFile, all);\r
-\r
-               Log log = LogFactory.getLog(this.getClass());\r
-               for (Object o : all.keySet()) {\r
-                       String key = o.toString();\r
-                       // System.out.println(key+"="+all.getProperty(key));\r
-                       if (project.getUserProperty(key) == null) {// not already set\r
-                               // if (log.isDebugEnabled())\r
-                               // log.debug(key + "=" + all.getProperty(key));\r
-                               project.setUserProperty(key, all.getProperty(key));\r
-                       }\r
-               }\r
-               return true;\r
-       }\r
-\r
-       /**\r
-        * Retrieves or infers all required properties.\r
-        * \r
-        * @param slcRootFile\r
-        *            the location of the SLC root file\r
-        * \r
-        * @return the prepared properties. Note that it also contains the System\r
-        *         and Ant properties which had previously been set.\r
-        */\r
-       public void prepareAllProperties(File slcRootFile, Properties all) {\r
-               try {\r
-                       final String fileUrlPrefix = "";\r
-\r
-                       all.put(ROOT_FILE_PROPERTY, slcRootFile.getCanonicalPath());\r
-                       // Remove basedir property in order to avoid conflict with Maven\r
-                       if (all.containsKey("basedir"))\r
-                               all.remove("basedir");\r
-\r
-                       Properties rootProps = loadFile(slcRootFile.getCanonicalPath());\r
-\r
-                       final File confDir;\r
-                       final File workDir;\r
-                       // Root dir\r
-                       final File rootDir = slcRootFile.getParentFile();\r
-                       all.setProperty(SlcAntConstants.ROOT_DIR_PROPERTY, fileUrlPrefix\r
-                                       + rootDir.getCanonicalPath());\r
-\r
-                       // Conf dir\r
-                       if (all.getProperty(SlcAntConstants.CONF_DIR_PROPERTY) == null) {\r
-                               confDir = new File(rootProps.getProperty(SlcAntConstants.CONF_DIR_PROPERTY,\r
-                                               rootDir.getAbsolutePath() + "/../conf"))\r
-                                               .getCanonicalFile();\r
-                               all.setProperty(SlcAntConstants.CONF_DIR_PROPERTY, fileUrlPrefix\r
-                                               + confDir.getAbsolutePath());\r
-                       } else {\r
-                               confDir = new File(all.getProperty(SlcAntConstants.CONF_DIR_PROPERTY))\r
-                                               .getCanonicalFile();\r
-                       }\r
-\r
-                       // Work dir\r
-                       if (all.getProperty(SlcAntConstants.WORK_DIR_PROPERTY) == null) {\r
-                               workDir = new File(rootProps.getProperty(SlcAntConstants.WORK_DIR_PROPERTY,\r
-                                               rootDir.getAbsolutePath() + "/../work"))\r
-                                               .getCanonicalFile();\r
-                               all.setProperty(SlcAntConstants.WORK_DIR_PROPERTY, fileUrlPrefix\r
-                                               + workDir.getAbsolutePath());\r
-                       } else {\r
-                               workDir = new File(all.getProperty(SlcAntConstants.WORK_DIR_PROPERTY))\r
-                                               .getCanonicalFile();\r
-                       }\r
-\r
-                       // Properties from the conf dir files\r
-                       Properties properties = new Properties();\r
-                       StringTokenizer st = new StringTokenizer(rootProps.getProperty(\r
-                                       PROPERTY_FILE_NAMES_PROPERTY, "slc.properties"), ",");\r
-                       while (st.hasMoreTokens()) {\r
-                               String fileName = st.nextToken();\r
-                               properties.putAll(loadFile(confDir.getAbsolutePath()\r
-                                               + File.separator + fileName));\r
-                       }\r
-\r
-                       for (Object o : properties.keySet()) {\r
-                               String key = o.toString();\r
-                               if (all.getProperty(key) == null) {// not already set\r
-                                       all.setProperty(key, properties.getProperty(key));\r
-                               }\r
-                       }\r
-\r
-                       // Default application context\r
-                       if (all.getProperty(APPLICATION_CONTEXT_PROPERTY) == null) {\r
-                               all.setProperty(APPLICATION_CONTEXT_PROPERTY, confDir\r
-                                               .getAbsolutePath()\r
-                                               + "/applicationContext.xml");\r
-                       }\r
-                       // Default test run\r
-                       if (all.getProperty(SlcAntConstants.DEFAULT_TEST_RUN_PROPERTY) == null) {\r
-                               all.setProperty(SlcAntConstants.DEFAULT_TEST_RUN_PROPERTY, "defaultTestRun");\r
-                       }\r
-\r
-                       // Default log4j\r
-                       if (all.getProperty("log4j.configuration") == null) {\r
-                               System.setProperty("log4j.configuration", confDir\r
-                                               .getCanonicalPath()\r
-                                               + File.separator + "log4j.properties");\r
-                               // TODO: fix dependency to log4j\r
-                               Log4jConfigurer.initLogging(confDir.getCanonicalPath()\r
-                                               + File.separator + "log4j.properties");\r
-                       }\r
-               } catch (Exception e) {\r
-                       throw new SlcAntException("Unexpected exception while configuring",\r
-                                       e);\r
-               }\r
-       }\r
-\r
-       /** Loads the content of a file as <code>Properties</code>. */\r
-       private Properties loadFile(String path) {\r
-               Properties p = new Properties();\r
-               try {\r
-                       FileInputStream in = new FileInputStream(path);\r
-                       p.load(in);\r
-                       in.close();\r
-               } catch (IOException e) {\r
-                       throw new SlcAntException("Cannot read SLC root file", e);\r
-               }\r
-               return p;\r
-       }\r
-\r
-       /**\r
-        * Looks for a file named {@link #getSlcLocalFileName()} in the directory,\r
-        * loads it as properties file and return the value of the property\r
-        * {@link #DIR_LABEL_PROPERTY}.\r
-        */\r
-       public String getDescriptionForDir(File dir) {\r
-               String description = dir.getName();\r
-               File slcLocal = new File(dir.getPath() + File.separator\r
-                               + getSlcLocalFileName());\r
-               if (slcLocal.exists()) {\r
-                       Properties properties = loadFile(slcLocal.getAbsolutePath());\r
-                       description = properties.getProperty(\r
-                                       SlcAntConfig.DIR_LABEL_PROPERTY, description);\r
-               }\r
-               return description;\r
-       }\r
-\r
-       /**\r
-        * Recursively scans directories downwards until it find a file names as\r
-        * defined by {@link #getSlcRootFileName()}.\r
-        */\r
-       public File findSlcRootFile(File dir) {\r
-               for (File file : dir.listFiles()) {\r
-                       if (!file.isDirectory()\r
-                                       && file.getName().equals(getSlcRootFileName())) {\r
-                               return file;\r
-                       }\r
-               }\r
-\r
-               File parentDir = dir.getParentFile();\r
-               if (parentDir == null) {\r
-                       return null;// stop condition: not found\r
-               } else {\r
-                       return findSlcRootFile(parentDir);\r
-               }\r
-       }\r
-\r
-       /**\r
-        * Gets the file name of the file marking the root directory, default being\r
-        * <i>slcRoot.properties</i>.\r
-        */\r
-       public String getSlcRootFileName() {\r
-               return slcRootFileName;\r
-       }\r
-\r
-       /** Sets the file name of the file marking the root directory. */\r
-       public void setSlcRootFileName(String slcRootFileName) {\r
-               this.slcRootFileName = slcRootFileName;\r
-       }\r
-\r
-       /**\r
-        * Gets the file name of the file containing directory specific properties,\r
-        * default being <i>slcLocal.properties</i>.\r
-        */\r
-       public String getSlcLocalFileName() {\r
-               return slcLocalFileName;\r
-       }\r
-\r
-       /** Sets the file name of the file containing directory specific properties. */\r
-       public void setSlcLocalFileName(String slcLocalFileName) {\r
-               this.slcLocalFileName = slcLocalFileName;\r
-       }\r
-\r
-}\r
index 2b9400e4b0efb58fe3b7baff387ca68f70d91b6d..da682ba6fe606236a53cc9966b344a961342b673 100644 (file)
@@ -5,9 +5,7 @@ import java.util.Vector;
 \r
 import org.apache.log4j.AppenderSkeleton;\r
 import org.apache.log4j.Level;\r
-import org.apache.log4j.LogManager;\r
 import org.apache.log4j.MDC;\r
-import org.apache.log4j.Priority;\r
 import org.apache.log4j.spi.LoggingEvent;\r
 import org.apache.tools.ant.BuildEvent;\r
 import org.apache.tools.ant.BuildListener;\r
@@ -16,7 +14,6 @@ import org.argeo.slc.core.SlcException;
 import org.argeo.slc.core.process.SlcExecution;\r
 import org.argeo.slc.core.process.SlcExecutionNotifier;\r
 import org.argeo.slc.core.process.SlcExecutionStep;\r
-import org.argeo.slc.ws.process.WebServiceSlcExecutionNotifier;\r
 \r
 public class SlcExecutionBuildListener extends AppenderSkeleton implements\r
                BuildListener {\r
diff --git a/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/SlcProjectHelper.java b/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/SlcProjectHelper.java
deleted file mode 100644 (file)
index 2271481..0000000
+++ /dev/null
@@ -1,247 +0,0 @@
-package org.argeo.slc.ant;\r
-\r
-import java.io.File;\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.net.InetAddress;\r
-import java.net.UnknownHostException;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Properties;\r
-import java.util.UUID;\r
-import java.util.Vector;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-import org.apache.tools.ant.BuildException;\r
-import org.apache.tools.ant.Project;\r
-import org.apache.tools.ant.helper.ProjectHelper2;\r
-import org.argeo.slc.core.process.SlcExecution;\r
-import org.argeo.slc.core.structure.DefaultSRegistry;\r
-import org.argeo.slc.core.structure.SimpleSElement;\r
-import org.argeo.slc.core.structure.StructureRegistry;\r
-import org.argeo.slc.core.structure.tree.TreeSPath;\r
-import org.springframework.beans.factory.ListableBeanFactory;\r
-import org.springframework.context.support.AbstractApplicationContext;\r
-import org.springframework.context.support.FileSystemXmlApplicationContext;\r
-\r
-/**\r
- * Custom implementation of an Ant <code>ProjectHelper</code> binding a Spring\r
- * application context and a structure registry with the Ant project.\r
- */\r
-public class SlcProjectHelper extends ProjectHelper2 {\r
-       private static Log log;\r
-\r
-       protected SlcAntConfig slcAntConfig = null;\r
-\r
-       @Override\r
-       public void parse(Project project, Object source) throws BuildException {\r
-\r
-               if (source instanceof File) {\r
-                       File sourceFile = (File) source;\r
-                       // Reset basedir property, in order to avoid base dir override when\r
-                       // running in Maven\r
-                       project.setProperty("basedir", sourceFile.getParentFile()\r
-                                       .getAbsolutePath());\r
-               }\r
-\r
-               if (slcAntConfig != null) {\r
-                       // Config already initialized (probably import), only parse\r
-                       super.parse(project, source);\r
-                       return;\r
-               }\r
-\r
-               // Initialize config\r
-               slcAntConfig = new SlcAntConfig();\r
-\r
-               if (!slcAntConfig.initProject(project)) {\r
-                       // not SLC compatible, do normal Ant\r
-                       super.parse(project, source);\r
-                       return;\r
-               }\r
-\r
-               if (log == null) {\r
-                       // log4j is initialized only now\r
-                       log = LogFactory.getLog(SlcProjectHelper.class);\r
-               }\r
-\r
-               if (log.isDebugEnabled())\r
-                       log.debug("SLC properties are set, starting initialization for "\r
-                                       + source + " (projectHelper=" + this + ")");\r
-\r
-               beforeParsing(project);\r
-\r
-               // Calls the underlying implementation to do the actual work\r
-               super.parse(project, source);\r
-\r
-               afterParsing(project);\r
-       }\r
-\r
-       /**\r
-        * Performs operations after config initialization and before Ant file\r
-        * parsing. Performed only once when the main project file is parsed. Should\r
-        * be called by overriding methods.\r
-        */\r
-       protected void beforeParsing(Project project) {\r
-               // Init Spring application context\r
-               initSpringContext(project);\r
-\r
-               // Init structure registry\r
-               DefaultSRegistry registry = new DefaultSRegistry();\r
-               project.addReference(SlcAntConstants.REF_STRUCTURE_REGISTRY, registry);\r
-       }\r
-\r
-       /**\r
-        * Performs operations after parsing of the main file. Called only once (not\r
-        * for imports).\r
-        */\r
-       protected void afterParsing(Project project) {\r
-               // Creates structure root\r
-               registerProjectAndParents(project, slcAntConfig);\r
-               addCustomTaskAndTypes(project);\r
-       }\r
-\r
-       /** Creates the tree-based structure for this project. */\r
-       private void registerProjectAndParents(Project project,\r
-                       SlcAntConfig slcAntConfig) {\r
-               StructureRegistry<TreeSPath> registry = (StructureRegistry<TreeSPath>) project\r
-                               .getReference(SlcAntConstants.REF_STRUCTURE_REGISTRY);\r
-               File rootDir = new File(project\r
-                               .getUserProperty(SlcAntConstants.ROOT_DIR_PROPERTY))\r
-                               .getAbsoluteFile();\r
-               File baseDir = project.getBaseDir().getAbsoluteFile();\r
-               List<File> dirs = new Vector<File>();\r
-               File currentDir = baseDir;\r
-               do {\r
-                       dirs.add(currentDir);\r
-                       currentDir = currentDir.getParentFile();\r
-                       if (log.isTraceEnabled())\r
-                               log.trace("List " + currentDir);\r
-               } while (!currentDir.equals(rootDir.getParentFile()));\r
-\r
-               // first path is root dir (because of previous algorithm)\r
-               TreeSPath currPath = TreeSPath.createRootPath(rootDir.getName());\r
-               for (int i = dirs.size() - 1; i >= 0; i--) {\r
-                       File dir = dirs.get(i);\r
-\r
-                       // retrieves description for this path\r
-                       final String description;\r
-                       if (i == 0) {// project itself\r
-                               description = project.getDescription() != null\r
-                                               && !project.getDescription().equals("") ? project\r
-                                               .getDescription() : project.getName() != null ? project\r
-                                               .getName() : slcAntConfig.getDescriptionForDir(dir);\r
-                       } else {\r
-                               description = slcAntConfig.getDescriptionForDir(dir);\r
-                               if (log.isTraceEnabled())\r
-                                       log.trace("Dir desc " + i + "/" + dirs.size() + ": "\r
-                                                       + description);\r
-                       }\r
-                       SimpleSElement element = new SimpleSElement(description);\r
-\r
-                       // creates and register path\r
-                       if (!dir.equals(rootDir)) {// already set\r
-                               currPath = currPath.createChild(dir.getName());\r
-                       }\r
-                       registry.register(currPath, element);\r
-               }\r
-               project.addReference(SlcAntConstants.REF_PROJECT_PATH, currPath);\r
-       }\r
-\r
-       /** Gets the path of a project (root). */\r
-       // private static TreeSPath getProjectPath(Project project) {\r
-       // return (TreeSPath) project.getReference(REF_PROJECT_PATH);\r
-       // }\r
-       /** Initializes the Spring application context. */\r
-       private void initSpringContext(Project project) {\r
-               System.getProperties().putAll((Map<?, ?>) project.getProperties());\r
-               String acPath = project\r
-                               .getUserProperty(SlcAntConfig.APPLICATION_CONTEXT_PROPERTY);\r
-               if (log.isDebugEnabled())\r
-                       log.debug("Loading Spring application context from " + acPath);\r
-               // FIXME: workaround to the removal of leading '/' by Spring\r
-               // use URL instead?\r
-               AbstractApplicationContext context = new FileSystemXmlApplicationContext(\r
-                               '/' + acPath);\r
-               context.registerShutdownHook();\r
-               project.addReference(SlcAntConstants.REF_ROOT_CONTEXT, context);\r
-\r
-               createAndRegisterSlcExecution(project);\r
-               // Add build listeners declared in Spring context\r
-               // Map<String, BuildListener> listeners = context.getBeansOfType(\r
-               // BuildListener.class, false, true);\r
-               // for (BuildListener listener : listeners.values()) {\r
-               // project.addBuildListener(listener);\r
-               // }\r
-       }\r
-\r
-       /** Loads the SLC specific Ant tasks. */\r
-       protected static void addCustomTaskAndTypes(Project project) {\r
-               Properties taskdefs = getDefs(project, SlcAntConstants.SLC_TASKDEFS_RESOURCE_PATH);\r
-               for (Object o : taskdefs.keySet()) {\r
-                       String name = o.toString();\r
-                       try {\r
-                               project.addTaskDefinition(name, Class.forName(taskdefs\r
-                                               .getProperty(name)));\r
-                       } catch (ClassNotFoundException e) {\r
-                               log.error("Unknown class for task " + name, e);\r
-                       }\r
-               }\r
-               Properties typedefs = getDefs(project, SlcAntConstants.SLC_TYPEDEFS_RESOURCE_PATH);\r
-               for (Object o : typedefs.keySet()) {\r
-                       String name = o.toString();\r
-                       try {\r
-                               project.addDataTypeDefinition(name, Class.forName(typedefs\r
-                                               .getProperty(name)));\r
-                       } catch (ClassNotFoundException e) {\r
-                               log.error("Unknown class for type " + name, e);\r
-                       }\r
-               }\r
-       }\r
-\r
-       private static Properties getDefs(Project project, String path) {\r
-               Properties defs = new Properties();\r
-               try {\r
-                       InputStream in = project.getClass().getResourceAsStream(path);\r
-                       defs.load(in);\r
-                       in.close();\r
-               } catch (IOException e) {\r
-                       throw new SlcAntException("Cannot load task definitions", e);\r
-               }\r
-               return defs;\r
-       }\r
-\r
-       protected static void createAndRegisterSlcExecution(Project project) {\r
-               SlcExecution slcExecution = new SlcExecution();\r
-               slcExecution.setUuid(UUID.randomUUID().toString());\r
-               try {\r
-                       slcExecution.setHost(InetAddress.getLocalHost().getHostName());\r
-               } catch (UnknownHostException e) {\r
-                       slcExecution.setHost(SlcExecution.UNKOWN_HOST);\r
-               }\r
-\r
-               if (project.getReference(SlcAntConstants.REF_ROOT_CONTEXT) != null) {\r
-                       slcExecution.setType(SlcAntConstants.EXECTYPE_SLC_ANT);\r
-               } else {\r
-                       slcExecution.setType(SlcAntConstants.EXECTYPE_ANT);\r
-               }\r
-\r
-               slcExecution.setUser(System.getProperty("user.name"));\r
-               slcExecution.setStatus(SlcExecution.STATUS_RUNNING);\r
-               slcExecution.getAttributes().put("ant.file",\r
-                               project.getProperty("ant.file"));\r
-\r
-               project.addReference(SlcAntConstants.REF_SLC_EXECUTION,\r
-                               slcExecution);\r
-\r
-               // Add build listeners declared in Spring context\r
-               Map<String, ProjectRelatedBuildListener> listeners = ((ListableBeanFactory) project\r
-                               .getReference(SlcAntConstants.REF_ROOT_CONTEXT)).getBeansOfType(\r
-                               ProjectRelatedBuildListener.class, false, true);\r
-               for (ProjectRelatedBuildListener listener : listeners.values()) {\r
-                       listener.init(project);\r
-                       project.addBuildListener(listener);\r
-               }\r
-\r
-       }\r
-}\r
index 8e6fc63b108b84b04c0df2a15b8c8d84241512d2..e6d42db9aed3f68bdb21490680f7652fcafcf4bf 100644 (file)
@@ -3,7 +3,6 @@ package org.argeo.slc.ant.deploy;
 import org.apache.commons.logging.Log;\r
 import org.apache.commons.logging.LogFactory;\r
 import org.apache.tools.ant.BuildException;\r
-import org.argeo.slc.ant.SlcAntConfig;\r
 import org.argeo.slc.ant.spring.SpringArg;\r
 import org.argeo.slc.ant.structure.SAwareTask;\r
 import org.argeo.slc.core.build.Distribution;\r
index 651ccad7b959eefd4c79f6825b7454a214dc6fef..e5ccab51a2ec8ed34d2f2dc6be03acbc4304fb5f 100644 (file)
@@ -3,7 +3,6 @@ package org.argeo.slc.ant.test;
 import org.apache.commons.logging.Log;\r
 import org.apache.commons.logging.LogFactory;\r
 import org.apache.tools.ant.BuildException;\r
-import org.argeo.slc.ant.SlcAntConfig;\r
 import org.argeo.slc.ant.SlcAntConstants;\r
 import org.argeo.slc.ant.spring.SpringArg;\r
 import org.argeo.slc.ant.structure.SAwareTask;\r
index efe4ca73ea8f61667bb4f9348b2ccc3cd23d86f0..22050b4e861119b51d449f6b879a9def7e3be225 100644 (file)
@@ -2,10 +2,8 @@ package org.argeo.slc.ant.unit;
 
 import junit.framework.TestCase;
 
-import org.apache.tools.ant.launch.AntMain;
 import org.argeo.slc.ant.AntExecutionContext;
 import org.argeo.slc.cli.DefaultSlcRuntime;
-import org.argeo.slc.runtime.SlcExecutionContext;
 import org.argeo.slc.runtime.SlcExecutionOutput;
 
 public abstract class SlcAntAppliTestCase extends TestCase implements
index fcf27246462847e5db34c439298451b0d2ee9dbf..adae463c2b4cc564dab651a2a018bae1d2aed783 100644 (file)
@@ -18,7 +18,6 @@ import org.argeo.slc.ant.SlcAntConstants;
 import org.argeo.slc.ant.SlcAntException;
 import org.argeo.slc.core.SlcException;
 import org.argeo.slc.core.process.SlcExecution;
-import org.argeo.slc.runtime.SlcExecutionContext;
 import org.argeo.slc.runtime.SlcExecutionOutput;
 import org.argeo.slc.spring.SpringUtils;
 import org.springframework.core.io.DefaultResourceLoader;
index dfbd7053c09f4c1d9627068b546f50fc7cb16ea7..10636f3d4191815a8a97d102dce1e10d8598828e 100644 (file)
@@ -1,6 +1,5 @@
 package org.argeo.slc.cli;
 
-import java.io.File;
 import java.util.Properties;
 
 import org.apache.commons.cli.CommandLine;
@@ -15,9 +14,6 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.argeo.slc.core.SlcException;
 import org.argeo.slc.logging.Log4jUtils;
-import org.springframework.core.io.DefaultResourceLoader;
-import org.springframework.core.io.FileSystemResource;
-import org.springframework.core.io.Resource;
 
 public class SlcMain {
        public enum Mode {
index ebe06ea82807eb94969cf26c5c452557239d7a9a..223eb300fc2b71ce17aba4def2c85a9f298039c2 100644 (file)
@@ -8,7 +8,7 @@ import java.util.UUID;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.ant.AntRegistryUtil;
+import org.argeo.slc.ant.AntRunner;
 import org.argeo.slc.core.SlcException;
 import org.argeo.slc.core.deploy.DeployEnvironment;
 
@@ -52,9 +52,9 @@ public class MavenDeployEnvironment implements DeployEnvironment {
                                        "org/argeo/slc/support/deploy/ant/build.xml");
 
                        if (type == null || type.equals("zip")) {
-                               AntRegistryUtil.runAll(antUrl, "deployZip", props);
+                               new AntRunner(antUrl, "deployZip", props).run();
                        } else if (type.equals("tar.gz")) {
-                               AntRegistryUtil.runAll(antUrl, "deployTarGz", props);
+                               new AntRunner(antUrl, "deployTarGz", props).run();
                        } else {
                                throw new SlcException("Unknow package type " + type);
                        }
diff --git a/org.argeo.slc.agent/src/main/resources/META-INF/services/org.apache.tools.ant.ProjectHelper b/org.argeo.slc.agent/src/main/resources/META-INF/services/org.apache.tools.ant.ProjectHelper
deleted file mode 100644 (file)
index 1c222d5..0000000
+++ /dev/null
@@ -1 +0,0 @@
-org.argeo.slc.ant.SlcProjectHelper
\ No newline at end of file
index 7b3d662f78cec935c08b51aba8f134404f219117..ab80744af5bff8b22e8118f0985b20cf6884f9b3 100644 (file)
@@ -1,25 +1,22 @@
 package org.argeo.slc.ws;\r
 \r
-import java.net.URL;\r
-\r
 import org.apache.commons.logging.Log;\r
 import org.apache.commons.logging.LogFactory;\r
-\r
-import org.argeo.slc.ant.AntRunner;\r
 import org.argeo.slc.unit.AbstractSpringTestCase;\r
 \r
 public class SlcAntWsIntegrationTest extends AbstractSpringTestCase {\r
        private Log log = LogFactory.getLog(getClass());\r
 \r
        public void testSimpleRun() {\r
+               fail("Adapt to new runtime");\r
                // AntRegistryUtil.runAll(getClass().getResource(\r
                // "/org/argeo/slc/ant/build.xml"), "test", null);\r
 \r
-               URL url = getClass().getResource("/org/argeo/slc/ant/build.xml");\r
-               log.info("Run Ant file from URL: " + url);\r
-               AntRunner antRunner = new AntRunner(getContext(), url, "test");\r
-\r
-               antRunner.run();\r
+               // URL url = getClass().getResource("/org/argeo/slc/ant/build.xml");\r
+               // log.info("Run Ant file from URL: " + url);\r
+               // AntRunner antRunner = new AntRunner(getContext(), url, "test");\r
+               //\r
+               // antRunner.run();\r
        }\r
 \r
 }\r