More code analysis fixes

git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1517623 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java b/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java
index c85e0e0..6b69ad3 100644
--- a/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java
+++ b/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java
@@ -464,7 +464,8 @@
 
         if ( !project.getCompileSourceRoots().isEmpty() )
         {
-            String[] compileSourceRoots = (String[]) project.getCompileSourceRoots().toArray( new String[0] );
+            List var = project.getCompileSourceRoots();
+            String[] compileSourceRoots = (String[]) var.toArray(new String[var.size()]);
             for ( int i = 0; i < compileSourceRoots.length; i++ )
             {
                 writer.startElement( "property" );
@@ -476,7 +477,8 @@
 
         if ( project.getBuild().getResources() != null )
         {
-            Resource[] array = project.getBuild().getResources().toArray( new Resource[0] );
+            List<Resource> var = project.getBuild().getResources();
+            Resource[] array = var.toArray(new Resource[var.size()]);
             for ( int i = 0; i < array.length; i++ )
             {
                 writer.startElement( "property" );
@@ -495,7 +497,8 @@
 
         if ( !project.getTestCompileSourceRoots().isEmpty() )
         {
-            String[] compileSourceRoots = (String[]) project.getTestCompileSourceRoots().toArray( new String[0] );
+            List var = project.getTestCompileSourceRoots();
+            String[] compileSourceRoots = (String[]) var.toArray(new String[var.size()]);
             for ( int i = 0; i < compileSourceRoots.length; i++ )
             {
                 writer.startElement( "property" );
@@ -507,7 +510,8 @@
 
         if ( project.getBuild().getTestResources() != null )
         {
-            Resource[] array = project.getBuild().getTestResources().toArray( new Resource[0] );
+            List<Resource> var = project.getBuild().getTestResources();
+            Resource[] array = var.toArray(new Resource[var.size()]);
             for ( int i = 0; i < array.length; i++ )
             {
                 writer.startElement( "property" );
@@ -1157,7 +1161,7 @@
             AntBuildWriterUtil.addWrapAttribute( writer, "javac", "source", AntBuildWriterUtil
                 .getMavenCompilerPluginBasicOption( project, "source", "1.3" ), 3 );
 
-            String[] compileSourceRootsArray = (String[]) compileSourceRoots.toArray( new String[0] );
+            String[] compileSourceRootsArray = (String[]) compileSourceRoots.toArray(new String[compileSourceRoots.size()]);
             for ( int i = 0; i < compileSourceRootsArray.length; i++ )
             {
                 writer.startElement( "src" );
@@ -1209,7 +1213,7 @@
             writer.endElement(); // javac
         }
 
-        Resource[] array = (Resource[]) resources.toArray( new Resource[0] );
+        Resource[] array = (Resource[]) resources.toArray(new Resource[resources.size()]);
         for ( int i = 0; i < array.length; i++ )
         {
             Resource resource = array[i];
diff --git a/src/main/java/org/apache/maven/plugin/ant/AntBuildWriterUtil.java b/src/main/java/org/apache/maven/plugin/ant/AntBuildWriterUtil.java
index 2e51d05..15aafc5 100644
--- a/src/main/java/org/apache/maven/plugin/ant/AntBuildWriterUtil.java
+++ b/src/main/java/org/apache/maven/plugin/ant/AntBuildWriterUtil.java
@@ -187,7 +187,7 @@
         if ( sourcepath == null )
         {
             StringBuilder sb = new StringBuilder();
-            String[] compileSourceRoots = (String[]) sources.toArray( new String[0] );
+            String[] compileSourceRoots = (String[]) sources.toArray(new String[sources.size()]);
             for ( int i = 0; i < compileSourceRoots.length; i++ )
             {
                 sb.append( "${maven.build.srcDir." ).append( i ).append( "}" );
@@ -1051,7 +1051,7 @@
                             }
                         }
 
-                        options.put(optionName, optionNames.toArray(new Map[0]));
+                        options.put(optionName, optionNames.toArray(new Map[optionNames.size()]));
 
                         return options;
                     }