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