maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vsive...@apache.org
Subject svn commit: r584160 - in /maven/plugins/trunk/maven-javadoc-plugin/src: main/java/org/apache/maven/plugin/javadoc/ site/fml/ test/java/org/apache/maven/plugin/javadoc/
Date Fri, 12 Oct 2007 13:20:13 GMT
Author: vsiveton
Date: Fri Oct 12 06:20:01 2007
New Revision: 584160

URL: http://svn.apache.org/viewvc?rev=584160&view=rev
Log:
MJAVADOC-155: maxmemory and minmemory support only m unit

o added utility method to parse memory string
o updated javadoc and some log messages
o added a test case
o updated faq

Modified:
    maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java
    maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocUtil.java
    maven/plugins/trunk/maven-javadoc-plugin/src/site/fml/faq.fml
    maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocUtilTest.java

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java?rev=584160&r1=584159&r2=584160&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java
(original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java
Fri Oct 12 06:20:01 2007
@@ -172,19 +172,20 @@
 
     /**
      * Set an additional parameter(s) on the command line. This value should include quotes
as necessary for
-     * parameters that include spaces.
+     * parameters that include spaces. Useful for a custom doclet.
      *
      * @parameter expression="${additionalparam}"
      */
     private String additionalparam;
 
     /**
-     * Set an additional J option(s) on the command line.
+     * Set an additional Javadoc option(s) (i.e. JVM options) on the command line.
      * Example:
      * <pre>
      * &lt;additionalJOption&gt;-J-Xss128m&lt;/additionalJOption&gt;
      * </pre>
      * See <a href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javadoc.html#J">Jflag</a>.
+     * See <a href="http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp">vmoptions</a>.
      *
      * @since 2.3
      * @parameter expression="${additionalJOption}"
@@ -384,16 +385,22 @@
     private String locale;
 
     /**
-     * Specifies the maximum Java heap size to be used when launching the javadoc executable.
-     * Some JVMs refer to this property as the -Xmx parameter. Example: '512' or '512m'.
+     * Specifies the maximum Java heap size to be used when launching the Javadoc tool.
+     * JVMs refer to this property as the <code>-Xmx</code> parameter. Example:
'512' or '512m'.
+     * The memory unit depends on the JVM used. The units supported could be: <code>k</code>,
<code>kb</code>,
+     * <code>m</code>, <code>mb</code>, <code>g</code>,
<code>gb</code>, <code>t</code>, <code>tb</code>.
+     *  If no unit specified, the default unit is <code>m</code>.
      *
      * @parameter expression="${maxmemory}"
      */
     private String maxmemory;
 
     /**
-     * Specifies the minimum Java heap size to be used when launching the javadoc executable.
-     * Some JVMs refer to this property as the -Xms parameter. Example: '128' or '128m'.
+     * Specifies the minimum Java heap size to be used when launching the Javadoc tool.
+     * JVMs refer to this property as the <code>-Xms</code> parameter. Example:
'512' or '512m'.
+     * The memory unit depends on the JVM used. The units supported could be: <code>k</code>,
<code>kb</code>,
+     * <code>m</code>, <code>mb</code>, <code>g</code>,
<code>gb</code>, <code>t</code>, <code>tb</code>.
+     *  If no unit specified, the default unit is <code>m</code>.
      *
      * @parameter expression="${minmemory}"
      */
@@ -1261,7 +1268,7 @@
 
         if ( old && isJavaDocVersionAtLeast( SINCE_JAVADOC_1_4 ) )
         {
-            getLog().warn( "Javadoc 1.4 doesn't support the -1.1 switch anymore. Ignore this
option." );
+            getLog().warn( "Javadoc 1.4+ doesn't support the -1.1 switch anymore. Ignore
this option." );
         }
         else
         {
@@ -1316,7 +1323,7 @@
                     if ( groups[i] == null || StringUtils.isEmpty( groups[i].getTitle() )
                         || StringUtils.isEmpty( groups[i].getPackages() ) )
                     {
-                        getLog().info( "A group option is empty. Ignore this option." );
+                        getLog().warn( "A group option is empty. Ignore this option." );
                     }
                     else
                     {
@@ -1372,7 +1379,7 @@
                 {
                     if ( ( taglets[i] == null ) || ( StringUtils.isEmpty( taglets[i].getTagletClass()
) ) )
                     {
-                        getLog().info( "A taglet option is empty. Ignore this option." );
+                        getLog().warn( "A taglet option is empty. Ignore this option." );
                     }
                     else
                     {
@@ -1389,7 +1396,7 @@
                 {
                     if ( StringUtils.isEmpty( tags[i].getName() ) )
                     {
-                        getLog().info( "A tag name is empty. Ignore this option." );
+                        getLog().warn( "A tag name is empty. Ignore this option." );
                     }
                     else
                     {
@@ -2070,27 +2077,19 @@
      * @param cmd    the command line execution object where the argument will be added
      * @param arg    the argument parameter name
      * @param memory the JVM memory value to be set
+     * @see JavadocUtil#parseJavadocMemory(String)
      */
     private void addMemoryArg( Commandline cmd, String arg, String memory )
     {
         if ( StringUtils.isNotEmpty( memory ) )
         {
-            // Allow '128' or '128m'
-            if ( NumberUtils.isDigits( memory ) )
+            try
             {
-                cmd.createArgument().setValue( "-J" + arg + memory + "m" );
+                cmd.createArgument().setValue( "-J" + arg + JavadocUtil.parseJavadocMemory(
memory ) );
             }
-            else
+            catch ( IllegalArgumentException e )
             {
-                if ( NumberUtils.isDigits( memory.substring( 0, memory.length() - 1 ) )
-                    && memory.toLowerCase().endsWith( "m" ) )
-                {
-                    cmd.createArgument().setValue( "-J" + arg + memory );
-                }
-                else
-                {
-                    getLog().error( arg + " '" + memory + "' is not a valid number. Ignore
this option." );
-                }
+                getLog().error( "Malformed memory pattern for '" + arg + memory + "'. Ignore
this option." );
             }
         }
     }
@@ -2281,7 +2280,7 @@
         }
         else
         {
-            getLog().warn( value + " option is not supported on Java version < " + requiredJavaVersion
);
+            getLog().warn( value + " option is not supported on Java version < " + requiredJavaVersion
+ ". Ignore this option." );
         }
     }
 
@@ -2324,7 +2323,7 @@
         }
         else
         {
-            getLog().warn( key + " option is not supported on Java version < " + requiredJavaVersion
);
+            getLog().warn( key + " option is not supported on Java version < " + requiredJavaVersion
+ ". Ignore this option." );
         }
     }
 
@@ -2513,11 +2512,11 @@
                 }
                 catch ( MalformedURLException e )
                 {
-                    getLog().error( "Malformed link: " + link + "/package-list. IGNORED IT."
);
+                    getLog().error( "Malformed link: " + link + "/package-list. Ignored it."
);
                 }
                 catch ( IOException e )
                 {
-                    getLog().error( "Error fetching link: " + link + "/package-list. IGNORED
IT." );
+                    getLog().error( "Error fetching link: " + link + "/package-list. Ignored
it." );
                 }
             }
         }

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocUtil.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocUtil.java?rev=584160&r1=584159&r2=584160&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocUtil.java
(original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocUtil.java
Fri Oct 12 06:20:01 2007
@@ -479,7 +479,81 @@
         }
 
         return Float.parseFloat( version );
+    }
 
+    /**
+     * Parse a memory string which be used in the JVM arguments <code>-Xms</code>
or <code>-Xmx</code>.
+     * <br/>
+     * Here are some supported memory string depending the JDK used:
+     * <table>
+     * <tr>
+     *   <th>JDK</th>
+     *   <th>Memory argument support for <code>-Xms</code> or <code>-Xmx</code></th>
+     * </tr>
+     * <tr>
+     *   <td>SUN</td>
+     *   <td>1024k | 128m | 1g | 1t</td>
+     * </tr>
+     * <tr>
+     *   <td>IBM</td>
+     *   <td>1024k | 1024b | 128m | 128mb | 1g | 1gb</td>
+     * </tr>
+     * <tr>
+     *   <td>BEA</td>
+     *   <td>1024k | 1024kb | 128m | 128mb | 1g | 1gb</td>
+     * </tr>
+     * </table>
+     *
+     * @param memory the memory to be parsed, not null.
+     * @return the memory parsed with a supported unit. If no unit specified in the <code>memory</code>
parameter,
+     * the default unit is <code>m</code>. The units <code>g | gb</code>
or <code>t | tb</code> will be converted
+     * in <code>m</code>.
+     * @throws IllegalArgumentException if the <code>memory</code> parameter
is null or doesn't match any pattern.
+     */
+    protected static String parseJavadocMemory( String memory )
+        throws IllegalArgumentException
+    {
+        if ( StringUtils.isEmpty( memory ) )
+        {
+            throw new IllegalArgumentException( "The memory could not be null." );
+        }
+
+        Pattern p = Pattern.compile( "^\\s*(\\d+)\\s*?\\s*$" );
+        Matcher m = p.matcher( memory );
+        if ( m.matches() )
+        {
+            return m.group( 1 ) + "m";
+        }
+
+        p = Pattern.compile( "^\\s*(\\d+)\\s*k(b)?\\s*$", Pattern.CASE_INSENSITIVE );
+        m = p.matcher( memory );
+        if ( m.matches() )
+        {
+            return m.group( 1 ) + "k";
+        }
+
+        p = Pattern.compile( "^\\s*(\\d+)\\s*m(b)?\\s*$", Pattern.CASE_INSENSITIVE );
+        m = p.matcher( memory );
+        if ( m.matches() )
+        {
+            return m.group( 1 ) + "m";
+        }
+
+        p = Pattern.compile( "^\\s*(\\d+)\\s*g(b)?\\s*$", Pattern.CASE_INSENSITIVE );
+        m = p.matcher( memory );
+        if ( m.matches() )
+        {
+            return ( Integer.parseInt( m.group( 1 ) ) * 1024 ) + "m";
+        }
+
+        p = Pattern.compile( "^\\s*(\\d+)\\s*t(b)?\\s*$", Pattern.CASE_INSENSITIVE );
+        m = p.matcher( memory );
+        if ( m.matches() )
+        {
+            return ( Integer.parseInt( m.group( 1 ) ) * 1024 * 1024 ) + "m";
+        }
+
+        throw new IllegalArgumentException( "Could convert not to a memory size: " + memory
);
     }
 
     /**

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/site/fml/faq.fml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/site/fml/faq.fml?rev=584160&r1=584159&r2=584160&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/site/fml/faq.fml (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/site/fml/faq.fml Fri Oct 12 06:20:01 2007
@@ -93,6 +93,40 @@
         </p>
       </answer>
     </faq>
+    <faq id="How to increase Javadoc heap size">
+      <question>How to increase Javadoc heap size?</question>
+      <answer>
+        <p>
+          If you need to increase the Javadoc heap size, you should use the <i>&lt;minmemory/&gt;</i>
and
+          <i>&lt;maxmemory/&gt;</i> parameters in your Javadoc Plugin
configuration. For instance:
+          <source>
+<project>
+  ...
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+        <configuration>
+          ...
+          <minmemory>128m</minmemory>
+          <maxmemory>1g</maxmemory>
+          ...
+        </configuration>
+      </plugin>
+    </plugins>
+    ...
+  </reporting>
+  ...
+</project></source>
+        </p>
+        <p>
+          <b>Note:</b> The memory unit depends on the JVM used. The units supported
could be: <code>k</code>,
+          <code>kb</code>, <code>m</code>, <code>mb</code>,
<code>g</code>, <code>gb</code>, <code>t</code>,
+          <code>tb</code>. If no unit specified, the default unit is <code>m</code>.
+        </p>
+      </answer>
+    </faq>
     <faq id="How to add proxy support">
       <question>How to add proxy support?</question>
       <answer>

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocUtilTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocUtilTest.java?rev=584160&r1=584159&r2=584160&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocUtilTest.java
(original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocUtilTest.java
Fri Oct 12 06:20:01 2007
@@ -31,7 +31,7 @@
     extends TestCase
 {
     /**
-     * Method to test the javadoc parsing.
+     * Method to test the javadoc version parsing.
      *
      * @throws Exception if any
      */
@@ -80,6 +80,13 @@
         // Other tests
         version = "java full version \"1.5.0_07-164\"" + System.getProperty( "line.separator"
);
         assertEquals( JavadocUtil.parseJavadocVersion( version ), 1.5f, 0 );
+        version = System.getProperty( "line.separator" ) + "java full version \"1.5.0_07-164\"";
+        assertEquals( JavadocUtil.parseJavadocVersion( version ), 1.5f, 0 );
+        version = System.getProperty( "line.separator" ) + "java full version \"1.5.0_07-164\""
+            + System.getProperty( "line.separator" );
+        assertEquals( JavadocUtil.parseJavadocVersion( version ), 1.5f, 0 );
+        version = "java full" + System.getProperty( "line.separator" ) + " version \"1.5.0_07-164\"";
+        assertEquals( JavadocUtil.parseJavadocVersion( version ), 1.5f, 0 );
 
         version = "java full version \"1.99.123-b01\"";
         assertEquals( JavadocUtil.parseJavadocVersion( version ), 1.99123f, 0 );
@@ -97,6 +104,80 @@
             assertTrue( "Not catch wrong pattern", false );
         }
         catch ( PatternSyntaxException e )
+        {
+            assertTrue( true );
+        }
+    }
+
+    /**
+     * Method to test the javadoc memory parsing.
+     *
+     * @throws Exception if any
+     */
+    public void testParseJavadocMemory()
+        throws Exception
+    {
+        String memory = null;
+        try
+        {
+            JavadocUtil.parseJavadocMemory( memory );
+            assertTrue( "Not catch null", false );
+        }
+        catch ( IllegalArgumentException e )
+        {
+            assertTrue( true );
+        }
+
+        memory = "128";
+        assertEquals( JavadocUtil.parseJavadocMemory( memory ), "128m" );
+
+        memory = "128k";
+        assertEquals( JavadocUtil.parseJavadocMemory( memory ), "128k" );
+        memory = "128kb";
+        assertEquals( JavadocUtil.parseJavadocMemory( memory ), "128k" );
+
+        memory = "128m";
+        assertEquals( JavadocUtil.parseJavadocMemory( memory ), "128m" );
+        memory = "128mb";
+        assertEquals( JavadocUtil.parseJavadocMemory( memory ), "128m" );
+
+        memory = "1g";
+        assertEquals( JavadocUtil.parseJavadocMemory( memory ), "1024m" );
+        memory = "1gb";
+        assertEquals( JavadocUtil.parseJavadocMemory( memory ), "1024m" );
+
+        memory = "1t";
+        assertEquals( JavadocUtil.parseJavadocMemory( memory ), "1048576m" );
+        memory = "1tb";
+        assertEquals( JavadocUtil.parseJavadocMemory( memory ), "1048576m" );
+
+        memory = System.getProperty( "line.separator" ) + "128m";
+        assertEquals( JavadocUtil.parseJavadocMemory( memory ), "128m" );
+        memory = System.getProperty( "line.separator" ) + "128m" + System.getProperty( "line.separator"
);
+        assertEquals( JavadocUtil.parseJavadocMemory( memory ), "128m" );
+
+        memory = "     128m";
+        assertEquals( JavadocUtil.parseJavadocMemory( memory ), "128m" );
+        memory = "     128m     ";
+        assertEquals( JavadocUtil.parseJavadocMemory( memory ), "128m" );
+
+        memory = "1m28m";
+        try
+        {
+            JavadocUtil.parseJavadocMemory( memory );
+            assertTrue( "Not catch wrong pattern", false );
+        }
+        catch ( IllegalArgumentException e )
+        {
+            assertTrue( true );
+        }
+        memory = "ABC128m";
+        try
+        {
+            JavadocUtil.parseJavadocMemory( memory );
+            assertTrue( "Not catch wrong pattern", false );
+        }
+        catch ( IllegalArgumentException e )
         {
             assertTrue( true );
         }



Mime
View raw message