1 package org.apache.torque.mojo;
2
3 import org.apache.maven.plugin.MojoExecutionException;
4 import org.apache.tools.ant.Project;
5 import org.apache.tools.ant.Task;
6 import org.apache.torque.util.MojoAntBuildListener;
7 import org.kuali.core.db.torque.FilteredPropertyCopier;
8
9
10
11
12 public class AntTaskMojo extends BaseMojo {
13
14
15
16
17 private Task antTask;
18
19
20
21
22 private Project antProject;
23
24
25
26
27 protected void configureTask() throws MojoExecutionException {
28 if (getAntTask() == null) {
29 throw new IllegalArgumentException("Ant task is null");
30 }
31
32
33 setAntProject(getIniatializedAntProject());
34 getAntTask().setProject(getAntProject());
35 try {
36
37 FilteredPropertyCopier copier = new FilteredPropertyCopier();
38
39
40 copier.addExclude("project");
41 copier.copyProperties(getAntTask(), this);
42 } catch (Exception e) {
43 throw new MojoExecutionException("Error copying properties", e);
44 }
45 }
46
47
48
49
50 public void executeMojo() throws MojoExecutionException {
51 configureTask();
52 getAntTask().execute();
53 }
54
55
56
57
58 protected Project getIniatializedAntProject() {
59 getLog().info("Initializing the Ant Project");
60
61 Project antProject = new Project();
62
63 antProject.init();
64
65 antProject.addBuildListener(new MojoAntBuildListener(getLog()));
66
67 return antProject;
68 }
69
70 public Project getAntProject() {
71 return antProject;
72 }
73
74 public void setAntProject(Project antProject) {
75 this.antProject = antProject;
76 }
77
78 public Task getAntTask() {
79 return antTask;
80 }
81
82 public void setAntTask(Task antTask) {
83 this.antTask = antTask;
84 }
85 }