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