]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.ws.client/src/main/java/org/argeo/slc/ant/deploy/SlcDeployTask.java
Introduce org.argeo.slc.support.ws.client
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.ws.client / src / main / java / org / argeo / slc / ant / deploy / SlcDeployTask.java
1 package org.argeo.slc.ant.deploy;
2
3 import org.apache.commons.logging.Log;
4 import org.apache.commons.logging.LogFactory;
5 import org.apache.tools.ant.BuildException;
6 import org.argeo.slc.ant.spring.SpringArg;
7 import org.argeo.slc.ant.structure.SAwareTask;
8 import org.argeo.slc.core.build.Distribution;
9 import org.argeo.slc.core.deploy.Deployment;
10 import org.argeo.slc.core.deploy.DeploymentData;
11 import org.argeo.slc.core.deploy.TargetData;
12
13 /** Ant task wrapping a deployment. */
14 public class SlcDeployTask extends SAwareTask {
15 private Log log = LogFactory.getLog(SlcDeployTask.class);
16
17 private String deploymentBean = null;
18
19 private SpringArg<DeploymentData> deploymentDataArg;
20 private SpringArg<TargetData> targetDataArg;
21 private SpringArg<Distribution> distributionArg;
22
23 @Override
24 public void executeActions(String mode) throws BuildException {
25 Deployment deployment = (Deployment) getContext().getBean(
26 deploymentBean);
27
28 // set overridden references
29 if (distributionArg != null) {
30 deployment.setDistribution(distributionArg.getInstance());
31 log.trace("Overrides distribution");
32 }
33
34 if (deploymentDataArg != null) {
35 deployment.setDeploymentData(deploymentDataArg.getInstance());
36 log.trace("Overrides deployment data");
37 }
38
39 if (targetDataArg != null) {
40 deployment.setTargetData(targetDataArg.getInstance());
41 log.trace("Overrides target data");
42 }
43
44 deployment.execute();
45 }
46
47 /**
48 * The bean name of the test run to use. If not set the default is used.
49 *
50 * @see SlcAntConfig
51 */
52 public void setDeployment(String deploymentBean) {
53 this.deploymentBean = deploymentBean;
54 }
55
56 /** Creates deployment data sub tag. */
57 public SpringArg<DeploymentData> createDeploymentData() {
58 deploymentDataArg = new SpringArg<DeploymentData>();
59 return deploymentDataArg;
60 }
61
62 /** Creates target data sub tag. */
63 public SpringArg<TargetData> createTargetData() {
64 targetDataArg = new SpringArg<TargetData>();
65 return targetDataArg;
66 }
67
68 public SpringArg<Distribution> createDistribution() {
69 distributionArg = new SpringArg<Distribution>();
70 return distributionArg;
71 }
72 }