Clover Coverage Report - Maven Impex Plugin 1.0.26-SNAPSHOT
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
21   87   9   3
2   49   0.43   7
7     1.29  
1    
 
  AntTaskMojo       Line # 12 21 0% 9 30 0% 0.0
 
No Tests
 
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    * A base class for mojos that wrap an Ant Task
11    */
 
12    public class AntTaskMojo extends BaseMojo {
13   
14    /**
15    * The ant task to be executed by this mojo.
16    */
17    private Task antTask;
18   
19    /**
20    * The ant project for the ant task.
21    */
22    private Project antProject;
23   
24    /**
25    * Configures the Ant task which is wrapped by this mojo.
26    */
 
27  0 toggle protected void configureTask() throws MojoExecutionException {
28  0 if (getAntTask() == null) {
29  0 throw new IllegalArgumentException("Ant task is null");
30    }
31   
32    // Attach our task to a project
33  0 setAntProject(getIniatializedAntProject());
34  0 getAntTask().setProject(getAntProject());
35  0 try {
36    // Copy configuration from the mojo to the task
37  0 FilteredPropertyCopier copier = new FilteredPropertyCopier();
38    // There is a setProject() method on an Ant Task that expects an Ant Project. This conflicts with
39    // getProject() from the mojo which returns a Maven Project
40  0 copier.addExclude("project");
41  0 copier.addExclude("driverProperties");
42  0 copier.copyProperties(getAntTask(), this);
43    } catch (Exception e) {
44  0 throw new MojoExecutionException("Error copying properties", e);
45    }
46    }
47   
48    /**
49    * Configure the Ant task and then execute it
50    */
 
51  0 toggle @Override
52    public void executeMojo() throws MojoExecutionException {
53  0 configureTask();
54  0 getAntTask().execute();
55    }
56   
57    /**
58    * Return an Ant project that informs Maven about logging events
59    */
 
60  0 toggle protected Project getIniatializedAntProject() {
61  0 getLog().info("Initializing the Ant Project");
62    // Create a new Ant Project
63  0 Project antProject = new Project();
64    // initialize it
65  0 antProject.init();
66    // Add a listener that gets notified about log messages
67  0 antProject.addBuildListener(new MojoAntBuildListener(getLog()));
68    // Return the initialized ant project
69  0 return antProject;
70    }
71   
 
72  0 toggle public Project getAntProject() {
73  0 return antProject;
74    }
75   
 
76  0 toggle public void setAntProject(Project antProject) {
77  0 this.antProject = antProject;
78    }
79   
 
80  0 toggle public Task getAntTask() {
81  0 return antTask;
82    }
83   
 
84  0 toggle public void setAntTask(Task antTask) {
85  0 this.antTask = antTask;
86    }
87    }