modernize code a bit

Signed-off-by: olivier lamy <olamy@apache.org>
diff --git a/core-it-support/core-it-component/src/main/java/org/apache/maven/coreit/component/DefaultStatefulSingleton.java b/core-it-support/core-it-component/src/main/java/org/apache/maven/coreit/component/DefaultStatefulSingleton.java
index 9284011..7d74ecc 100644
--- a/core-it-support/core-it-component/src/main/java/org/apache/maven/coreit/component/DefaultStatefulSingleton.java
+++ b/core-it-support/core-it-component/src/main/java/org/apache/maven/coreit/component/DefaultStatefulSingleton.java
@@ -20,8 +20,9 @@
  */
 
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.Files;
 import java.util.Properties;
 
 /**
@@ -48,7 +49,7 @@
     {
         propertiesFile.getParentFile().mkdirs();
 
-        try ( FileOutputStream os = new FileOutputStream( propertiesFile ) )
+        try ( OutputStream os = Files.newOutputStream( propertiesFile.toPath() ) )
         {
             properties.store( os, "MAVEN-CORE-IT" );
         }
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/CheckMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/CheckMojo.java
index 77332db..5c5c135 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/CheckMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/CheckMojo.java
@@ -24,9 +24,9 @@
 import org.apache.maven.plugin.MojoFailureException;
 
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.nio.file.Files;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -132,31 +132,15 @@
 
         getLog().info( "[MAVEN-CORE-IT-LOG] Creating output file " + outputFile );
 
-        OutputStream out = null;
-        try
+        try ( OutputStream out = Files.newOutputStream( outputFile.toPath() ) )
         {
             outputFile.getParentFile().mkdirs();
-            out = new FileOutputStream( outputFile );
             componentProperties.store( out, "MAVEN-CORE-IT-LOG" );
         }
         catch ( IOException e )
         {
             throw new MojoExecutionException( "Output file could not be created: " + outputFile, e );
         }
-        finally
-        {
-            if ( out != null )
-            {
-                try
-                {
-                    out.close();
-                }
-                catch ( IOException e )
-                {
-                    // just ignore
-                }
-            }
-        }
 
         getLog().info( "[MAVEN-CORE-IT-LOG] Created output file " + outputFile );
     }
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/CheckThreadSafetyMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/CheckThreadSafetyMojo.java
index 3ce6076..ac86b4f 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/CheckThreadSafetyMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/CheckThreadSafetyMojo.java
@@ -23,9 +23,9 @@
 import org.apache.maven.plugin.MojoExecutionException;
 
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.nio.file.Files;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -155,32 +155,15 @@
 
         getLog().info( "[MAVEN-CORE-IT-LOG] Creating output file " + outputFile );
 
-        OutputStream out = null;
-        try
+        outputFile.getParentFile().mkdirs();
+        try ( OutputStream out = Files.newOutputStream( outputFile.toPath() ) )
         {
-            outputFile.getParentFile().mkdirs();
-            out = new FileOutputStream( outputFile );
             componentProperties.store( out, "MAVEN-CORE-IT-LOG" );
         }
         catch ( IOException e )
         {
             throw new MojoExecutionException( "Output file could not be created: " + outputFile, e );
         }
-        finally
-        {
-            if ( out != null )
-            {
-                try
-                {
-                    out.close();
-                }
-                catch ( IOException e )
-                {
-                    // just ignore
-                }
-            }
-        }
-
         getLog().info( "[MAVEN-CORE-IT-LOG] Created output file " + outputFile );
     }
 
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/DumpRepoLayoutsMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/DumpRepoLayoutsMojo.java
index 6750a82..338384e 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/DumpRepoLayoutsMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/DumpRepoLayoutsMojo.java
@@ -24,9 +24,9 @@
 import org.apache.maven.plugin.MojoFailureException;
 
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.nio.file.Files;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -112,32 +112,16 @@
 
         getLog().info( "[MAVEN-CORE-IT-LOG] Creating output file " + layoutsFile );
 
-        OutputStream out = null;
-        try
+        layoutsFile.getParentFile().mkdirs();
+
+        try ( OutputStream out = Files.newOutputStream( layoutsFile.toPath() ) )
         {
-            layoutsFile.getParentFile().mkdirs();
-            out = new FileOutputStream( layoutsFile );
             layoutProperties.store( out, "MAVEN-CORE-IT-LOG" );
         }
         catch ( IOException e )
         {
             throw new MojoExecutionException( "Output file could not be created: " + layoutsFile, e );
         }
-        finally
-        {
-            if ( out != null )
-            {
-                try
-                {
-                    out.close();
-                }
-                catch ( IOException e )
-                {
-                    // just ignore
-                }
-            }
-        }
-
         getLog().info( "[MAVEN-CORE-IT-LOG] Created output file " + layoutsFile );
     }
 
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/CollectMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/CollectMojo.java
index 54d3315..3c628e8 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/CollectMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/CollectMojo.java
@@ -123,7 +123,7 @@
             }
 
             collector.collect( artifacts, origin, localRepository, remoteRepositories, metadataSource, null,
-                               Collections.EMPTY_LIST );
+                               Collections.emptyList() );
         }
         catch ( Exception e )
         {
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallArtifactsMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallArtifactsMojo.java
index 1f07910..8907d90 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallArtifactsMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallArtifactsMojo.java
@@ -48,7 +48,7 @@
      * @readonly
      * @parameter default-value="${project.runtimeArtifacts}"
      */
-    private List artifacts;
+    private List<Artifact> artifacts;
 
     /**
      * @component
@@ -86,10 +86,8 @@
         ArtifactRepository artifactRepository =
             artifactRepositoryFactory.createDeploymentArtifactRepository( "appassembler", "file://"
                 + assembleDirectory.getAbsolutePath() + "/" + repositoryName, artifactRepositoryLayout, false );
-        for ( Object artifact1 : artifacts )
+        for ( Artifact artifact : artifacts )
         {
-            Artifact artifact = (Artifact) artifact1;
-
             installArtifact( artifactRepository, artifact );
         }
     }
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveMojo.java
index 09fa965..0c82538 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveMojo.java
@@ -28,8 +28,9 @@
 import org.apache.maven.plugin.MojoExecutionException;
 
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.Files;
 import java.util.List;
 import java.util.Properties;
 
@@ -139,7 +140,7 @@
             {
                 propertiesFile.getParentFile().mkdirs();
 
-                try ( FileOutputStream fos = new FileOutputStream( propertiesFile ) )
+                try ( OutputStream fos = Files.newOutputStream( propertiesFile.toPath() ) )
                 {
                     props.store( fos, "MAVEN-CORE-IT" );
                 }
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/AbstractLoadMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/AbstractLoadMojo.java
index 7d0d5c6..b1dcc77 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/AbstractLoadMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/AbstractLoadMojo.java
@@ -174,11 +174,11 @@
                 // test ClassLoader.getResources()
                 try
                 {
-                    List urls = Collections.list( classLoader.getResources( path ) );
+                    List<URL> urls = Collections.list( classLoader.getResources( path ) );
                     if ( !urls.equals( Collections.list( childClassLoader.getResources( path ) ) ) )
                     {
                         getLog().error( "[MAVEN-CORE-IT-LOG] Detected class loader defect while getting " + path );
-                        urls = Collections.EMPTY_LIST;
+                        urls = Collections.emptyList();
                     }
                     loaderProperties.setProperty( path + ".count", "" + urls.size() );
                     for ( int j = 0; j < urls.size(); j++ )
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/PropertiesUtil.java b/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/PropertiesUtil.java
index 332dcc7..c7d1ba4 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/PropertiesUtil.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/PropertiesUtil.java
@@ -20,9 +20,9 @@
  */
 
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.nio.file.Files;
 import java.util.Properties;
 
 import org.apache.maven.plugin.MojoExecutionException;
@@ -39,31 +39,15 @@
     public static void write( File outputFile, Properties props )
         throws MojoExecutionException
     {
-        OutputStream out = null;
-        try
+        outputFile.getParentFile().mkdirs();
+        try ( OutputStream out = Files.newOutputStream( outputFile.toPath() ) )
         {
-            outputFile.getParentFile().mkdirs();
-            out = new FileOutputStream( outputFile );
             props.store( out, "MAVEN-CORE-IT-LOG" );
         }
         catch ( IOException e )
         {
             throw new MojoExecutionException( "Output file could not be created: " + outputFile, e );
         }
-        finally
-        {
-            if ( out != null )
-            {
-                try
-                {
-                    out.close();
-                }
-                catch ( IOException e )
-                {
-                    // just ignore
-                }
-            }
-        }
     }
 
 }
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-configuration/src/main/java/org/apache/maven/plugin/coreit/PropertiesUtil.java b/core-it-support/core-it-plugins/maven-it-plugin-configuration/src/main/java/org/apache/maven/plugin/coreit/PropertiesUtil.java
index caf27d8..3450769 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-configuration/src/main/java/org/apache/maven/plugin/coreit/PropertiesUtil.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-configuration/src/main/java/org/apache/maven/plugin/coreit/PropertiesUtil.java
@@ -23,12 +23,11 @@
 import org.codehaus.plexus.configuration.PlexusConfiguration;
 
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.lang.reflect.Array;
+import java.nio.file.Files;
 import java.text.SimpleDateFormat;
 import java.util.Collection;
 import java.util.Date;
@@ -52,10 +51,8 @@
 
         if ( inputFile.exists() )
         {
-            InputStream is = null;
-            try
+            try ( InputStream is = Files.newInputStream( inputFile.toPath() ) )
             {
-                is = new FileInputStream( inputFile );
                 props.load( is );
             }
             catch ( IOException e )
@@ -63,20 +60,6 @@
                 throw new MojoExecutionException( "Input file " + inputFile + " could not be read: " + e.getMessage(),
                                                   e );
             }
-            finally
-            {
-                if ( is != null )
-                {
-                    try
-                    {
-                        is.close();
-                    }
-                    catch ( IOException e )
-                    {
-                        // just ignore
-                    }
-                }
-            }
         }
 
         return props;
@@ -85,11 +68,9 @@
     public static void write( File outputFile, Properties props )
         throws MojoExecutionException
     {
-        OutputStream os = null;
-        try
+        outputFile.getParentFile().mkdirs();
+        try ( OutputStream os = Files.newOutputStream( outputFile.toPath() ) )
         {
-            outputFile.getParentFile().mkdirs();
-            os = new FileOutputStream( outputFile );
             props.store( os, "MAVEN-CORE-IT-LOG" );
         }
         catch ( IOException e )
@@ -97,20 +78,6 @@
             throw new MojoExecutionException( "Output file " + outputFile + " could not be created: " + e.getMessage(),
                                               e );
         }
-        finally
-        {
-            if ( os != null )
-            {
-                try
-                {
-                    os.close();
-                }
-                catch ( IOException e )
-                {
-                    // just ignore
-                }
-            }
-        }
     }
 
     public static void serialize( Properties props, String key, Object value )
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-context-passing/src/main/java/org/apache/maven/plugin/coreit/CatchMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-context-passing/src/main/java/org/apache/maven/plugin/coreit/CatchMojo.java
index cd891ad..af6dcd8 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-context-passing/src/main/java/org/apache/maven/plugin/coreit/CatchMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-context-passing/src/main/java/org/apache/maven/plugin/coreit/CatchMojo.java
@@ -23,9 +23,10 @@
 import org.apache.maven.plugin.MojoExecutionException;
 
 import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.Writer;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
 
 /**
  * "Catch" a parameter "thrown" by the ThrowMojo through the plugin context, and
@@ -66,33 +67,14 @@
         
         File outfile = new File( outDir, value );
 
-        Writer writer = null;
-        try
+        try ( Writer writer = Files.newBufferedWriter( outfile.toPath(), Charset.defaultCharset() ) )
         {
-            writer = new FileWriter( outfile );
-            
             writer.write( value );
-            
-            writer.flush();
         }
         catch ( IOException e )
         {
             throw new MojoExecutionException( "Cannot write output file: " + outfile, e );
         }
-        finally
-        {
-            if ( writer != null )
-            {
-                try
-                {
-                    writer.close();
-                }
-                catch ( IOException e )
-                {
-                    // ignore
-                }
-            }
-        }
     }
 
 }
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/AbstractDependencyMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/AbstractDependencyMojo.java
index 2e4124c..bd46ab3 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/AbstractDependencyMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/AbstractDependencyMojo.java
@@ -26,9 +26,9 @@
 
 import java.io.BufferedWriter;
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.OutputStreamWriter;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
 import java.util.Collection;
 
 /**
@@ -58,7 +58,7 @@
      * @param artifacts The list of artifacts to write to the file, may be <code>null</code>.
      * @throws MojoExecutionException If the output file could not be written.
      */
-    protected void writeArtifacts( String pathname, Collection artifacts )
+    protected void writeArtifacts( String pathname, Collection<Artifact> artifacts )
         throws MojoExecutionException
     {
         if ( pathname == null || pathname.length() <= 0 )
@@ -70,18 +70,15 @@
 
         getLog().info( "[MAVEN-CORE-IT-LOG] Dumping artifact list: " + file );
 
-        BufferedWriter writer = null;
-        try
-        {
-            file.getParentFile().mkdirs();
+        file.getParentFile().mkdirs();
 
-            writer = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( file ), "UTF-8" ) );
+        try ( BufferedWriter writer = Files.newBufferedWriter( file.toPath(), Charset.forName( "UTF-8" ) ) )
+        {
 
             if ( artifacts != null )
             {
-                for ( Object artifact1 : artifacts )
+                for ( Artifact artifact : artifacts )
                 {
-                    Artifact artifact = (Artifact) artifact1;
                     writer.write( artifact.getId() );
                     String optional = "";
                     if ( artifact.isOptional() )
@@ -98,20 +95,6 @@
         {
             throw new MojoExecutionException( "Failed to write artifact list", e );
         }
-        finally
-        {
-            if ( writer != null )
-            {
-                try
-                {
-                    writer.close();
-                }
-                catch ( IOException e )
-                {
-                    // just ignore
-                }
-            }
-        }
     }
 
     // NOTE: We don't want to test path translation here so resolve relative path manually for robustness
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AbstractDependencyMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AbstractDependencyMojo.java
index 0bbd86b..12aee86 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AbstractDependencyMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AbstractDependencyMojo.java
@@ -27,9 +27,10 @@
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.OutputStreamWriter;
+import java.io.OutputStream;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
 import java.security.DigestInputStream;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
@@ -74,7 +75,7 @@
      * @param artifacts The list of artifacts to write to the file, may be <code>null</code>.
      * @throws MojoExecutionException If the output file could not be written.
      */
-    protected void writeArtifacts( String pathname, Collection artifacts )
+    protected void writeArtifacts( String pathname, Collection<Artifact> artifacts )
         throws MojoExecutionException
     {
         if ( pathname == null || pathname.length() <= 0 )
@@ -86,18 +87,15 @@
 
         getLog().info( "[MAVEN-CORE-IT-LOG] Dumping artifact list: " + file );
 
-        BufferedWriter writer = null;
-        try
-        {
-            file.getParentFile().mkdirs();
+        file.getParentFile().mkdirs();
 
-            writer = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( file ), "UTF-8" ) );
+        try ( BufferedWriter writer = Files.newBufferedWriter( file.toPath(), Charset.forName( "UTF-8" ) ) )
+        {
 
             if ( artifacts != null )
             {
-                for ( Object artifact1 : artifacts )
+                for ( Artifact artifact : artifacts )
                 {
-                    Artifact artifact = (Artifact) artifact1;
                     String id = getId( artifact );
                     writer.write( id );
                     String optional = "";
@@ -115,20 +113,6 @@
         {
             throw new MojoExecutionException( "Failed to write artifact list", e );
         }
-        finally
-        {
-            if ( writer != null )
-            {
-                try
-                {
-                    writer.close();
-                }
-                catch ( IOException e )
-                {
-                    // just ignore
-                }
-            }
-        }
     }
 
     private String getId( Artifact artifact )
@@ -157,12 +141,10 @@
 
         getLog().info( "[MAVEN-CORE-IT-LOG] Dumping class path: " + file );
 
-        BufferedWriter writer = null;
-        try
-        {
-            file.getParentFile().mkdirs();
+        file.getParentFile().mkdirs();
 
-            writer = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( file ), "UTF-8" ) );
+        try ( BufferedWriter writer = Files.newBufferedWriter( file.toPath(), Charset.forName( "UTF-8" ) ) )
+        {
 
             if ( classPath != null )
             {
@@ -179,20 +161,6 @@
         {
             throw new MojoExecutionException( "Failed to write class path list", e );
         }
-        finally
-        {
-            if ( writer != null )
-            {
-                try
-                {
-                    writer.close();
-                }
-                catch ( IOException e )
-                {
-                    // just ignore
-                }
-            }
-        }
     }
 
     protected void writeClassPathChecksums( String pathname, Collection classPath )
@@ -245,33 +213,16 @@
             }
         }
 
-        FileOutputStream os = null;
-        try
+        file.getParentFile().mkdirs();
+
+        try ( OutputStream os = Files.newOutputStream( file.toPath() ) )
         {
-            file.getParentFile().mkdirs();
-
-            os = new FileOutputStream( file );
-
             checksums.store( os, "MAVEN-CORE-IT" );
         }
         catch ( IOException e )
         {
             throw new MojoExecutionException( "Failed to write class path checksums", e );
         }
-        finally
-        {
-            if ( os != null )
-            {
-                try
-                {
-                    os.close();
-                }
-                catch ( IOException e )
-                {
-                    // just ignore
-                }
-            }
-        }
     }
 
     private String calcChecksum( File jarFile )
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AggregateTestMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AggregateTestMojo.java
index f52bee9..af6dae2 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AggregateTestMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AggregateTestMojo.java
@@ -74,7 +74,7 @@
      * @parameter default-value="${reactorProjects}"
      * @readonly
      */
-    private List reactorProjects;
+    private List<MavenProject> reactorProjects;
 
     /**
      * Runs this mojo.
@@ -86,10 +86,8 @@
     {
         try
         {
-            for ( Object reactorProject : reactorProjects )
+            for ( MavenProject project : reactorProjects )
             {
-                MavenProject project = (MavenProject) reactorProject;
-
                 writeArtifacts( filter( projectArtifacts, project ), project.getArtifacts() );
                 writeClassPath( filter( testClassPath, project ), project.getTestClasspathElements() );
                 writeClassPathChecksums( filter( testClassPathChecksums, project ),
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/InjectMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/InjectMojo.java
index 56841ce..6ae06d7 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/InjectMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/InjectMojo.java
@@ -53,7 +53,7 @@
      * @parameter default-value="${plugin.artifacts}"
      * @readonly
      */
-    private Collection pluginArtifacts;
+    private Collection<Artifact> pluginArtifacts;
 
     /**
      * The current Maven project.
@@ -97,9 +97,8 @@
             dependencyArtifacts = new LinkedHashSet();
         }
 
-        for ( Object pluginArtifact : pluginArtifacts )
+        for ( Artifact artifact : pluginArtifacts )
         {
-            Artifact artifact = (Artifact) pluginArtifact;
 
             String artifactKey = artifact.getGroupId() + ':' + artifact.getArtifactId();
 
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/ExpressionUtil.java b/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/ExpressionUtil.java
index 6e5738b..a1a0302 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/ExpressionUtil.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/ExpressionUtil.java
@@ -85,7 +85,7 @@
      */
     private static Map evaluate( String prefix, List segments, Object context )
     {
-        Map values = Collections.EMPTY_MAP;
+        Map values = Collections.emptyMap();
 
         if ( segments.isEmpty() )
         {
@@ -93,7 +93,7 @@
         }
         else if ( context != null )
         {
-            Map targets = Collections.EMPTY_MAP;
+            Map<String, Object> targets = Collections.emptyMap();
             String segment = (String) segments.get( 0 );
             if ( context.getClass().isArray() && Character.isDigit( segment.charAt( 0 ) ) )
             {
@@ -142,9 +142,10 @@
             }
 
             values = new LinkedHashMap();
-            for ( Object key : targets.keySet() )
+            for ( Map.Entry<String, Object> entry : targets.entrySet() )
             {
-                Object target = targets.get( key );
+                String key = entry.getKey();
+                Object target = entry.getValue();
                 values.putAll(
                     evaluate( concat( prefix, String.valueOf( key ) ), segments.subList( 1, segments.size() ),
                               target ) );
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/PropertyUtil.java b/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/PropertyUtil.java
index becb865..f3769ab 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/PropertyUtil.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/PropertyUtil.java
@@ -20,12 +20,12 @@
  */
 
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.lang.reflect.Array;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
+import java.nio.file.Files;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -211,27 +211,12 @@
     public static void write( Properties props, File file )
         throws IOException
     {
-        OutputStream out = null;
-        try
+        file.getParentFile().mkdirs();
+
+        try ( OutputStream out = Files.newOutputStream( file.toPath() ) )
         {
-            file.getParentFile().mkdirs();
-            out = new FileOutputStream( file );
             props.store( out, "MAVEN-CORE-IT-LOG" );
         }
-        finally
-        {
-            if ( out != null )
-            {
-                try
-                {
-                    out.close();
-                }
-                catch ( IOException e )
-                {
-                    // just ignore
-                }
-            }
-        }
     }
 
 }
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/TouchMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/TouchMojo.java
index 5401d48..8788f39 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/TouchMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/TouchMojo.java
@@ -23,10 +23,12 @@
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
 
+import java.io.BufferedWriter;
 import java.io.File;
-import java.io.FileOutputStream;
-import java.io.OutputStreamWriter;
 import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.StandardOpenOption;
 
 /**
  * @goal touch
@@ -75,14 +77,19 @@
              }
              
              File touch = new File( dir, file );
+             if ( !Files.exists( touch.toPath() ) )
+             {
+                 Files.createFile( touch.toPath() );
+             }
 
              // NOTE: Using append mode to track execution count
-             OutputStreamWriter w = new OutputStreamWriter( new FileOutputStream( touch, true ), "UTF-8" );
-             
-             w.write( file );
-             w.write( "\n" );
-             
-             w.close();
+             try ( BufferedWriter w = Files.newBufferedWriter( touch.toPath(), Charset.forName( "UTF-8" ),
+                                                              StandardOpenOption.APPEND ) )
+             {
+                 w.write( file );
+                 w.write( "\n" );
+             }
+
         }
         catch ( IOException e )
         {
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/AbstractLogMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/AbstractLogMojo.java
index 585b552..bda0f81 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/AbstractLogMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/AbstractLogMojo.java
@@ -27,7 +27,9 @@
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.io.OutputStreamWriter;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.StandardOpenOption;
 
 /**
  * Provides common services for the mojos of this plugin.
@@ -89,10 +91,13 @@
         try
         {
             file.getParentFile().mkdirs();
-            OutputStream out = new FileOutputStream( file, true );
-            try
+            if ( !Files.exists( file.toPath() ) )
             {
-                BufferedWriter writer = new BufferedWriter( new OutputStreamWriter( out, encoding ) );
+                Files.createFile( file.toPath() );
+            }
+            try ( BufferedWriter writer = Files.newBufferedWriter( file.toPath(), Charset.forName( encoding ),
+                                                                  StandardOpenOption.APPEND ) )
+            {
                 if ( value != null )
                 {
                     writer.write( value.toString() );
@@ -100,17 +105,6 @@
                     writer.flush();
                 }
             }
-            finally
-            {
-                try
-                {
-                    out.close();
-                }
-                catch ( IOException e )
-                {
-                    // just ignore, we tried our best to clean up
-                }
-            }
         }
         catch ( IOException e )
         {
@@ -128,26 +122,19 @@
     {
         File file = getLogFile();
         getLog().info( "[MAVEN-CORE-IT-LOG] Resetting log file: " + file );
-        try
+        /*
+         * NOTE: Intentionally don't delete the file but create a new empty one to check the plugin was executed.
+         */
+        file.getParentFile().mkdirs();
+        try ( OutputStream out = new FileOutputStream( file ) )
         {
-            /*
-             * NOTE: Intentionally don't delete the file but create a new empty one to check the plugin was executed.
-             */
-            file.getParentFile().mkdirs();
-            OutputStream out = new FileOutputStream( file );
-            try
-            {
-                out.close();
-            }
-            catch ( IOException e )
-            {
-                // just ignore, we tried our best to clean up
-            }
+            // no op
         }
         catch ( IOException e )
         {
             throw new MojoExecutionException( "Failed to reset log file " + logFile, e );
         }
+
     }
 
 }
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-no-project/src/main/java/org/apache/maven/plugin/coreit/NoProjectMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-no-project/src/main/java/org/apache/maven/plugin/coreit/NoProjectMojo.java
index 752686c..7dd85eb 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-no-project/src/main/java/org/apache/maven/plugin/coreit/NoProjectMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-no-project/src/main/java/org/apache/maven/plugin/coreit/NoProjectMojo.java
@@ -67,11 +67,10 @@
              
              getLog().info( "Touching: " + touch );
      
-             FileWriter w = new FileWriter( touch );
-             
-             w.write( file );
-             
-             w.close();
+             try ( FileWriter w = new FileWriter( touch ) )
+             {
+                 w.write( file );
+             }
         }
         catch ( IOException e )
         {
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-plexus-utils-11/src/main/java/org/apache/maven/its/plugins/SerializeMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-plexus-utils-11/src/main/java/org/apache/maven/its/plugins/SerializeMojo.java
index 8d26a3a..33512a7 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-plexus-utils-11/src/main/java/org/apache/maven/its/plugins/SerializeMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-plexus-utils-11/src/main/java/org/apache/maven/its/plugins/SerializeMojo.java
@@ -28,7 +28,6 @@
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
-import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 import org.codehaus.plexus.util.xml.pull.MXSerializer;
 import org.codehaus.plexus.util.xml.pull.XmlSerializer;
@@ -49,12 +48,11 @@
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
-        Writer writer = null;
+
+        file.getParentFile().mkdirs();
         XmlSerializer s = new MXSerializer();
-        try
+        try ( Writer writer = new OutputStreamWriter( new FileOutputStream( file ), "UTF-8" ) )
         {
-            file.getParentFile().mkdirs();
-            writer = new OutputStreamWriter( new FileOutputStream( file ), "UTF-8" );
             s.setOutput( writer );
 
             Xpp3Dom dom = new Xpp3Dom( "root" );
@@ -65,9 +63,5 @@
         {
             throw new MojoExecutionException( e.getMessage(), e );
         }
-        finally
-        {
-            IOUtil.close( writer );
-        }
     }
 }
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-plexus-utils-new/src/main/java/org/apache/maven/its/plugins/SerializeMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-plexus-utils-new/src/main/java/org/apache/maven/its/plugins/SerializeMojo.java
index 7627e1f..d848d4a 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-plexus-utils-new/src/main/java/org/apache/maven/its/plugins/SerializeMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-plexus-utils-new/src/main/java/org/apache/maven/its/plugins/SerializeMojo.java
@@ -25,7 +25,6 @@
 import java.io.OutputStreamWriter;
 import java.io.Writer;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
@@ -49,12 +48,10 @@
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
-        Writer writer = null;
+        file.getParentFile().mkdirs();
         XmlSerializer s = new MXSerializer();
-        try
+        try ( Writer writer = new OutputStreamWriter( new FileOutputStream( file ), "UTF-8" ) )
         {
-            file.getParentFile().mkdirs();
-            writer = new OutputStreamWriter( new FileOutputStream( file ), "UTF-8" );
             s.setOutput( writer );
 
             Xpp3Dom dom = new Xpp3Dom( "root" );
@@ -65,9 +62,5 @@
         {
             throw new MojoExecutionException( e.getMessage(), e );
         }
-        finally
-        {
-            IOUtils.closeQuietly( writer );
-        }
     }
 }
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-setter/src/main/java/org/apache/maven/plugin/coreit/CoreItMojoWithSetters.java b/core-it-support/core-it-plugins/maven-it-plugin-setter/src/main/java/org/apache/maven/plugin/coreit/CoreItMojoWithSetters.java
index 5c6c9dd..a4d3ecc 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-setter/src/main/java/org/apache/maven/plugin/coreit/CoreItMojoWithSetters.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-setter/src/main/java/org/apache/maven/plugin/coreit/CoreItMojoWithSetters.java
@@ -127,11 +127,10 @@
 
              File touch = new File( dir, file );
 
-             FileWriter w = new FileWriter( touch );
-
-             w.write( file );
-
-             w.close();
+             try ( FileWriter w = new FileWriter( touch ) )
+             {
+                 w.write( file );
+             }
         }
         catch ( IOException e )
         {
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-settings/src/main/java/org/apache/maven/plugin/coreit/SettingsReadItMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-settings/src/main/java/org/apache/maven/plugin/coreit/SettingsReadItMojo.java
index d812445..c786ec4 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-settings/src/main/java/org/apache/maven/plugin/coreit/SettingsReadItMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-settings/src/main/java/org/apache/maven/plugin/coreit/SettingsReadItMojo.java
@@ -23,7 +23,6 @@
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.settings.Settings;
 import org.apache.maven.settings.io.xpp3.SettingsXpp3Writer;
-import org.codehaus.plexus.util.IOUtil;
 
 import java.io.File;
 import java.io.FileWriter;
@@ -59,10 +58,8 @@
             dumpFile.delete();
         }
         dumpFile.getParentFile().mkdirs();
-        FileWriter fw = null;
-        try
+        try ( FileWriter fw = new FileWriter( dumpFile ) )
         {
-            fw = new FileWriter( dumpFile );
             SettingsXpp3Writer writer = new SettingsXpp3Writer();
             writer.write( fw, settings );
         }
@@ -70,10 +67,6 @@
         {
             throw new MojoExecutionException( e.getMessage(), e );
         }
-        finally
-        {
-            IOUtil.close( fw );
-        }
     }
 
 
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-site/src/main/java/org/apache/maven/plugin/coreit/InfoReport.java b/core-it-support/core-it-plugins/maven-it-plugin-site/src/main/java/org/apache/maven/plugin/coreit/InfoReport.java
index 74149db..73643ff 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-site/src/main/java/org/apache/maven/plugin/coreit/InfoReport.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-site/src/main/java/org/apache/maven/plugin/coreit/InfoReport.java
@@ -110,31 +110,15 @@
 
         getLog().info( "[MAVEN-CORE-IT-LOG] Creating output file: " + outputFile );
 
-        OutputStream out = null;
-        try
+        outputFile.getParentFile().mkdirs();
+        try ( OutputStream out = new FileOutputStream( outputFile ) )
         {
-            outputFile.getParentFile().mkdirs();
-            out = new FileOutputStream( outputFile );
             props.store( out, "MAVEN-CORE-IT-LOG" );
         }
         catch ( IOException e )
         {
             throw new MojoExecutionException( "Output file could not be created: " + outputFile, e );
         }
-        finally
-        {
-            if ( out != null )
-            {
-                try
-                {
-                    out.close();
-                }
-                catch ( IOException e )
-                {
-                    // just ignore
-                }
-            }
-        }
 
         getLog().info( "[MAVEN-CORE-IT-LOG] Created output file: " + outputFile );
     }
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-site/src/main/java/org/apache/maven/plugin/coreit/ListMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-site/src/main/java/org/apache/maven/plugin/coreit/ListMojo.java
index 3d79337..e6e642a 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-site/src/main/java/org/apache/maven/plugin/coreit/ListMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-site/src/main/java/org/apache/maven/plugin/coreit/ListMojo.java
@@ -83,31 +83,15 @@
 
         getLog().info( "[MAVEN-CORE-IT-LOG] Creating output file " + reportsFile );
 
-        OutputStream out = null;
-        try
+        reportsFile.getParentFile().mkdirs();
+        try ( OutputStream out = new FileOutputStream( reportsFile ) )
         {
-            reportsFile.getParentFile().mkdirs();
-            out = new FileOutputStream( reportsFile );
             reportProperties.store( out, "MAVEN-CORE-IT-LOG" );
         }
         catch ( IOException e )
         {
             throw new MojoExecutionException( "Output file could not be created: " + reportsFile, e );
         }
-        finally
-        {
-            if ( out != null )
-            {
-                try
-                {
-                    out.close();
-                }
-                catch ( IOException e )
-                {
-                    // just ignore
-                }
-            }
-        }
 
         getLog().info( "[MAVEN-CORE-IT-LOG] Created output file " + reportsFile );
     }
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-toolchain/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-toolchain/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java
index 7fa4452..a847f96 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-toolchain/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-toolchain/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java
@@ -109,7 +109,7 @@
         Properties properties = new Properties();
 
         int count = 1;
-        for ( Iterator<ToolchainPrivate> i = Arrays.<ToolchainPrivate>asList( tcs ).iterator(); i.hasNext(); count++ )
+        for ( Iterator<ToolchainPrivate> i = Arrays.asList( tcs ).iterator(); i.hasNext(); count++ )
         {
             ToolchainPrivate toolchain = i.next();
 
@@ -120,31 +120,15 @@
             }
         }
 
-        OutputStream out = null;
-        try
+        outputFile.getParentFile().mkdirs();
+        try ( OutputStream out = new FileOutputStream( outputFile ) )
         {
-            outputFile.getParentFile().mkdirs();
-            out = new FileOutputStream( outputFile );
             properties.store( out, "MAVEN-CORE-IT-LOG" );
         }
         catch ( IOException e )
         {
             throw new MojoExecutionException( e.getMessage(), e );
         }
-        finally
-        {
-            if ( out != null )
-            {
-                try
-                {
-                    out.close();
-                }
-                catch ( IOException e )
-                {
-                    // ignore
-                }
-            }
-        }
     }
 
     private ToolchainPrivate[] getToolchains()
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-toolchain/src/main/java/org/apache/maven/plugin/coreit/FindToolMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-toolchain/src/main/java/org/apache/maven/plugin/coreit/FindToolMojo.java
index 06fec9f..88b6a2d 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-toolchain/src/main/java/org/apache/maven/plugin/coreit/FindToolMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-toolchain/src/main/java/org/apache/maven/plugin/coreit/FindToolMojo.java
@@ -97,30 +97,14 @@
             }
         }
 
-        OutputStream out = null;
-        try
+        outputFile.getParentFile().mkdirs();
+        try ( OutputStream out = new FileOutputStream( outputFile ) )
         {
-            outputFile.getParentFile().mkdirs();
-            out = new FileOutputStream( outputFile );
             properties.store( out, "MAVEN-CORE-IT-LOG" );
         }
         catch ( IOException e )
         {
             throw new MojoExecutionException( e.getMessage(), e );
         }
-        finally
-        {
-            if ( out != null )
-            {
-                try
-                {
-                    out.close();
-                }
-                catch ( IOException e )
-                {
-                    // ignore
-                }
-            }
-        }
     }
 }
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-touch/src/main/java/org/apache/maven/plugin/coreit/CopyPomMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-touch/src/main/java/org/apache/maven/plugin/coreit/CopyPomMojo.java
index eddef2b..c9abeea 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-touch/src/main/java/org/apache/maven/plugin/coreit/CopyPomMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-touch/src/main/java/org/apache/maven/plugin/coreit/CopyPomMojo.java
@@ -62,18 +62,16 @@
 
             getLog().info( "Copying POM to file: " + dest.getAbsolutePath() );
 
-            FileInputStream in = new FileInputStream( pomFile );
-            FileOutputStream out = new FileOutputStream( dest );
-
-            int read = -1;
-            byte[] buf = new byte[4 * 1024];
-            while ( ( read = in.read( buf ) ) > -1 )
+            try ( FileInputStream in = new FileInputStream( pomFile );
+                  FileOutputStream out = new FileOutputStream( dest ) )
             {
-                out.write( buf, 0, read );
+                int read = -1;
+                byte[] buf = new byte[4 * 1024];
+                while ( ( read = in.read( buf ) ) > -1 )
+                {
+                    out.write( buf, 0, read );
+                }
             }
-
-            in.close();
-            out.close();
         }
         catch ( IOException e )
         {
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-touch/src/main/java/org/apache/maven/plugin/coreit/CoreItTouchMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-touch/src/main/java/org/apache/maven/plugin/coreit/CoreItTouchMojo.java
index 460e9c8..950abc3 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-touch/src/main/java/org/apache/maven/plugin/coreit/CoreItTouchMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-touch/src/main/java/org/apache/maven/plugin/coreit/CoreItTouchMojo.java
@@ -153,11 +153,10 @@
 
              getLog().info( "Touching file: " + touch.getAbsolutePath() );
 
-             FileWriter w = new FileWriter( touch );
-
-             w.write( file );
-
-             w.close();
+             try ( FileWriter w = new FileWriter( touch ) )
+             {
+                 w.write( file );
+             }
         }
         
         catch ( IOException e )
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-uses-properties/src/main/java/org/apache/maven/plugin/coreit/UsesPropertiesMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-uses-properties/src/main/java/org/apache/maven/plugin/coreit/UsesPropertiesMojo.java
index c10e1ff..89983fe 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-uses-properties/src/main/java/org/apache/maven/plugin/coreit/UsesPropertiesMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-uses-properties/src/main/java/org/apache/maven/plugin/coreit/UsesPropertiesMojo.java
@@ -50,10 +50,12 @@
         {
             File file = new File( basedir, "target/project.properties" );
             file.getParentFile().mkdirs();
-            FileOutputStream fos = new FileOutputStream( file );
-
-            properties.store( fos, "# Properties generated by the execution of a mojo that uses"
-                + " interpolated POM values for configuration." );
+            try ( FileOutputStream fos = new FileOutputStream( file ) )
+            {
+                properties.store( fos,
+                                  "# Properties generated by the execution of a mojo that uses"
+                                      + " interpolated POM values for configuration." );
+            }
         }
         catch ( Exception e )
         {
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/DumpAuthMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/DumpAuthMojo.java
index eb829e2..d654c5a 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/DumpAuthMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/DumpAuthMojo.java
@@ -124,31 +124,15 @@
 
         getLog().info( "[MAVEN-CORE-IT-LOG] Creating output file " + propertiesFile );
 
-        OutputStream out = null;
-        try
+        propertiesFile.getParentFile().mkdirs();
+        try ( OutputStream out = new FileOutputStream( propertiesFile ) )
         {
-            propertiesFile.getParentFile().mkdirs();
-            out = new FileOutputStream( propertiesFile );
             authProperties.store( out, "MAVEN-CORE-IT-LOG" );
         }
         catch ( IOException e )
         {
             throw new MojoExecutionException( "Output file could not be created: " + propertiesFile, e );
         }
-        finally
-        {
-            if ( out != null )
-            {
-                try
-                {
-                    out.close();
-                }
-                catch ( IOException e )
-                {
-                    // just ignore
-                }
-            }
-        }
 
         getLog().info( "[MAVEN-CORE-IT-LOG] Created output file " + propertiesFile );
     }
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/DumpVersionMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/DumpVersionMojo.java
index 7b02347..28a821c 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/DumpVersionMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/DumpVersionMojo.java
@@ -121,32 +121,15 @@
 
         getLog().info( "[MAVEN-CORE-IT-LOG] Creating output file " + propertiesFile );
 
-        OutputStream out = null;
-        try
+        propertiesFile.getParentFile().mkdirs();
+        try ( OutputStream out = new FileOutputStream( propertiesFile ) )
         {
-            propertiesFile.getParentFile().mkdirs();
-            out = new FileOutputStream( propertiesFile );
             wagonProperties.store( out, "MAVEN-CORE-IT-LOG" );
         }
         catch ( IOException e )
         {
             throw new MojoExecutionException( "Output file could not be created: " + propertiesFile, e );
         }
-        finally
-        {
-            if ( out != null )
-            {
-                try
-                {
-                    out.close();
-                }
-                catch ( IOException e )
-                {
-                    // just ignore
-                }
-            }
-        }
-
         getLog().info( "[MAVEN-CORE-IT-LOG] Created output file " + propertiesFile );
     }
 
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/LoadResourceMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/LoadResourceMojo.java
index 4b140a3..346586c 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/LoadResourceMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/LoadResourceMojo.java
@@ -151,32 +151,16 @@
 
         getLog().info( "[MAVEN-CORE-IT-LOG] Creating output file " + wagonClassLoaderOutput );
 
-        OutputStream out = null;
-        try
+        wagonClassLoaderOutput.getParentFile().mkdirs();
+
+        try ( OutputStream out = new FileOutputStream( wagonClassLoaderOutput ) )
         {
-            wagonClassLoaderOutput.getParentFile().mkdirs();
-            out = new FileOutputStream( wagonClassLoaderOutput );
             loaderProperties.store( out, "MAVEN-CORE-IT-LOG" );
         }
         catch ( IOException e )
         {
             throw new MojoExecutionException( "Output file could not be created: " + wagonClassLoaderOutput, e );
         }
-        finally
-        {
-            if ( out != null )
-            {
-                try
-                {
-                    out.close();
-                }
-                catch ( IOException e )
-                {
-                    // just ignore
-                }
-            }
-        }
-
         getLog().info( "[MAVEN-CORE-IT-LOG] Created output file " + wagonClassLoaderOutput );
     }
 
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/LookupWagonMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/LookupWagonMojo.java
index 8ebf3de..1371895 100644
--- a/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/LookupWagonMojo.java
+++ b/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/LookupWagonMojo.java
@@ -102,32 +102,16 @@
 
         getLog().info( "[MAVEN-CORE-IT-LOG] Creating output file " + outputFile );
 
-        OutputStream out = null;
-        try
+        outputFile.getParentFile().mkdirs();
+
+        try ( OutputStream out = new FileOutputStream( outputFile ) )
         {
-            outputFile.getParentFile().mkdirs();
-            out = new FileOutputStream( outputFile );
             loaderProperties.store( out, "MAVEN-CORE-IT-LOG" );
         }
         catch ( IOException e )
         {
             throw new MojoExecutionException( "Output file could not be created: " + outputFile, e );
         }
-        finally
-        {
-            if ( out != null )
-            {
-                try
-                {
-                    out.close();
-                }
-                catch ( IOException e )
-                {
-                    // just ignore
-                }
-            }
-        }
-
         getLog().info( "[MAVEN-CORE-IT-LOG] Created output file " + outputFile );
     }
 
diff --git a/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java b/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java
index 9e0edc4..ad69618 100644
--- a/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java
+++ b/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java
@@ -89,7 +89,7 @@
         }
         catch ( InvalidVersionSpecificationException e )
         {
-            throw (RuntimeException) new IllegalArgumentException( "Invalid version range: " + versionRangeStr, e );
+            throw new IllegalArgumentException( "Invalid version range: " + versionRangeStr, e );
         }
 
         ArtifactVersion version = getMavenVersion();
@@ -180,7 +180,7 @@
         }
         catch ( InvalidVersionSpecificationException e )
         {
-            throw (RuntimeException) new IllegalArgumentException( "Invalid version range: " + versionRangeStr, e );
+            throw new IllegalArgumentException( "Invalid version range: " + versionRangeStr, e );
         }
 
         ArtifactVersion version = getMavenVersion();
@@ -276,7 +276,7 @@
         }
         catch ( InvalidVersionSpecificationException e )
         {
-            throw (RuntimeException) new IllegalArgumentException( "Invalid version range: " + versionRange, e );
+            throw new IllegalArgumentException( "Invalid version range: " + versionRange, e );
         }
 
         ArtifactVersion version = getJavaVersion();
@@ -303,7 +303,7 @@
         }
         catch ( InvalidVersionSpecificationException e )
         {
-            throw (RuntimeException) new IllegalArgumentException( "Invalid version range: " + versionRange, e );
+            throw new IllegalArgumentException( "Invalid version range: " + versionRange, e );
         }
 
         ArtifactVersion version = getMavenVersion();
@@ -339,7 +339,7 @@
         }
         catch ( InvalidVersionSpecificationException e )
         {
-            throw (RuntimeException) new IllegalArgumentException( "Invalid version range: " + versionRange, e );
+            throw new IllegalArgumentException( "Invalid version range: " + versionRange, e );
         }
 
         ArtifactVersion version = getMavenVersion();