]> git.argeo.org Git - gpl/argeo-slc.git/commitdiff
Rename Ant constants
authorMathieu Baudier <mbaudier@argeo.org>
Sat, 21 Jun 2008 18:18:19 +0000 (18:18 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Sat, 21 Jun 2008 18:18:19 +0000 (18:18 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@1279 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/AntConstants.java [new file with mode: 0644]
org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/AntExecutionContext.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/SlcAntConstants.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/spring/AbstractSpringTask.java
org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/spring/SpringArg.java
org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/structure/SAwareTask.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/cli/DefaultSlcRuntime.java
org.argeo.slc.agent/src/test/java/org/argeo/slc/ant/SlcAntTest.java

diff --git a/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/AntConstants.java b/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/AntConstants.java
new file mode 100644 (file)
index 0000000..1e6cf14
--- /dev/null
@@ -0,0 +1,44 @@
+package org.argeo.slc.ant;
+
+public interface AntConstants {
+       // ANT
+       /** The Ant reference to the Spring application context used. */
+       public static final String REF_ROOT_CONTEXT = "slcApplicationContext";
+       /** The Ant reference to the SLC structure registry used. */
+       public static final String REF_STRUCTURE_REGISTRY = "slcStructureRegistry";
+       /** The Ant reference to the <code>TreePath</code> of the current project */
+       public static final String REF_PROJECT_PATH = "slcProjectPath";
+       /**
+        * Resource path to the property file listing the SLC specific Ant tasks:
+        * /org/argeo/slc/ant/taskdefs.properties
+        */
+       public static final String SLC_TASKDEFS_RESOURCE_PATH = "/org/argeo/slc/ant/taskdefs.properties";
+       /**
+        * Resource path to the property file listing the SLC specific Ant types:
+        * /org/argeo/slc/ant/typedefs.properties
+        */
+       public static final String SLC_TYPEDEFS_RESOURCE_PATH = "/org/argeo/slc/ant/typedefs.properties";
+       public static final String REF_SLC_EXECUTION = "slcExecution";
+
+       // SLC EXECUTION
+       public static final String EXECTYPE_ANT = "org.apache.tools.ant";
+       public static final String EXECTYPE_SLC_ANT = "org.argeo.slc.ant";
+
+       public final static String EXECATTR_RUNTIME = "slc.runtime";
+       public final static String EXECATTR_ANT_FILE = "ant.file";
+       public final static String EXECATTR_ANT_TARGETS = "ant.targets";
+
+       // PROPERTIES
+       /** Property for the root dir (SLC root property file). */
+       public final static String ROOT_DIR_PROPERTY = "slc.rootDir";
+       /** Property for the conf dir (SLC root property file). */
+       public final static String CONF_DIR_PROPERTY = "slc.confDir";
+       /** Property for the work dir (SLC root property file). */
+       public final static String WORK_DIR_PROPERTY = "slc.workDir";
+       /** Name of the Spring bean used by default */
+       public final static String DEFAULT_TEST_RUN_PROPERTY = "slc.defaultTestRun";
+
+       // LOG4J
+       public final static String MDC_ANT_PROJECT = "slc.ant.project";
+
+}
index d78b8f8ee4720ac976a36a4891fc32a66e0f760d..a010e7fad14cff66c84696e75adee3c5aca08ecf 100644 (file)
@@ -14,13 +14,13 @@ public class AntExecutionContext implements SlcExecutionContext {
 
        public <T> T getBean(String name) {
                ApplicationContext context = (ApplicationContext) project
-                               .getReference(SlcAntConstants.REF_ROOT_CONTEXT);
+                               .getReference(AntConstants.REF_ROOT_CONTEXT);
                return (T) context.getBean(name);
        }
 
        public SlcExecution getSlcExecution() {
                return (SlcExecution) project
-                               .getReference(SlcAntConstants.REF_SLC_EXECUTION);
+                               .getReference(AntConstants.REF_SLC_EXECUTION);
        }
 
        public Project getProject() {
index 8b8d2e4e5e3f564e85f646851f167603c2d6d3fa..ae1f8ef13dbd2f6cd836bd1d60b271f503b6ef9c 100644 (file)
@@ -77,8 +77,8 @@ public class AntSlcApplication {
                // Ant project initialization
                Project project = new Project();
                AntExecutionContext executionContext = new AntExecutionContext(project);
-               project.addReference(SlcAntConstants.REF_ROOT_CONTEXT, ctx);
-               project.addReference(SlcAntConstants.REF_SLC_EXECUTION, slcExecution);
+               project.addReference(AntConstants.REF_ROOT_CONTEXT, ctx);
+               project.addReference(AntConstants.REF_SLC_EXECUTION, slcExecution);
                initProject(project, properties, references);
                parseProject(project, scriptRelativePath);
 
@@ -102,20 +102,20 @@ public class AntSlcApplication {
                        }
                }
 
-               if (System.getProperty(SlcAntConstants.DEFAULT_TEST_RUN_PROPERTY) == null) {
-                       System.setProperty(SlcAntConstants.DEFAULT_TEST_RUN_PROPERTY,
+               if (System.getProperty(AntConstants.DEFAULT_TEST_RUN_PROPERTY) == null) {
+                       System.setProperty(AntConstants.DEFAULT_TEST_RUN_PROPERTY,
                                        "defaultTestRun");
                }
 
                try {
                        if (rootDir != null)
-                               System.setProperty(SlcAntConstants.ROOT_DIR_PROPERTY, rootDir
+                               System.setProperty(AntConstants.ROOT_DIR_PROPERTY, rootDir
                                                .getURL().toString());
                        if (confDir != null)
-                               System.setProperty(SlcAntConstants.CONF_DIR_PROPERTY, confDir
+                               System.setProperty(AntConstants.CONF_DIR_PROPERTY, confDir
                                                .getURL().toString());
                        if (workDir != null)
-                               System.setProperty(SlcAntConstants.WORK_DIR_PROPERTY, workDir
+                               System.setProperty(AntConstants.WORK_DIR_PROPERTY, workDir
                                                .getCanonicalPath());
 
                        // Additional properties in slc.properties file. Already set sytem
@@ -155,7 +155,7 @@ public class AntSlcApplication {
                        // Find runtime definition
                        Resource runtimeRes = null;
                        String runtimeStr = slcExecution.getAttributes().get(
-                                       SlcAntConstants.EXECATTR_RUNTIME);
+                                       AntConstants.EXECATTR_RUNTIME);
                        if (runtimeStr == null)
                                runtimeStr = "default";
 
@@ -208,7 +208,7 @@ public class AntSlcApplication {
 
        protected String findAntScript(SlcExecution slcExecution) {
                String scriptStr = slcExecution.getAttributes().get(
-                               SlcAntConstants.EXECATTR_ANT_FILE);
+                               AntConstants.EXECATTR_ANT_FILE);
                if (scriptStr == null)
                        throw new SlcException("No Ant script provided");
 
@@ -217,7 +217,7 @@ public class AntSlcApplication {
 
        protected List<String> findAntTargets(SlcExecution slcExecution) {
                String targetList = slcExecution.getAttributes().get(
-                               SlcAntConstants.EXECATTR_ANT_TARGETS);
+                               AntConstants.EXECATTR_ANT_TARGETS);
                List<String> targets = new Vector<String>();
                if (targetList != null) {
                        StringTokenizer stTargets = new StringTokenizer(targetList, ",");
@@ -246,7 +246,7 @@ public class AntSlcApplication {
                project.addBuildListener(new CommonsLoggingListener());
 
                ListableBeanFactory context = (ListableBeanFactory) project
-                               .getReference(SlcAntConstants.REF_ROOT_CONTEXT);
+                               .getReference(AntConstants.REF_ROOT_CONTEXT);
                // Register build listeners
                Map<String, BuildListener> listeners = context.getBeansOfType(
                                BuildListener.class, false, true);
@@ -255,7 +255,7 @@ public class AntSlcApplication {
                }
 
                // Register log4j appenders from context
-               MDC.put(SlcAntConstants.MDC_ANT_PROJECT, project);
+               MDC.put(AntConstants.MDC_ANT_PROJECT, project);
                Map<String, Appender> appenders = context.getBeansOfType(
                                Appender.class, false, true);
                for (Appender appender : appenders.values()) {
@@ -269,7 +269,7 @@ public class AntSlcApplication {
        /** Loads the SLC specific Ant tasks. */
        protected void addCustomTaskAndTypes(Project project) {
                Properties taskdefs = getDefs(project,
-                               SlcAntConstants.SLC_TASKDEFS_RESOURCE_PATH);
+                               AntConstants.SLC_TASKDEFS_RESOURCE_PATH);
                for (Object o : taskdefs.keySet()) {
                        String name = o.toString();
                        try {
@@ -280,7 +280,7 @@ public class AntSlcApplication {
                        }
                }
                Properties typedefs = getDefs(project,
-                               SlcAntConstants.SLC_TYPEDEFS_RESOURCE_PATH);
+                               AntConstants.SLC_TYPEDEFS_RESOURCE_PATH);
                for (Object o : typedefs.keySet()) {
                        String name = o.toString();
                        try {
@@ -307,7 +307,7 @@ public class AntSlcApplication {
        protected void initStructure(Project project, String scriptRelativePath) {
                // Init structure registry
                StructureRegistry<TreeSPath> registry = new TreeSRegistry();
-               project.addReference(SlcAntConstants.REF_STRUCTURE_REGISTRY, registry);
+               project.addReference(AntConstants.REF_STRUCTURE_REGISTRY, registry);
 
                // Lowest levels
                StringTokenizer st = new StringTokenizer(scriptRelativePath, "/");
@@ -334,7 +334,7 @@ public class AntSlcApplication {
                                .getDescription() : projectPath.getName();
 
                registry.register(projectPath, new SimpleSElement(projectDesc));
-               project.addReference(SlcAntConstants.REF_PROJECT_PATH, projectPath);
+               project.addReference(AntConstants.REF_PROJECT_PATH, projectPath);
 
                if (log.isDebugEnabled())
                        log.debug("Project path: " + projectPath);
diff --git a/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/SlcAntConstants.java b/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/SlcAntConstants.java
deleted file mode 100644 (file)
index 7e234b1..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.argeo.slc.ant;
-
-public interface SlcAntConstants {
-       // ANT
-       /** The Ant reference to the Spring application context used. */
-       public static final String REF_ROOT_CONTEXT = "slcApplicationContext";
-       /** The Ant reference to the SLC structure registry used. */
-       public static final String REF_STRUCTURE_REGISTRY = "slcStructureRegistry";
-       /** The Ant reference to the <code>TreePath</code> of the current project */
-       public static final String REF_PROJECT_PATH = "slcProjectPath";
-       /**
-        * Resource path to the property file listing the SLC specific Ant tasks:
-        * /org/argeo/slc/ant/taskdefs.properties
-        */
-       public static final String SLC_TASKDEFS_RESOURCE_PATH = "/org/argeo/slc/ant/taskdefs.properties";
-       /**
-        * Resource path to the property file listing the SLC specific Ant types:
-        * /org/argeo/slc/ant/typedefs.properties
-        */
-       public static final String SLC_TYPEDEFS_RESOURCE_PATH = "/org/argeo/slc/ant/typedefs.properties";
-       public static final String REF_SLC_EXECUTION = "slcExecution";
-
-       // SLC EXECUTION
-       public static final String EXECTYPE_ANT = "org.apache.tools.ant";
-       public static final String EXECTYPE_SLC_ANT = "org.argeo.slc.ant";
-
-       public final static String EXECATTR_RUNTIME = "slc.runtime";
-       public final static String EXECATTR_ANT_FILE = "ant.file";
-       public final static String EXECATTR_ANT_TARGETS = "ant.targets";
-
-       // PROPERTIES
-       /** Property for the root dir (SLC root property file). */
-       public final static String ROOT_DIR_PROPERTY = "slc.rootDir";
-       /** Property for the conf dir (SLC root property file). */
-       public final static String CONF_DIR_PROPERTY = "slc.confDir";
-       /** Property for the work dir (SLC root property file). */
-       public final static String WORK_DIR_PROPERTY = "slc.workDir";
-       /** Name of the Spring bean used by default */
-       public final static String DEFAULT_TEST_RUN_PROPERTY = "slc.defaultTestRun";
-
-       // LOG4J
-       public final static String MDC_ANT_PROJECT = "slc.ant.project";
-
-}
index 3e427b1397d6e3ad39eb74540b89f2754e752daa..64dc33e98bd2736431c88722cd907757d4389b56 100644 (file)
@@ -130,7 +130,7 @@ public class SlcExecutionBuildListener extends AppenderSkeleton implements
 \r
        protected SlcExecution getSlcExecution(Project project) {\r
                SlcExecution slcExecution = (SlcExecution) project\r
-                               .getReference(SlcAntConstants.REF_SLC_EXECUTION);\r
+                               .getReference(AntConstants.REF_SLC_EXECUTION);\r
 \r
                if (slcExecution == null)\r
                        throw new SlcException("No SLC Execution registered.");\r
@@ -162,7 +162,7 @@ public class SlcExecutionBuildListener extends AppenderSkeleton implements
 \r
        @Override\r
        protected void append(LoggingEvent event) {\r
-               Project project = (Project) MDC.get(SlcAntConstants.MDC_ANT_PROJECT);\r
+               Project project = (Project) MDC.get(AntConstants.MDC_ANT_PROJECT);\r
                if (project == null)\r
                        throw new SlcException("No Ant project registered in Log4j MDC.");\r
 \r
index ebc14c215b92463c4bb1659c364abd9a2854b810..f0eae3fd070c374e7fa95b2215725029e74be8f9 100644 (file)
@@ -4,7 +4,7 @@ import org.springframework.context.ApplicationContext;
 \r
 import org.apache.tools.ant.Task;\r
 \r
-import org.argeo.slc.ant.SlcAntConstants;\r
+import org.argeo.slc.ant.AntConstants;\r
 import org.argeo.slc.core.process.SlcExecution;\r
 \r
 /** Abstract Ant task providing access to a Spring context. */\r
@@ -13,12 +13,12 @@ public abstract class AbstractSpringTask extends Task {
        /** Gets the related Spring context. */\r
        protected ApplicationContext getContext() {\r
                return (ApplicationContext) getProject().getReference(\r
-                               SlcAntConstants.REF_ROOT_CONTEXT);\r
+                               AntConstants.REF_ROOT_CONTEXT);\r
        }\r
 \r
        /** Gets the related slc execution or null if not is registered. */\r
        protected SlcExecution getSlcExecution() {\r
                return (SlcExecution) getProject().getReference(\r
-                               SlcAntConstants.REF_SLC_EXECUTION);\r
+                               AntConstants.REF_SLC_EXECUTION);\r
        }\r
 }\r
index 75b3447c5182e7c7e386f1d89416063801245fa3..c84c96567d80d0df8e7e9a9558e09277db91fca5 100644 (file)
@@ -5,7 +5,7 @@ import java.util.Vector;
 \r
 import org.apache.tools.ant.BuildException;\r
 import org.apache.tools.ant.types.DataType;\r
-import org.argeo.slc.ant.SlcAntConstants;\r
+import org.argeo.slc.ant.AntConstants;\r
 import org.argeo.slc.core.SlcException;\r
 import org.springframework.beans.BeanWrapper;\r
 import org.springframework.beans.BeanWrapperImpl;\r
@@ -103,7 +103,7 @@ public class SpringArg<T> extends DataType {
        /** The related Spring application context. */\r
        protected ApplicationContext getContext() {\r
                return (ApplicationContext) getProject().getReference(\r
-                               SlcAntConstants.REF_ROOT_CONTEXT);\r
+                               AntConstants.REF_ROOT_CONTEXT);\r
        }\r
 \r
        protected void checkValueAlreadySet() {\r
index 8c0cf9d76bd7fb7a6786ad94fb19d857671eab93..343db96444868e3f4743de3dddb3d519b9f60105 100644 (file)
@@ -5,7 +5,7 @@ import java.util.Vector;
 \r
 import org.apache.tools.ant.BuildException;\r
 import org.apache.tools.ant.Target;\r
-import org.argeo.slc.ant.SlcAntConstants;\r
+import org.argeo.slc.ant.AntConstants;\r
 import org.argeo.slc.ant.spring.AbstractSpringTask;\r
 import org.argeo.slc.ant.spring.SpringArg;\r
 import org.argeo.slc.core.SlcException;\r
@@ -124,13 +124,13 @@ public abstract class SAwareTask extends AbstractSpringTask {
        /** Gets the underlying structure registry. */\r
        protected StructureRegistry<TreeSPath> getRegistry() {\r
                return (StructureRegistry<TreeSPath>) getProject().getReference(\r
-                               SlcAntConstants.REF_STRUCTURE_REGISTRY);\r
+                               AntConstants.REF_STRUCTURE_REGISTRY);\r
        }\r
 \r
        /** Creates the treeSPath for a given Ant target. */\r
        protected static TreeSPath createTargetPath(Target target) {\r
                TreeSPath projectPath = (TreeSPath) target.getProject().getReference(\r
-                               SlcAntConstants.REF_PROJECT_PATH);\r
+                               AntConstants.REF_PROJECT_PATH);\r
                return projectPath.createChild(target.getName());\r
        }\r
 \r
index d5185b9c72886650ad4cc76b6496f73110d098a9..37daed7d50b1f00b0ea165ceb735d2e4dd23ad92 100644 (file)
@@ -3,7 +3,7 @@ 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.SlcAntConstants;\r
+import org.argeo.slc.ant.AntConstants;\r
 import org.argeo.slc.ant.spring.SpringArg;\r
 import org.argeo.slc.ant.structure.SAwareTask;\r
 import org.argeo.slc.core.deploy.DeployedSystem;\r
@@ -39,7 +39,7 @@ public class SlcTestTask extends SAwareTask {
                        testRunBeanT = testRunBean;\r
                } else {\r
                        testRunBeanT = getProject().getProperty(\r
-                                       SlcAntConstants.DEFAULT_TEST_RUN_PROPERTY);\r
+                                       AntConstants.DEFAULT_TEST_RUN_PROPERTY);\r
                }\r
                WritableTestRun testRun = null;\r
 \r
index 4b3aa0b153479f74d1d65dc23fcfb152ca5e381a..3fc2a5671fced3e77bb54b9fb7c290e84d5a6607 100644 (file)
@@ -14,7 +14,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.argeo.slc.ant.AntExecutionContext;
 import org.argeo.slc.ant.AntSlcApplication;
-import org.argeo.slc.ant.SlcAntConstants;
+import org.argeo.slc.ant.AntConstants;
 import org.argeo.slc.core.SlcException;
 import org.argeo.slc.core.process.SlcExecution;
 import org.argeo.slc.runtime.SlcExecutionOutput;
@@ -99,21 +99,21 @@ public class DefaultSlcRuntime {
                        slcExecution.setHost(SlcExecution.UNKOWN_HOST);
                }
 
-               slcExecution.setType(SlcAntConstants.EXECTYPE_SLC_ANT);
+               slcExecution.setType(AntConstants.EXECTYPE_SLC_ANT);
 
                slcExecution.setUser(System.getProperty("user.name"));
 
                if (runtimeStr != null)
-                       slcExecution.getAttributes().put(SlcAntConstants.EXECATTR_RUNTIME,
+                       slcExecution.getAttributes().put(AntConstants.EXECATTR_RUNTIME,
                                        runtimeStr);
                String scriptRelativePath = SpringUtils.extractRelativePath(SpringUtils
                                .getParent(slcRootFile), script);
 
-               slcExecution.getAttributes().put(SlcAntConstants.EXECATTR_ANT_FILE,
+               slcExecution.getAttributes().put(AntConstants.EXECATTR_ANT_FILE,
                                scriptRelativePath);
                if (targets != null)
                        slcExecution.getAttributes().put(
-                                       SlcAntConstants.EXECATTR_ANT_TARGETS, targets);
+                                       AntConstants.EXECATTR_ANT_TARGETS, targets);
 
                slcExecution.setStatus(SlcExecution.STATUS_SCHEDULED);
                return slcExecution;
@@ -137,7 +137,7 @@ public class DefaultSlcRuntime {
 
                        // Conf dir
                        String confDirStr = rootProps
-                                       .getProperty(SlcAntConstants.CONF_DIR_PROPERTY);
+                                       .getProperty(AntConstants.CONF_DIR_PROPERTY);
                        if (confDirStr != null)
                                confDir = new DefaultResourceLoader(application.getClass()
                                                .getClassLoader()).getResource(confDirStr);
@@ -150,7 +150,7 @@ public class DefaultSlcRuntime {
 
                        // Work dir
                        String workDirStr = rootProps
-                                       .getProperty(SlcAntConstants.WORK_DIR_PROPERTY);
+                                       .getProperty(AntConstants.WORK_DIR_PROPERTY);
                        if (workDirStr != null) {
                                workDir = new File(workDirStr);
                        }
index b52f38a250b84be2f17b3455a7b09e6ede1d9cdb..ad63b34b5145d1a7e15252e5a9a5ffeee9f869fe 100644 (file)
@@ -18,7 +18,7 @@ public class SlcAntTest extends AbstractSpringTestCase {
                slcApp.setParentContext(getContext());\r
 \r
                SlcExecution slcExecution = new SlcExecution();\r
-               slcExecution.getAttributes().put(SlcAntConstants.EXECATTR_ANT_FILE,\r
+               slcExecution.getAttributes().put(AntConstants.EXECATTR_ANT_FILE,\r
                                "/org/argeo/slc/ant/build.xml");\r
 \r
                slcApp.execute(slcExecution, null, null, null);\r