From 3c5911b8a9ed2e6e6ffbacf618d8ed5feafaba84 Mon Sep 17 00:00:00 2001 From: Dennis Lundberg Date: Sun, 1 May 2011 16:07:11 +0000 Subject: [PATCH] [MPLUGIN-183] When setting useJava5 to true the generated code has warnings for Java 5 features git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1098364 13f79535-47bb-0310-9956-ffa450edef68 --- .../plugin/generator/PluginHelpGenerator.java | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java b/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java index aae4cec..3923c0e 100644 --- a/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java +++ b/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java @@ -330,7 +330,7 @@ public class PluginHelpGenerator writeExecute( writer, pluginDescriptor, helpDescriptor ); writer.write( LS ); - writeUtilities( writer ); + writeUtilities( writer, useJava5 ); writer.write( "}" + LS ); } @@ -626,9 +626,10 @@ public class PluginHelpGenerator /** * @param writer not null + * @param useJava5 If the generated code should use Java5 features * @throws IOException if any */ - private static void writeUtilities( Writer writer ) + private static void writeUtilities( Writer writer, boolean useJava5 ) throws IOException { writer.write( " /**" + LS ); @@ -685,7 +686,14 @@ public class PluginHelpGenerator writer.write( " private static List toLines( String text, int indent, int indentSize, int lineLength )" + LS ); writer.write( " {" + LS ); - writer.write( " List lines = new ArrayList();" + LS ); + if ( useJava5 ) + { + writer.write( " List lines = new ArrayList();" + LS ); + } + else + { + writer.write( " List lines = new ArrayList();" + LS ); + } writer.write( LS ); writer.write( " String ind = repeat( \"\\t\", indent );" + LS ); writer.write( " String[] plainLines = text.split( \"(\\r\\n)|(\\r)|(\\n)\" );" + LS ); @@ -707,8 +715,16 @@ public class PluginHelpGenerator writer.write( " * @param indentSize The size of each indentation, must not be negative." + LS ); writer.write( " * @param lineLength The length of the line, must not be negative." + LS ); writer.write( " */" + LS ); - writer.write( " private static void toLines( List lines, String line, int indentSize, int lineLength )" - + LS ); + if ( useJava5 ) + { + writer.write( " private static void toLines( List lines, String line, int indentSize, int lineLength )" + + LS ); + } + else + { + writer.write( " private static void toLines( List lines, String line, int indentSize, int lineLength )" + + LS ); + } writer.write( " {" + LS ); writer.write( " int lineIndent = getIndentLevel( line );" + LS ); writer.write( " StringBuffer buf = new StringBuffer( 256 );" + LS );