You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2012/06/26 22:52:34 UTC

svn commit: r1354222 - /maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java

Author: hboutemy
Date: Tue Jun 26 20:52:33 2012
New Revision: 1354222

URL: http://svn.apache.org/viewvc?rev=1354222&view=rev
Log:
extracted writeHelpPropertiesFile() method

Modified:
    maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java

Modified: maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java?rev=1354222&r1=1354221&r2=1354222&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java Tue Jun 26 20:52:33 2012
@@ -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 );
+        }
+    }
 }