[maven-antrun-plugin] branch MANTRUN-217 created (now c30232e)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[maven-antrun-plugin] branch MANTRUN-217 created (now c30232e)

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

rfscholte pushed a change to branch MANTRUN-217
in repository https://gitbox.apache.org/repos/asf/maven-antrun-plugin.git.


      at c30232e  [MANTRUN-217] Require Java 7

This branch includes the following new commits:

     new c30232e  [MANTRUN-217] Require Java 7

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Reply | Threaded
Open this post in threaded view
|

[maven-antrun-plugin] 01/01: [MANTRUN-217] Require Java 7

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

rfscholte pushed a commit to branch MANTRUN-217
in repository https://gitbox.apache.org/repos/asf/maven-antrun-plugin.git

commit c30232e9c9eed27f44f038070cb009a654e9dcbd
Author: rfscholte <[hidden email]>
AuthorDate: Mon Mar 11 20:13:28 2019 +0100

    [MANTRUN-217] Require Java 7
---
 pom.xml                                                  |  3 ++-
 .../org/apache/maven/ant/tasks/AttachArtifactTask.java   |  1 +
 .../apache/maven/ant/tasks/DependencyFilesetsTask.java   |  3 ++-
 .../ant/tasks/support/SpecificScopesArtifactFilter.java  | 12 ++++++------
 .../maven/ant/tasks/support/TypesArtifactFilter.java     |  3 ++-
 .../apache/maven/ant/tasks/support/VersionMapper.java    |  4 ++++
 .../java/org/apache/maven/plugins/antrun/AntRunMojo.java | 16 ++--------------
 .../antrun/AntrunXmlPlexusConfigurationWriter.java       | 10 ++--------
 .../org/apache/maven/plugins/antrun/MavenLogger.java     |  1 +
 9 files changed, 22 insertions(+), 31 deletions(-)

diff --git a/pom.xml b/pom.xml
index 4b17701..50ff164 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,7 @@ under the License.
     <artifactId>maven-plugins</artifactId>
     <groupId>org.apache.maven.plugins</groupId>
     <version>33</version>
-    <relativePath>../../pom/maven/maven-plugins/pom.xml</relativePath>
+    <relativePath/>
   </parent>
 
   <artifactId>maven-antrun-plugin</artifactId>
@@ -63,6 +63,7 @@ under the License.
 
   <properties>
     <mavenVersion>3.0</mavenVersion>
+    <javaVersion>7</javaVersion>
   </properties>
 
   <dependencies>
diff --git a/src/main/java/org/apache/maven/ant/tasks/AttachArtifactTask.java b/src/main/java/org/apache/maven/ant/tasks/AttachArtifactTask.java
index ffb302e..18afaa4 100644
--- a/src/main/java/org/apache/maven/ant/tasks/AttachArtifactTask.java
+++ b/src/main/java/org/apache/maven/ant/tasks/AttachArtifactTask.java
@@ -63,6 +63,7 @@ public class AttachArtifactTask
     private String type;
 
     /** {@inheritDoc} */
+    @Override
     public void execute()
     {
         if ( file == null )
diff --git a/src/main/java/org/apache/maven/ant/tasks/DependencyFilesetsTask.java b/src/main/java/org/apache/maven/ant/tasks/DependencyFilesetsTask.java
index e2dab17..01ed138 100644
--- a/src/main/java/org/apache/maven/ant/tasks/DependencyFilesetsTask.java
+++ b/src/main/java/org/apache/maven/ant/tasks/DependencyFilesetsTask.java
@@ -99,6 +99,7 @@ public class DependencyFilesetsTask
     }
 
     /** {@inheritDoc} */
+    @Override
     public void execute()
     {
         if ( this.getProject().getReference( mavenProjectId ) == null )
@@ -241,7 +242,7 @@ public class DependencyFilesetsTask
             filter.add( new TypesArtifactFilter( getTypes() ) );
         }
 
-        Set<Artifact> artifactsResult = new LinkedHashSet<Artifact>();
+        Set<Artifact> artifactsResult = new LinkedHashSet<>();
         for ( Artifact artifact : artifacts )
         {
             if ( filter.include( artifact ) )
diff --git a/src/main/java/org/apache/maven/ant/tasks/support/SpecificScopesArtifactFilter.java b/src/main/java/org/apache/maven/ant/tasks/support/SpecificScopesArtifactFilter.java
index e52cb56..5c460ca 100644
--- a/src/main/java/org/apache/maven/ant/tasks/support/SpecificScopesArtifactFilter.java
+++ b/src/main/java/org/apache/maven/ant/tasks/support/SpecificScopesArtifactFilter.java
@@ -20,7 +20,6 @@ package org.apache.maven.ant.tasks.support;
  */
 
 import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.DefaultArtifact;
 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
 
 /**
@@ -53,23 +52,23 @@ public class SpecificScopesArtifactFilter
 
         for ( String aScopeList : scopeList )
         {
-            if ( aScopeList.trim().equals( DefaultArtifact.SCOPE_COMPILE ) )
+            if ( aScopeList.trim().equals( Artifact.SCOPE_COMPILE ) )
             {
                 compileScope = true;
             }
-            else if ( aScopeList.trim().equals( DefaultArtifact.SCOPE_PROVIDED ) )
+            else if ( aScopeList.trim().equals( Artifact.SCOPE_PROVIDED ) )
             {
                 providedScope = true;
             }
-            else if ( aScopeList.trim().equals( DefaultArtifact.SCOPE_RUNTIME ) )
+            else if ( aScopeList.trim().equals( Artifact.SCOPE_RUNTIME ) )
             {
                 runtimeScope = true;
             }
-            else if ( aScopeList.trim().equals( DefaultArtifact.SCOPE_SYSTEM ) )
+            else if ( aScopeList.trim().equals( Artifact.SCOPE_SYSTEM ) )
             {
                 systemScope = true;
             }
-            else if ( aScopeList.trim().equals( DefaultArtifact.SCOPE_TEST ) )
+            else if ( aScopeList.trim().equals( Artifact.SCOPE_TEST ) )
             {
                 testScope = true;
             }
@@ -77,6 +76,7 @@ public class SpecificScopesArtifactFilter
     }
 
     /** {@inheritDoc} */
+    @Override
     public boolean include( Artifact artifact )
     {
         if ( Artifact.SCOPE_COMPILE.equals( artifact.getScope() ) )
diff --git a/src/main/java/org/apache/maven/ant/tasks/support/TypesArtifactFilter.java b/src/main/java/org/apache/maven/ant/tasks/support/TypesArtifactFilter.java
index 8adc4c7..bd12865 100644
--- a/src/main/java/org/apache/maven/ant/tasks/support/TypesArtifactFilter.java
+++ b/src/main/java/org/apache/maven/ant/tasks/support/TypesArtifactFilter.java
@@ -31,7 +31,7 @@ import java.util.List;
 public class TypesArtifactFilter
     implements ArtifactFilter
 {
-    private List<String> types = new ArrayList<String>();
+    private List<String> types = new ArrayList<>();
 
     /**
      * Accepts a comma separated list of types
@@ -50,6 +50,7 @@ public class TypesArtifactFilter
     }
 
     /** {@inheritDoc} */
+    @Override
     public boolean include( Artifact artifact )
     {
         String artifactType = artifact.getType();
diff --git a/src/main/java/org/apache/maven/ant/tasks/support/VersionMapper.java b/src/main/java/org/apache/maven/ant/tasks/support/VersionMapper.java
index 73577ec..c3fe433 100644
--- a/src/main/java/org/apache/maven/ant/tasks/support/VersionMapper.java
+++ b/src/main/java/org/apache/maven/ant/tasks/support/VersionMapper.java
@@ -41,6 +41,7 @@ public class VersionMapper
     private String to;
 
     /** {@inheritDoc} */
+    @Override
     public String[] mapFileName( String sourceFileName )
     {
         String originalFileName = new File( sourceFileName ).getName();
@@ -68,6 +69,7 @@ public class VersionMapper
      * separator, as used by dependencies task when setting <code>versionsId</code> property value.
      * @param from The string from which we set.
      */
+    @Override
     public void setFrom( String from )
     {
         String[] split = StringUtils.split( from, File.pathSeparator );
@@ -80,12 +82,14 @@ public class VersionMapper
      * By default, only filename is changed, but if this attribute is set to <code>flatten</code>, directory is removed.
      * @param to {@link #to}
      */
+    @Override
     public void setTo( String to )
     {
         this.to = to;
     }
 
     /** {@inheritDoc} */
+    @Override
     public int compare( String s1, String s2 )
     {
         int lengthDiff = s2.length() - s1.length();
diff --git a/src/main/java/org/apache/maven/plugins/antrun/AntRunMojo.java b/src/main/java/org/apache/maven/plugins/antrun/AntRunMojo.java
index 3163e43..0dc68ac 100644
--- a/src/main/java/org/apache/maven/plugins/antrun/AntRunMojo.java
+++ b/src/main/java/org/apache/maven/plugins/antrun/AntRunMojo.java
@@ -50,7 +50,6 @@ import org.apache.tools.ant.ProjectHelper;
 import org.apache.tools.ant.taskdefs.Typedef;
 import org.apache.tools.ant.types.Path;
 import org.codehaus.plexus.configuration.PlexusConfiguration;
-import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.StringUtils;
 
@@ -393,7 +392,7 @@ public class AntRunMojo
             return new Path( antProject );
         }
 
-        List<String> list = new ArrayList<String>( artifacts.size() );
+        List<String> list = new ArrayList<>( artifacts.size() );
         for ( Artifact a : artifacts )
         {
             File file = a.getFile();
@@ -557,11 +556,8 @@ public class AntRunMojo
             return null;
         }
 
-        LineNumberReader reader = null;
-        try
+        try ( LineNumberReader reader = new LineNumberReader( ReaderFactory.newXmlReader( antFile ) ) )
         {
-            reader = new LineNumberReader( ReaderFactory.newXmlReader( antFile ) );
-
             for ( String line = reader.readLine(); line != null; line = reader.readLine() )
             {
                 if ( reader.getLineNumber() == buildException.getLocation().getLineNumber() )
@@ -571,18 +567,10 @@ public class AntRunMojo
 
                 }
             }
-
-            reader.close();
-            reader = null;
         }
         catch ( Exception e )
         {
             getLog().debug( e.getMessage(), e );
-            return null;
-        }
-        finally
-        {
-            IOUtil.close( reader );
         }
 
         return null;
diff --git a/src/main/java/org/apache/maven/plugins/antrun/AntrunXmlPlexusConfigurationWriter.java b/src/main/java/org/apache/maven/plugins/antrun/AntrunXmlPlexusConfigurationWriter.java
index 1b3b1c2..aee667e 100644
--- a/src/main/java/org/apache/maven/plugins/antrun/AntrunXmlPlexusConfigurationWriter.java
+++ b/src/main/java/org/apache/maven/plugins/antrun/AntrunXmlPlexusConfigurationWriter.java
@@ -20,7 +20,6 @@ package org.apache.maven.plugins.antrun;
  */
 
 import org.codehaus.plexus.configuration.PlexusConfiguration;
-import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.xml.Xpp3DomUtils;
 import org.codehaus.plexus.util.xml.pull.MXSerializer;
 import org.codehaus.plexus.util.xml.pull.XmlSerializer;
@@ -40,7 +39,7 @@ class AntrunXmlPlexusConfigurationWriter
 {
 
     private static final Set<String> EXCLUDED_ATTRIBUTES =
-        new HashSet<String>( Arrays.asList( Xpp3DomUtils.CHILDREN_COMBINATION_MODE_ATTRIBUTE,
+        new HashSet<>( Arrays.asList( Xpp3DomUtils.CHILDREN_COMBINATION_MODE_ATTRIBUTE,
                                             Xpp3DomUtils.SELF_COMBINATION_MODE_ATTRIBUTE ) );
 
     /**
@@ -57,8 +56,7 @@ class AntrunXmlPlexusConfigurationWriter
         serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator",
                                 System.getProperty( "line.separator" ) );
         serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
-        BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream( file ) );
-        try
+        try ( BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream( file ) ) )
         {
             serializer.setOutput( bos, AntRunMojo.UTF_8 );
             serializer.startDocument( AntRunMojo.UTF_8, null );
@@ -73,10 +71,6 @@ class AntrunXmlPlexusConfigurationWriter
             serializer.endTag( null, "project" );
             serializer.endDocument();
         }
-        finally
-        {
-            IOUtil.close( bos );
-        }
     }
 
     private void write( PlexusConfiguration c, XmlSerializer serializer )
diff --git a/src/main/java/org/apache/maven/plugins/antrun/MavenLogger.java b/src/main/java/org/apache/maven/plugins/antrun/MavenLogger.java
index 293b116..ceccd43 100644
--- a/src/main/java/org/apache/maven/plugins/antrun/MavenLogger.java
+++ b/src/main/java/org/apache/maven/plugins/antrun/MavenLogger.java
@@ -39,6 +39,7 @@ public class MavenLogger
         this.log = log;
     }
 
+    @Override
     protected void printMessage( final String message, final PrintStream stream, final int priority )
     {
         switch ( priority )