extracted writeHelpPropertiesFile() method
git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1354222 13f79535-47bb-0310-9956-ffa450edef68master
parent
d75dfaa768
commit
297b152d05
|
|
@ -78,7 +78,6 @@ public class PluginHelpGenerator
|
|||
// Public methods
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
@ -112,38 +111,7 @@ public class PluginHelpGenerator
|
|||
}
|
||||
}
|
||||
|
||||
Properties properties = new Properties();
|
||||
properties.put( "helpPackageName", helpPackageName == null ? "" : helpPackageName );
|
||||
|
||||
MavenProject mavenProject = request.getProject();
|
||||
|
||||
File tmpPropertiesFile =
|
||||
new File( request.getProject().getBuild().getDirectory(), "maven-plugin-help.properties" );
|
||||
if ( tmpPropertiesFile.exists() )
|
||||
{
|
||||
tmpPropertiesFile.delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !tmpPropertiesFile.getParentFile().exists() )
|
||||
{
|
||||
tmpPropertiesFile.getParentFile().mkdirs();
|
||||
}
|
||||
}
|
||||
FileOutputStream fos = null;
|
||||
try
|
||||
{
|
||||
fos = new FileOutputStream( tmpPropertiesFile );
|
||||
properties.store( fos, "maven plugin help generation informations" );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new GeneratorException( e.getMessage(), e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close( fos );
|
||||
}
|
||||
writeHelpPropertiesFile( request );
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -152,6 +120,7 @@ public class PluginHelpGenerator
|
|||
File helpClass = new File( destinationDirectory, sourcePath );
|
||||
helpClass.getParentFile().mkdirs();
|
||||
|
||||
MavenProject mavenProject = request.getProject();
|
||||
String pluginResourcesPath = "META-INF/maven/" + mavenProject.getGroupId() + "/" + mavenProject.getArtifactId();
|
||||
|
||||
String helpClassSources = getHelpClassSources( pluginResourcesPath, pluginDescriptor );
|
||||
|
|
@ -185,7 +154,7 @@ public class PluginHelpGenerator
|
|||
// Private methods
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
protected String getHelpClassSources( String pluginResourcesPath, PluginDescriptor pluginDescriptor )
|
||||
private String getHelpClassSources( String pluginResourcesPath, PluginDescriptor pluginDescriptor )
|
||||
{
|
||||
Properties properties = new Properties();
|
||||
VelocityContext context = new VelocityContext( properties );
|
||||
|
|
@ -212,7 +181,6 @@ public class PluginHelpGenerator
|
|||
return stringWriter.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param pluginDescriptor The descriptor of the plugin for which to generate a help goal, must not be
|
||||
* <code>null</code>.
|
||||
|
|
@ -228,4 +196,38 @@ public class PluginHelpGenerator
|
|||
|
||||
return StringUtils.isEmpty( packageName ) ? HELP_MOJO_CLASS_NAME : packageName + '.' + HELP_MOJO_CLASS_NAME;
|
||||
}
|
||||
|
||||
private void writeHelpPropertiesFile( PluginToolsRequest request )
|
||||
throws GeneratorException
|
||||
{
|
||||
Properties properties = new Properties();
|
||||
properties.put( "helpPackageName", helpPackageName == null ? "" : helpPackageName );
|
||||
|
||||
File tmpPropertiesFile =
|
||||
new File( request.getProject().getBuild().getDirectory(), "maven-plugin-help.properties" );
|
||||
|
||||
if ( tmpPropertiesFile.exists() )
|
||||
{
|
||||
tmpPropertiesFile.delete();
|
||||
}
|
||||
else if ( !tmpPropertiesFile.getParentFile().exists() )
|
||||
{
|
||||
tmpPropertiesFile.getParentFile().mkdirs();
|
||||
}
|
||||
|
||||
FileOutputStream fos = null;
|
||||
try
|
||||
{
|
||||
fos = new FileOutputStream( tmpPropertiesFile );
|
||||
properties.store( fos, "maven plugin help mojo generation informations" );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new GeneratorException( e.getMessage(), e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close( fos );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue