targetDirectory = targetDirectory.replace('/', File.separatorChar);
// FIXME: [rfeng] Workaround to figure out the current execution phase
MojoDescriptor descriptor = (MojoDescriptor) mojos.get(0);
PluginDescriptor pluginDescriptor = descriptor.getPluginDescriptor();
Map pluginMap = project.getBuild().getPluginsAsMap();
Plugin plugin = (Plugin) pluginMap.get(pluginDescriptor.getGroupId() + ":" + pluginDescriptor.getArtifactId());
// How to get the current execution id?
for (Iterator i = plugin.getExecutions().iterator(); i.hasNext();) {
PluginExecution execution = (PluginExecution) i.next();
String phase = execution.getPhase();
if (phase != null && phase.indexOf("-test-") != -1) {