You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2019/06/05 20:11:44 UTC

[maven-linkcheck-plugin] 01/01: [MLINKCHECK-34] Require Java 7

This is an automated email from the ASF dual-hosted git repository.

rfscholte pushed a commit to branch MLINKCHECK-34
in repository https://gitbox.apache.org/repos/asf/maven-linkcheck-plugin.git

commit 46f0d36bd2da296abb71b8b432c9f1aeb171d20d
Author: rfscholte <rf...@apache.org>
AuthorDate: Wed Jun 5 22:11:31 2019 +0200

    [MLINKCHECK-34] Require Java 7
---
 Jenkinsfile                                        |  2 +-
 pom.xml                                            |  3 +-
 .../maven/plugins/linkcheck/SiteInvoker.java       | 42 +++++++---------------
 3 files changed, 15 insertions(+), 32 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 09ac70f..e9f05f7 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -17,4 +17,4 @@
  * under the License.
  */
 
-asfMavenTlpStdBuild()
+asfMavenTlpPlgnBuild()
diff --git a/pom.xml b/pom.xml
index e626bd1..515a3db 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,7 @@ under the License.
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-plugins</artifactId>
     <version>33</version>
-    <relativePath>../../pom/maven/maven-plugins/pom.xml</relativePath>
+    <relativePath></relativePath>
   </parent>
 
   <artifactId>maven-linkcheck-plugin</artifactId>
@@ -65,6 +65,7 @@ under the License.
     <doxiaVersion>1.4</doxiaVersion>
     <doxia-sitetoolsVersion>1.4</doxia-sitetoolsVersion>
     <mavenVersion>2.2.1</mavenVersion>
+    <javaVersion>7</javaVersion>
   </properties>
 
   <dependencies>
diff --git a/src/main/java/org/apache/maven/plugins/linkcheck/SiteInvoker.java b/src/main/java/org/apache/maven/plugins/linkcheck/SiteInvoker.java
index d434a7b..317469d 100644
--- a/src/main/java/org/apache/maven/plugins/linkcheck/SiteInvoker.java
+++ b/src/main/java/org/apache/maven/plugins/linkcheck/SiteInvoker.java
@@ -29,19 +29,16 @@ import java.io.Reader;
 import java.io.UnsupportedEncodingException;
 import java.io.Writer;
 import java.util.ArrayList;
-
 import java.util.Collections;
 import java.util.List;
 import java.util.Properties;
 
 import org.apache.commons.lang.SystemUtils;
 import org.apache.maven.artifact.repository.ArtifactRepository;
-
 import org.apache.maven.model.Profile;
 import org.apache.maven.model.Reporting;
-import org.apache.maven.project.MavenProject;
-
 import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
 import org.apache.maven.shared.invoker.DefaultInvocationRequest;
 import org.apache.maven.shared.invoker.DefaultInvoker;
 import org.apache.maven.shared.invoker.InvocationOutputHandler;
@@ -50,7 +47,6 @@ import org.apache.maven.shared.invoker.InvocationResult;
 import org.apache.maven.shared.invoker.Invoker;
 import org.apache.maven.shared.invoker.MavenInvocationException;
 import org.apache.maven.shared.invoker.PrintStreamHandler;
-
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.ReaderFactory;
@@ -100,7 +96,7 @@ public class SiteInvoker
         }
 
         // invoker site parameters
-        List goals = Collections.singletonList( "site" );
+        List<String> goals = Collections.singletonList( "site" );
         Properties properties = new Properties();
         properties.put( "linkcheck.skip", "true" ); // to stop recursion
 
@@ -127,21 +123,14 @@ public class SiteInvoker
         }
 
         clone.getOriginalModel().getReporting().setOutputDirectory( tmpReportingOutputDirectory.getAbsolutePath() );
-        List profileIds = getActiveProfileIds( clone );
+        List<String> profileIds = getActiveProfileIds( clone );
 
         // create the original model as tmp pom file for the invoker
         File tmpProjectFile = FileUtils.createTempFile( "pom", ".xml", project.getBasedir() );
-        Writer writer = null;
-        try
+        
+        try ( Writer writer = WriterFactory.newXmlWriter( tmpProjectFile ) )
         {
-            writer = WriterFactory.newXmlWriter( tmpProjectFile );
             clone.writeOriginalModel( writer );
-            writer.close();
-            writer = null;
-        }
-        finally
-        {
-            IOUtil.close( writer );
         }
 
         // invoke it
@@ -158,9 +147,9 @@ public class SiteInvoker
         }
     }
 
-    private static List getActiveProfileIds( MavenProject clone )
+    private static List<String> getActiveProfileIds( MavenProject clone )
     {
-        List profileIds = new ArrayList();
+        List<String> profileIds = new ArrayList<>();
 
         for ( Object o : clone.getActiveProfiles() )
         {
@@ -177,8 +166,8 @@ public class SiteInvoker
      * @param goals the list of goals
      * @param properties the properties for the invoker
      */
-    private void invoke( File projectFile, File invokerLog, String mavenHome, List goals, List activeProfiles,
-                         Properties properties )
+    private void invoke( File projectFile, File invokerLog, String mavenHome, List<String> goals,
+                         List<String> activeProfiles, Properties properties )
     {
         Invoker invoker = new DefaultInvoker();
         invoker.setMavenHome( new File( mavenHome ) );
@@ -221,23 +210,16 @@ public class SiteInvoker
         }
 
         String invokerLogContent = null;
-        Reader reader = null;
-        try
+        
+        try ( Reader reader = ReaderFactory.newReader( invokerLog, "UTF-8" ) )
         {
-            reader = ReaderFactory.newReader( invokerLog, "UTF-8" );
             invokerLogContent = IOUtil.toString( reader );
-            reader.close();
-            reader = null;
         }
         catch ( IOException e )
         {
             getLog().error( "IOException: " + e.getMessage() );
             getLog().debug( e );
         }
-        finally
-        {
-            IOUtil.close( reader );
-        }
 
         if ( invokerLogContent != null && invokerLogContent.contains( "Error occurred during initialization of VM" ) )
         {
@@ -280,7 +262,7 @@ public class SiteInvoker
      * @return the invocation result
      * @throws MavenInvocationException if any
      */
-    private InvocationResult invoke( Invoker invoker, InvocationRequest request, File invokerLog, List goals,
+    private InvocationResult invoke( Invoker invoker, InvocationRequest request, File invokerLog, List<String> goals,
                                      Properties properties, String mavenOpts )
         throws MavenInvocationException
     {