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 | 0 | 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 | 0 | if (getAntTask() == null) { |
29 | 0 | throw new IllegalArgumentException("Ant task is null"); |
30 | |
} |
31 | |
|
32 | |
|
33 | 0 | setAntProject(getIniatializedAntProject()); |
34 | 0 | getAntTask().setProject(getAntProject()); |
35 | |
try { |
36 | |
|
37 | 0 | FilteredPropertyCopier copier = new FilteredPropertyCopier(); |
38 | |
|
39 | |
|
40 | 0 | copier.addExclude("project"); |
41 | 0 | copier.addExclude("driverProperties"); |
42 | 0 | copier.copyProperties(getAntTask(), this); |
43 | 0 | } catch (Exception e) { |
44 | 0 | throw new MojoExecutionException("Error copying properties", e); |
45 | 0 | } |
46 | 0 | } |
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
@Override |
52 | |
public void executeMojo() throws MojoExecutionException { |
53 | 0 | configureTask(); |
54 | 0 | getAntTask().execute(); |
55 | 0 | } |
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
protected Project getIniatializedAntProject() { |
61 | 0 | getLog().info("Initializing the Ant Project"); |
62 | |
|
63 | 0 | Project antProject = new Project(); |
64 | |
|
65 | 0 | antProject.init(); |
66 | |
|
67 | 0 | antProject.addBuildListener(new MojoAntBuildListener(getLog())); |
68 | |
|
69 | 0 | return antProject; |
70 | |
} |
71 | |
|
72 | |
public Project getAntProject() { |
73 | 0 | return antProject; |
74 | |
} |
75 | |
|
76 | |
public void setAntProject(Project antProject) { |
77 | 0 | this.antProject = antProject; |
78 | 0 | } |
79 | |
|
80 | |
public Task getAntTask() { |
81 | 0 | return antTask; |
82 | |
} |
83 | |
|
84 | |
public void setAntTask(Task antTask) { |
85 | 0 | this.antTask = antTask; |
86 | 0 | } |
87 | |
} |