}
public void writeDescriptor( File destinationFile, PluginToolsRequest request, boolean helpDescriptor )
throws IOException, DuplicateMojoDescriptorException
{
PluginDescriptor pluginDescriptor = request.getPluginDescriptor();
if ( destinationFile.exists() )
{
destinationFile.delete();
}
else
{
if ( !destinationFile.getParentFile().exists() )
{
destinationFile.getParentFile().mkdirs();
}
}
String encoding = "UTF-8";
Writer writer = null;
try
{
writer = new OutputStreamWriter( new FileOutputStream( destinationFile ), encoding );
XMLWriter w = new PrettyPrintXMLWriter( writer, encoding, null );
w.writeMarkup( "\n<!-- Generated by maven-plugin-tools " + getVersion() + " on " + new SimpleDateFormat(
"yyyy-MM-dd" ).format( new Date() ) + " -->\n\n" );
w.startElement( "plugin" );
GeneratorUtils.element( w, "name", pluginDescriptor.getName() );
GeneratorUtils.element( w, "description", pluginDescriptor.getDescription(), helpDescriptor );
GeneratorUtils.element( w, "groupId", pluginDescriptor.getGroupId() );
GeneratorUtils.element( w, "artifactId", pluginDescriptor.getArtifactId() );
GeneratorUtils.element( w, "version", pluginDescriptor.getVersion() );
GeneratorUtils.element( w, "goalPrefix", pluginDescriptor.getGoalPrefix() );
if ( !helpDescriptor )
{
GeneratorUtils.element( w, "isolatedRealm", String.valueOf( pluginDescriptor.isIsolatedRealm() ) );
GeneratorUtils.element( w, "inheritedByDefault",
String.valueOf( pluginDescriptor.isInheritedByDefault() ) );
}
w.startElement( "mojos" );
if ( pluginDescriptor.getMojos() != null )
{
@SuppressWarnings( "unchecked" ) List<MojoDescriptor> descriptors = pluginDescriptor.getMojos();
PluginUtils.sortMojos( descriptors );
for ( MojoDescriptor descriptor : descriptors )
{