--- /dev/null
+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";
+
+}
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() {
// 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);
}
}
- 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
// Find runtime definition
Resource runtimeRes = null;
String runtimeStr = slcExecution.getAttributes().get(
- SlcAntConstants.EXECATTR_RUNTIME);
+ AntConstants.EXECATTR_RUNTIME);
if (runtimeStr == null)
runtimeStr = "default";
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");
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, ",");
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);
}
// 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()) {
/** 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 {
}
}
Properties typedefs = getDefs(project,
- SlcAntConstants.SLC_TYPEDEFS_RESOURCE_PATH);
+ AntConstants.SLC_TYPEDEFS_RESOURCE_PATH);
for (Object o : typedefs.keySet()) {
String name = o.toString();
try {
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, "/");
.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);
+++ /dev/null
-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";
-
-}
\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
\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
\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
/** 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
\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
/** 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
\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
/** 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
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
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
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;
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;
// 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);
// Work dir
String workDirStr = rootProps
- .getProperty(SlcAntConstants.WORK_DIR_PROPERTY);
+ .getProperty(AntConstants.WORK_DIR_PROPERTY);
if (workDirStr != null) {
workDir = new File(workDirStr);
}
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