avoid code duplication for plugin-help.xml path between PluginDescriptorGenerator and PluginHelpGenerator
git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1389657 13f79535-47bb-0310-9956-ffa450edef68master
parent
55e9f2dcfb
commit
b93ab8fca8
|
|
@ -48,7 +48,7 @@ import java.util.Set;
|
|||
|
||||
/**
|
||||
* Generate a <a href="/ref/current/maven-plugin-api/plugin.html">Maven Plugin Descriptor XML file</a> and
|
||||
* corresponding help content.
|
||||
* corresponding <code>plugin-help.xml</code> help content for {@link PluginHelpGenerator}.
|
||||
*
|
||||
* @version $Id$
|
||||
* @todo add example usage tag that can be shown in the doco
|
||||
|
|
@ -76,10 +76,11 @@ public class PluginDescriptorGenerator
|
|||
|
||||
// write plugin-help.xml help-descriptor
|
||||
MavenProject mavenProject = request.getProject();
|
||||
String pluginHelpFilePath =
|
||||
"META-INF/maven/" + mavenProject.getGroupId() + "/" + mavenProject.getArtifactId() + "/plugin-help.xml";
|
||||
|
||||
f = new File( request.getProject().getBuild().getOutputDirectory(), pluginHelpFilePath );
|
||||
f =
|
||||
new File( mavenProject.getBuild().getOutputDirectory(),
|
||||
PluginHelpGenerator.getPluginHelpPath( mavenProject ) );
|
||||
|
||||
writeDescriptor( f, request, true );
|
||||
}
|
||||
catch ( IOException e )
|
||||
|
|
|
|||
|
|
@ -138,10 +138,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 );
|
||||
String helpClassSources = getHelpClassSources( getPluginHelpPath( request.getProject() ), pluginDescriptor );
|
||||
|
||||
FileUtils.fileWrite( helpClass, request.getEncoding(), helpClassSources );
|
||||
}
|
||||
|
|
@ -172,7 +169,7 @@ public class PluginHelpGenerator
|
|||
// Private methods
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
private String getHelpClassSources( String pluginResourcesPath, PluginDescriptor pluginDescriptor )
|
||||
private String getHelpClassSources( String pluginHelpPath, PluginDescriptor pluginDescriptor )
|
||||
{
|
||||
Properties properties = new Properties();
|
||||
VelocityContext context = new VelocityContext( properties );
|
||||
|
|
@ -184,7 +181,7 @@ public class PluginHelpGenerator
|
|||
{
|
||||
properties.put( "helpPackageName", "" );
|
||||
}
|
||||
properties.put( "pluginHelpPath", pluginResourcesPath + "/plugin-help.xml" );
|
||||
properties.put( "pluginHelpPath", pluginHelpPath );
|
||||
properties.put( "artifactId", pluginDescriptor.getArtifactId() );
|
||||
properties.put( "goalPrefix", pluginDescriptor.getGoalPrefix() );
|
||||
|
||||
|
|
@ -256,6 +253,11 @@ public class PluginHelpGenerator
|
|||
}
|
||||
}
|
||||
|
||||
static String getPluginHelpPath( MavenProject mavenProject )
|
||||
{
|
||||
return "META-INF/maven/" + mavenProject.getGroupId() + "/" + mavenProject.getArtifactId() + "/plugin-help.xml";
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewrite Help Mojo to match actual Mojos package name if it was not available at source generation
|
||||
* time. This is used at descriptor generation time.
|
||||
|
|
|
|||
Loading…
Reference in New Issue