[maven-plugin-tools] branch MPLUGIN-340 created (now 7517a07)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[maven-plugin-tools] branch MPLUGIN-340 created (now 7517a07)

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

slachiewicz pushed a change to branch MPLUGIN-340
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git.


      at 7517a07  [MPLUGIN-340] Upgrade Apache Ant to 1.9.15

This branch includes the following new commits:

     new c998b78   [MPLUGIN-353] Use Java 7 APIs and language features (part 2)
     new 7517a07  [MPLUGIN-340] Upgrade Apache Ant to 1.9.15

The 2 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-plugin-tools] 01/02: [MPLUGIN-353] Use Java 7 APIs and language features (part 2)

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

slachiewicz pushed a commit to branch MPLUGIN-340
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git

commit c998b78a7f93877822d6fafc0ea1ec4185385fed
Author: Sylwester Lachiewicz <[hidden email]>
AuthorDate: Thu Oct 3 22:45:41 2019 +0200

     [MPLUGIN-353] Use Java 7 APIs and language features (part 2)
---
 .../maven/plugin/plugin/AbstractGeneratorMojo.java | 11 ++--
 .../apache/maven/plugin/plugin/PluginReport.java   | 23 ++++----
 .../descriptor/MNG6109PluginDescriptorBuilder.java |  2 +-
 .../JavaAnnotationsMojoDescriptorExtractor.java    | 26 ++++-----
 .../datamodel/ParameterAnnotationContent.java      | 20 ++-----
 .../scanner/DefaultMojoAnnotationsScanner.java     |  2 +-
 .../scanner/MojoAnnotationsScannerRequest.java     |  4 +-
 .../scanner/visitors/MojoClassVisitor.java         |  2 +-
 .../plugin/extractor/annotations/FooMojo.java      |  1 -
 .../annotations/TestAnnotationsReader.java         |  2 +-
 .../AbstractScriptedMojoDescriptorExtractor.java   |  2 -
 .../plugin/scanner/DefaultMojoScannerTest.java     |  9 +---
 .../maven/tools/plugin/util/stubs/MojoStub.java    | 62 ----------------------
 .../tools/plugin/generator/GeneratorUtils.java     | 62 ++++------------------
 .../generator/PluginDescriptorGenerator.java       |  8 +--
 .../plugin/generator/PluginXdocGenerator.java      |  2 +-
 .../generator/AbstractGeneratorTestCase.java       |  2 +-
 .../generator/PluginDescriptorGeneratorTest.java   |  6 +--
 .../JavaJavadocMojoDescriptorExtractor.java        | 10 ++--
 .../extractor/ant/AntMojoDescriptorExtractor.java  |  2 -
 .../BeanshellMojoDescriptorExtractor.java          |  2 +-
 .../apache/maven/script/ant/AntMojoWrapper.java    |  1 +
 .../apache/maven/script/ant/AntPropertyHelper.java |  2 +-
 23 files changed, 58 insertions(+), 205 deletions(-)

diff --git a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
index 849ea2e..264a16d 100644
--- a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
+++ b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
@@ -41,7 +41,7 @@ import org.codehaus.plexus.component.repository.ComponentDependency;
 import org.codehaus.plexus.util.ReaderFactory;
 
 import java.io.File;
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
@@ -167,7 +167,7 @@ public abstract class AbstractGeneratorMojo
      * @since 3.3
      */
     @Parameter
-    protected List<String> packagingTypes = Arrays.asList( "maven-plugin" );
+    protected List<String> packagingTypes = Collections.singletonList( "maven-plugin" );
 
     /**
      * @return the output directory where files will be generated.
@@ -267,12 +267,7 @@ public abstract class AbstractGeneratorMojo
         {
             throw new MojoExecutionException( "Error writing plugin descriptor", e );
         }
-        catch ( InvalidPluginDescriptorException e )
-        {
-            throw new MojoExecutionException( "Error extracting plugin descriptor: \'" + e.getLocalizedMessage() + "\'",
-                                              e );
-        }
-        catch ( ExtractionException e )
+        catch ( InvalidPluginDescriptorException | ExtractionException e )
         {
             throw new MojoExecutionException( "Error extracting plugin descriptor: \'" + e.getLocalizedMessage() + "\'",
                                               e );
diff --git a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java
index 886951f..d1cdd6b 100644
--- a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java
+++ b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java
@@ -487,7 +487,7 @@ public class PluginReport
          * {@inheritDoc}
          */
         @Override
-        @SuppressWarnings( { "unchecked", "rawtypes" } )
+        @SuppressWarnings( { "rawtypes" } )
         public void renderBody()
         {
             startSection( getTitle() );
@@ -502,10 +502,8 @@ public class PluginReport
             paragraph( getBundle( locale ).getString( "report.plugin.goals.intro" ) );
 
             boolean hasMavenReport = false;
-            for ( Iterator<MojoDescriptor> i = pluginDescriptor.getMojos().iterator(); i.hasNext(); )
+            for ( MojoDescriptor mojo : pluginDescriptor.getMojos() )
             {
-                MojoDescriptor mojo = i.next();
-
                 if ( GeneratorUtils.isMavenReport( mojo.getImplementation(), project ) )
                 {
                     hasMavenReport = true;
@@ -526,8 +524,7 @@ public class PluginReport
                 tableHeader( new String[]{ goalColumnName, descriptionColumnName } );
             }
 
-            List<MojoDescriptor> mojos = new ArrayList<>();
-            mojos.addAll( pluginDescriptor.getMojos() );
+            List<MojoDescriptor> mojos = new ArrayList<>( pluginDescriptor.getMojos() );
             PluginUtils.sortMojos( mojos );
             for ( MojoDescriptor mojo : mojos )
             {
@@ -654,9 +651,8 @@ public class PluginReport
             sb.append( "<project>" ).append( '\n' );
             sb.append( "  ..." ).append( '\n' );
             sb.append( "  <build>" ).append( '\n' );
-            sb.append(
-                "    <!-- " + getBundle( locale ).getString( "report.plugin.usage.pluginManagement" ) + " -->" ).append(
-                '\n' );
+            sb.append( "    <!-- " ).append( getBundle( locale ).getString( "report.plugin.usage.pluginManagement" ) )
+                    .append( " -->" ).append( '\n' );
             sb.append( "    <pluginManagement>" ).append( '\n' );
             sb.append( "      <plugins>" ).append( '\n' );
             sb.append( "        <plugin>" ).append( '\n' );
@@ -670,8 +666,8 @@ public class PluginReport
             sb.append( "        ..." ).append( '\n' );
             sb.append( "      </plugins>" ).append( '\n' );
             sb.append( "    </pluginManagement>" ).append( '\n' );
-            sb.append( "    <!-- " + getBundle( locale ).getString( "report.plugin.usage.plugins" ) + " -->" ).append(
-                '\n' );
+            sb.append( "    <!-- " ).append( getBundle( locale ).getString( "report.plugin.usage.plugins" ) )
+                    .append( " -->" ).append( '\n' );
             sb.append( "    <plugins>" ).append( '\n' );
             sb.append( "      <plugin>" ).append( '\n' );
             sb.append( "        <groupId>" ).append( pluginDescriptor.getGroupId() ).append( "</groupId>" ).append(
@@ -688,9 +684,8 @@ public class PluginReport
             if ( hasMavenReport )
             {
                 sb.append( "  ..." ).append( '\n' );
-                sb.append(
-                    "  <!-- " + getBundle( locale ).getString( "report.plugin.usage.reporting" ) + " -->" ).append(
-                    '\n' );
+                sb.append( "  <!-- " ).append( getBundle( locale ).getString( "report.plugin.usage.reporting" ) )
+                        .append( " -->" ).append( '\n' );
                 sb.append( "  <reporting>" ).append( '\n' );
                 sb.append( "    <plugins>" ).append( '\n' );
                 sb.append( "      <plugin>" ).append( '\n' );
diff --git a/maven-plugin-plugin/src/main/java/org/apache/maven/plugins/plugin/descriptor/MNG6109PluginDescriptorBuilder.java b/maven-plugin-plugin/src/main/java/org/apache/maven/plugins/plugin/descriptor/MNG6109PluginDescriptorBuilder.java
index 0974302..e0a035d 100644
--- a/maven-plugin-plugin/src/main/java/org/apache/maven/plugins/plugin/descriptor/MNG6109PluginDescriptorBuilder.java
+++ b/maven-plugin-plugin/src/main/java/org/apache/maven/plugins/plugin/descriptor/MNG6109PluginDescriptorBuilder.java
@@ -51,7 +51,7 @@ public class MNG6109PluginDescriptorBuilder extends PluginDescriptorBuilder
         for ( PlexusConfiguration d : parameterConfigurations )
         {
             String parameterName = d.getChild( "name" ).getValue();
-            Parameter pd = (Parameter) mojoDescriptor.getParameterMap().get( parameterName );
+            Parameter pd = mojoDescriptor.getParameterMap().get( parameterName );
             
             String parameterSince = d.getChild( "since" ).getValue();
             pd.setSince( parameterSince );
diff --git a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/JavaAnnotationsMojoDescriptorExtractor.java b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/JavaAnnotationsMojoDescriptorExtractor.java
index 7b9afe7..39dc319 100644
--- a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/JavaAnnotationsMojoDescriptorExtractor.java
+++ b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/JavaAnnotationsMojoDescriptorExtractor.java
@@ -24,13 +24,13 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 import java.util.TreeMap;
 import java.util.TreeSet;
@@ -115,7 +115,7 @@ public class JavaAnnotationsMojoDescriptorExtractor
         MojoAnnotationsScannerRequest mojoAnnotationsScannerRequest = new MojoAnnotationsScannerRequest();
 
         File output = new File( request.getProject().getBuild().getOutputDirectory() );
-        mojoAnnotationsScannerRequest.setClassesDirectories( Arrays.asList( output ) );
+        mojoAnnotationsScannerRequest.setClassesDirectories( Collections.singletonList( output ) );
 
         mojoAnnotationsScannerRequest.setDependencies( request.getDependencies() );
 
@@ -137,7 +137,7 @@ public class JavaAnnotationsMojoDescriptorExtractor
 
         for ( MojoAnnotatedClass mojoAnnotatedClass : mojoAnnotatedClasses )
         {
-            if ( StringUtils.equals( mojoAnnotatedClass.getArtifact().getArtifactId(),
+            if ( Objects.equals( mojoAnnotatedClass.getArtifact().getArtifactId(),
                                      request.getProject().getArtifact().getArtifactId() ) )
             {
                 continue;
@@ -162,7 +162,7 @@ public class JavaAnnotationsMojoDescriptorExtractor
             }
         }
 
-        Map<String, JavaClass> javaClassesMap = new HashMap<String, JavaClass>();
+        Map<String, JavaClass> javaClassesMap = new HashMap<>();
 
         // try to get artifact with sources classifier, extract somewhere then scan for @since, @deprecated
         for ( Artifact artifact : externalArtifacts )
@@ -224,10 +224,10 @@ public class JavaAnnotationsMojoDescriptorExtractor
             unArchiver.setDestDirectory( extractDirectory );
             unArchiver.extract();
 
-            return discoverClasses( request.getEncoding(), Arrays.asList( extractDirectory ),
+            return discoverClasses( request.getEncoding(), Collections.singletonList( extractDirectory ),
                                     request.getDependencies() );
         }
-        catch ( ArtifactResolutionException e )
+        catch ( ArtifactResolutionException | NoSuchArchiverException e )
         {
             throw new ExtractionException( e.getMessage(), e );
         }
@@ -240,10 +240,6 @@ public class JavaAnnotationsMojoDescriptorExtractor
                     + artifact.getVersion() + ". Some javadoc tags (@since, @deprecated and comments) won't be used" );
             return Collections.emptyMap();
         }
-        catch ( NoSuchArchiverException e )
-        {
-            throw new ExtractionException( e.getMessage(), e );
-        }
     }
 
     /**
@@ -375,7 +371,7 @@ public class JavaAnnotationsMojoDescriptorExtractor
     private Map<String, JavaField> extractFieldParameterTags( JavaClass javaClass,
                                                               Map<String, JavaClass> javaClassesMap )
     {
-        Map<String, JavaField> rawParams = new TreeMap<String, com.thoughtworks.qdox.model.JavaField>();
+        Map<String, JavaField> rawParams = new TreeMap<>();
 
         // we have to add the parent fields first, so that they will be overwritten by the local fields if
         // that actually happens...
@@ -413,12 +409,11 @@ public class JavaAnnotationsMojoDescriptorExtractor
         return discoverClasses( request.getEncoding(), request.getProject() );
     }
 
-    @SuppressWarnings( "unchecked" )
     protected Map<String, JavaClass> discoverClasses( final String encoding, final MavenProject project )
     {
         List<File> sources = new ArrayList<>();
 
-        for ( String source : (List<String>) project.getCompileSourceRoots() )
+        for ( String source : project.getCompileSourceRoots() )
         {
             sources.add( new File( source ) );
         }
@@ -725,11 +720,10 @@ public class JavaAnnotationsMojoDescriptorExtractor
         {
             return null;
         }
-        @SuppressWarnings( "unchecked" ) Collection<MavenProject> mavenProjects =
-            project.getProjectReferences().values();
+        Collection<MavenProject> mavenProjects = project.getProjectReferences().values();
         for ( MavenProject mavenProject : mavenProjects )
         {
-            if ( StringUtils.equals( mavenProject.getId(), artifact.getId() ) )
+            if ( Objects.equals( mavenProject.getId(), artifact.getId() ) )
             {
                 return mavenProject;
             }
diff --git a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/datamodel/ParameterAnnotationContent.java b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/datamodel/ParameterAnnotationContent.java
index 919aaa4..84ccd99 100644
--- a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/datamodel/ParameterAnnotationContent.java
+++ b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/datamodel/ParameterAnnotationContent.java
@@ -22,6 +22,7 @@ package org.apache.maven.tools.plugin.extractor.annotations.datamodel;
 import org.apache.maven.plugins.annotations.Parameter;
 
 import java.lang.annotation.Annotation;
+import java.util.Objects;
 
 /**
  * @author Olivier Lamy
@@ -182,31 +183,20 @@ public class ParameterAnnotationContent
             return false;
         }
 
-        if ( alias != null ? !alias.equals( that.alias ) : that.alias != null )
+        if ( !Objects.equals( alias, that.alias ) )
         {
             return false;
         }
-        if ( defaultValue != null ? !defaultValue.equals( that.defaultValue ) : that.defaultValue != null )
+        if ( !Objects.equals( defaultValue, that.defaultValue ) )
         {
             return false;
         }
-        if ( property != null ? !property.equals( that.property ) : that.property != null )
-        {
-            return false;
-        }
-
-        return true;
+        return property != null ? property.equals( that.property ) : that.property == null;
     }
 
     @Override
     public int hashCode()
     {
-        int result = alias != null ? alias.hashCode() : 0;
-        result = 31 * result + ( getFieldName() != null ? getFieldName().hashCode() : 0 );
-        result = 31 * result + ( property != null ? property.hashCode() : 0 );
-        result = 31 * result + ( defaultValue != null ? defaultValue.hashCode() : 0 );
-        result = 31 * result + ( required ? 1 : 0 );
-        result = 31 * result + ( readonly ? 1 : 0 );
-        return result;
+        return Objects.hash( alias, getFieldName(), property, defaultValue, required, readonly );
     }
 }
diff --git a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/DefaultMojoAnnotationsScanner.java b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/DefaultMojoAnnotationsScanner.java
index 2eab391..d7496d2 100644
--- a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/DefaultMojoAnnotationsScanner.java
+++ b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/DefaultMojoAnnotationsScanner.java
@@ -174,7 +174,7 @@ public class DefaultMojoAnnotationsScanner
         scanner.addDefaultExcludes();
         if ( includePatterns != null )
         {
-            scanner.setIncludes( includePatterns.toArray( new String[includePatterns.size()] ) );
+            scanner.setIncludes( includePatterns.toArray( new String[0] ) );
         }
         scanner.scan();
         String[] classFiles = scanner.getIncludedFiles();
diff --git a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/MojoAnnotationsScannerRequest.java b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/MojoAnnotationsScannerRequest.java
index 5a27cbd..1a1c04b 100644
--- a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/MojoAnnotationsScannerRequest.java
+++ b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/MojoAnnotationsScannerRequest.java
@@ -24,7 +24,7 @@ import org.apache.maven.project.MavenProject;
 
 import java.io.File;
 import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -39,7 +39,7 @@ public class MojoAnnotationsScannerRequest
 
     private Set<Artifact> dependencies = new HashSet<>();
 
-    private List<String> includePatterns = Arrays.asList( "**/*.class" );
+    private List<String> includePatterns = Collections.singletonList( "**/*.class" );
 
     private List<File> sourceDirectories = new ArrayList<>();
 
diff --git a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/visitors/MojoClassVisitor.java b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/visitors/MojoClassVisitor.java
index 2f3cf30..5b18fab 100644
--- a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/visitors/MojoClassVisitor.java
+++ b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/visitors/MojoClassVisitor.java
@@ -96,7 +96,7 @@ public class MojoClassVisitor
     {
         String annotationClassName = annotation.getName();
 
-        List<MojoFieldVisitor> mojoFieldVisitors = new ArrayList<MojoFieldVisitor>();
+        List<MojoFieldVisitor> mojoFieldVisitors = new ArrayList<>();
 
         for ( MojoFieldVisitor mojoFieldVisitor : this.fieldVisitors )
         {
diff --git a/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooMojo.java b/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooMojo.java
index 95b339d..0225b30 100644
--- a/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooMojo.java
+++ b/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooMojo.java
@@ -20,7 +20,6 @@ package org.apache.maven.tools.plugin.extractor.annotations;
  */
 
 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
-import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugins.annotations.Component;
diff --git a/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/TestAnnotationsReader.java b/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/TestAnnotationsReader.java
index b7702df..ab4552e 100644
--- a/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/TestAnnotationsReader.java
+++ b/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/TestAnnotationsReader.java
@@ -50,7 +50,7 @@ public class TestAnnotationsReader
 
         MojoAnnotationsScannerRequest request = new MojoAnnotationsScannerRequest();
         request.setClassesDirectories( Collections.singletonList( new File( getBasedir(), "target/test-classes" ) ) );
-        request.setIncludePatterns( Arrays.asList( "**/FooMojo.class" ) );
+        request.setIncludePatterns( Collections.singletonList( "**/FooMojo.class" ) );
         request.setProject( new MavenProject() );
 
         Map<String, MojoAnnotatedClass> mojoAnnotatedClasses = mojoAnnotationsScanner.scan( request );
diff --git a/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/extractor/AbstractScriptedMojoDescriptorExtractor.java b/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/extractor/AbstractScriptedMojoDescriptorExtractor.java
index 8787a08..55a9467 100644
--- a/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/extractor/AbstractScriptedMojoDescriptorExtractor.java
+++ b/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/extractor/AbstractScriptedMojoDescriptorExtractor.java
@@ -53,14 +53,12 @@ public abstract class AbstractScriptedMojoDescriptorExtractor
         
         MavenProject project = request.getProject();
 
-        @SuppressWarnings( "unchecked" )
         Map<String, Set<File>> scriptFilesKeyedByBasedir =
             gatherFilesByBasedir( project.getBasedir(), project.getScriptSourceRoots(), scriptExtension, request );
 
         List<MojoDescriptor> mojoDescriptors;
         if ( !StringUtils.isEmpty( metadataExtension ) )
         {
-            @SuppressWarnings( "unchecked" )
             Map<String, Set<File>> metadataFilesKeyedByBasedir =
                 gatherFilesByBasedir( project.getBasedir(), project.getScriptSourceRoots(), metadataExtension,
                                       request );
diff --git a/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/scanner/DefaultMojoScannerTest.java b/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/scanner/DefaultMojoScannerTest.java
index eeb1031..f65bc1c 100644
--- a/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/scanner/DefaultMojoScannerTest.java
+++ b/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/scanner/DefaultMojoScannerTest.java
@@ -52,10 +52,6 @@ public class DefaultMojoScannerTest
 {
     private Map<String, MojoDescriptorExtractor> extractors;
 
-    private Build build;
-
-    private Model model;
-
     private MojoScanner scanner;
 
     private MavenProject project;
@@ -70,10 +66,10 @@ public class DefaultMojoScannerTest
 
         scanner = new DefaultMojoScanner( extractors );
 
-        build = new Build();
+        Build build = new Build();
         build.setSourceDirectory( "testdir" );
 
-        model = new Model();
+        Model model = new Model();
         model.setBuild( build );
 
         project = new MavenProject( model );
@@ -185,7 +181,6 @@ public class DefaultMojoScannerTest
     protected void checkResult( PluginDescriptor pluginDescriptor, Collection<String> expectedGoals )
     {
         Set<String> remainingGoals = new HashSet<>( expectedGoals );
-        @SuppressWarnings( "unchecked" )
         List<MojoDescriptor> descriptors = pluginDescriptor.getMojos();
 
         if ( descriptors == null )
diff --git a/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/stubs/MojoStub.java b/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/stubs/MojoStub.java
index 00abbae..85a5906 100644
--- a/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/stubs/MojoStub.java
+++ b/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/stubs/MojoStub.java
@@ -19,12 +19,7 @@ package org.apache.maven.tools.plugin.util.stubs;
  * under the License.
  */
 
-import java.util.Map;
-
 import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugin.logging.Log;
 
 /**
  * Dummy Mojo.
@@ -35,64 +30,7 @@ public class MojoStub
     extends AbstractMojo
 {
     /** {@inheritDoc} */
-    public Log getLog()
-    {
-        return super.getLog();
-    }
-
-    /** {@inheritDoc} */
-    public Map getPluginContext()
-    {
-        return super.getPluginContext();
-    }
-
-    /** {@inheritDoc} */
-    public void setLog( Log log )
-    {
-        super.setLog( log );
-    }
-
-    /** {@inheritDoc} */
-    public void setPluginContext( Map pluginContext )
-    {
-        super.setPluginContext( pluginContext );
-    }
-
-    /** {@inheritDoc} */
-    protected Object clone()
-        throws CloneNotSupportedException
-    {
-        return super.clone();
-    }
-
-    /** {@inheritDoc} */
-    public boolean equals( Object obj )
-    {
-        return super.equals( obj );
-    }
-
-    /** {@inheritDoc} */
-    protected void finalize()
-        throws Throwable
-    {
-        super.finalize();
-    }
-
-    /** {@inheritDoc} */
-    public int hashCode()
-    {
-        return super.hashCode();
-    }
-
-    /** {@inheritDoc} */
-    public String toString()
-    {
-        return super.toString();
-    }
-
-    /** {@inheritDoc} */
     public void execute()
-        throws MojoExecutionException, MojoFailureException
     {
 
     }
diff --git a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/GeneratorUtils.java b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/GeneratorUtils.java
index f829d60..a1703d2 100644
--- a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/GeneratorUtils.java
+++ b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/GeneratorUtils.java
@@ -75,7 +75,6 @@ public final class GeneratorUtils
     {
         w.startElement( "dependencies" );
 
-        @SuppressWarnings( "unchecked" )
         List<ComponentDependency> deps = pluginDescriptor.getDependencies();
         for ( ComponentDependency dep : deps )
         {
@@ -143,48 +142,6 @@ public final class GeneratorUtils
     }
 
     /**
-     * Returns a literal replacement <code>String</code> for the specified <code>String</code>. This method
-     * produces a <code>String</code> that will work as a literal replacement <code>s</code> in the
-     * <code>appendReplacement</code> method of the {@link Matcher} class. The <code>String</code> produced will
-     * match the sequence of characters in <code>s</code> treated as a literal sequence. Slashes ('\') and dollar
-     * signs ('$') will be given no special meaning. TODO: copied from Matcher class of Java 1.5, remove once target
-     * platform can be upgraded
-     *
-     * @see <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Matcher.html">java.util.regex.Matcher</a>
-     * @param s The string to be literalized
-     * @return A literal string replacement
-     */
-    private static String quoteReplacement( String s )
-    {
-        if ( ( s.indexOf( '\\' ) == -1 ) && ( s.indexOf( '$' ) == -1 ) )
-        {
-            return s;
-        }
-
-        StringBuilder sb = new StringBuilder();
-        for ( int i = 0; i < s.length(); i++ )
-        {
-            char c = s.charAt( i );
-            if ( c == '\\' )
-            {
-                sb.append( '\\' );
-                sb.append( '\\' );
-            }
-            else if ( c == '$' )
-            {
-                sb.append( '\\' );
-                sb.append( '$' );
-            }
-            else
-            {
-                sb.append( c );
-            }
-        }
-
-        return sb.toString();
-    }
-
-    /**
      * Decodes javadoc inline tags into equivalent HTML tags. For instance, the inline tag "{@code <A&B>}" should be
      * rendered as "<code>&lt;A&amp;B&gt;</code>".
      *
@@ -249,7 +206,7 @@ public final class GeneratorUtils
                     text = "<code>" + text + "</code>";
                 }
             }
-            matcher.appendReplacement( decoded, ( text != null ) ? quoteReplacement( text ) : "" );
+            matcher.appendReplacement( decoded, ( text != null ) ? Matcher.quoteReplacement( text ) : "" );
         }
         matcher.appendTail( decoded );
 
@@ -358,7 +315,7 @@ public final class GeneratorUtils
         /**
          * Holds the index of the current item in a numbered list.
          */
-        class Counter
+        static class Counter
         {
             int value;
         }
@@ -618,17 +575,17 @@ public final class GeneratorUtils
                 String name = impl.substring( 0, impl.lastIndexOf( '.' ) );
                 if ( packageNames.get( name ) != null )
                 {
-                    int next = ( packageNames.get( name ) ).intValue() + 1;
-                    packageNames.put( name,  Integer.valueOf( next ) );
+                    int next = packageNames.get( name ) + 1;
+                    packageNames.put( name, next );
                 }
                 else
                 {
-                    packageNames.put( name, Integer.valueOf( 1 ) );
+                    packageNames.put( name, 1 );
                 }
             }
             else
             {
-                packageNames.put( "", Integer.valueOf( 1 ) );
+                packageNames.put( "", 1 );
             }
         }
 
@@ -636,7 +593,7 @@ public final class GeneratorUtils
         int max = 0;
         for ( Map.Entry<String, Integer> entry : packageNames.entrySet() )
         {
-            int value = entry.getValue().intValue();
+            int value = entry.getValue();
             if ( value > max )
             {
                 max = value;
@@ -654,7 +611,6 @@ public final class GeneratorUtils
      * <code>false</code> otherwise.
      * @throws IllegalArgumentException if any
      */
-    @SuppressWarnings( "unchecked" )
     public static boolean isMavenReport( String impl, MavenProject project )
         throws IllegalArgumentException
     {
@@ -685,7 +641,7 @@ public final class GeneratorUtils
             {
                 try
                 {
-                    urls.add( new File( classPathString ).toURL() );
+                    urls.add( new File( classPathString ).toURI().toURL() );
                 }
                 catch ( MalformedURLException e )
                 {
@@ -693,7 +649,7 @@ public final class GeneratorUtils
                 }
             }
 
-            classLoader = new URLClassLoader( urls.toArray( new URL[urls.size()] ), classLoader );
+            classLoader = new URLClassLoader( urls.toArray( new URL[0] ), classLoader );
         }
 
         try
diff --git a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java
index 59f2b7c..363cabc 100644
--- a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java
+++ b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java
@@ -85,11 +85,7 @@ public class PluginDescriptorGenerator
 
             writeDescriptor( f, request, true );
         }
-        catch ( IOException e )
-        {
-            throw new GeneratorException( e.getMessage(), e );
-        }
-        catch ( DuplicateMojoDescriptorException e )
+        catch ( IOException | DuplicateMojoDescriptorException e )
         {
             throw new GeneratorException( e.getMessage(), e );
         }
@@ -154,7 +150,7 @@ public class PluginDescriptorGenerator
 
             if ( pluginDescriptor.getMojos() != null )
             {
-                @SuppressWarnings( "unchecked" ) List<MojoDescriptor> descriptors = pluginDescriptor.getMojos();
+                List<MojoDescriptor> descriptors = pluginDescriptor.getMojos();
 
                 PluginUtils.sortMojos( descriptors );
 
diff --git a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java
index 8d3aefa..bd3f9ee 100644
--- a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java
+++ b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java
@@ -108,7 +108,7 @@ public class PluginXdocGenerator
         {
             if ( request.getPluginDescriptor().getMojos() != null )
             {
-                @SuppressWarnings( "unchecked" ) List<MojoDescriptor> mojos = request.getPluginDescriptor().getMojos();
+                List<MojoDescriptor> mojos = request.getPluginDescriptor().getMojos();
 
                 for ( MojoDescriptor descriptor : mojos )
                 {
diff --git a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java b/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java
index e98b128..5679793 100644
--- a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java
+++ b/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java
@@ -65,7 +65,7 @@ public abstract class AbstractGeneratorTestCase
         mojoDescriptor.setImplementation( "org.apache.maven.tools.plugin.generator.TestMojo" );
         mojoDescriptor.setDependencyResolutionRequired( "compile" );
 
-        List<Parameter> params = new ArrayList<Parameter>();
+        List<Parameter> params = new ArrayList<>();
 
         Parameter param = new Parameter();
         param.setExpression( "${project.build.directory}" );
diff --git a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGeneratorTest.java b/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGeneratorTest.java
index c5f5c9e..11844c7 100644
--- a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGeneratorTest.java
+++ b/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGeneratorTest.java
@@ -53,7 +53,7 @@ public class PluginDescriptorGeneratorTest
 
         assertEquals( 1, pluginDescriptor.getMojos().size() );
 
-        MojoDescriptor mojoDescriptor = (MojoDescriptor) pluginDescriptor.getMojos().get( 0 );
+        MojoDescriptor mojoDescriptor = pluginDescriptor.getMojos().get( 0 );
 
         checkMojo( mojoDescriptor );
 
@@ -81,7 +81,7 @@ public class PluginDescriptorGeneratorTest
         try (PrintWriter pWriter = new PrintWriter( sWriter ); //
              BufferedReader reader = new BufferedReader( ReaderFactory.newXmlReader( pluginDescriptorFile ) ))
         {
-            String line = null;
+            String line;
             while ( ( line = reader.readLine() ) != null )
             {
                 pWriter.println( line );
@@ -103,7 +103,7 @@ public class PluginDescriptorGeneratorTest
         assertNotNull( mojoDescriptor.isDependencyResolutionRequired() );
 
         // check the parameter.
-        checkParameter( (Parameter) mojoDescriptor.getParameters().get( 0 ) );
+        checkParameter( mojoDescriptor.getParameters().get( 0 ) );
     }
 
     private void checkParameter( Parameter parameter )
diff --git a/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaJavadocMojoDescriptorExtractor.java b/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaJavadocMojoDescriptorExtractor.java
index 5b5e493..c13191d 100644
--- a/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaJavadocMojoDescriptorExtractor.java
+++ b/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaJavadocMojoDescriptorExtractor.java
@@ -309,7 +309,7 @@ public class JavaJavadocMojoDescriptorExtractor
 
             if ( StringUtils.isNotEmpty( value ) )
             {
-                defaultValue = Boolean.valueOf( value ).booleanValue();
+                defaultValue = Boolean.valueOf( value );
             }
         }
         return defaultValue;
@@ -334,7 +334,7 @@ public class JavaJavadocMojoDescriptorExtractor
 
             if ( StringUtils.isNotEmpty( value ) )
             {
-                return Boolean.valueOf( value ).booleanValue();
+                return Boolean.valueOf( value );
             }
             else
             {
@@ -552,7 +552,7 @@ public class JavaJavadocMojoDescriptorExtractor
         }
         else
         {
-            rawParams = new TreeMap<String, JavaField>();
+            rawParams = new TreeMap<>();
         }
 
         for ( JavaField field : javaClass.getFields() )
@@ -597,7 +597,6 @@ public class JavaJavadocMojoDescriptorExtractor
      * @param request The plugin request.
      * @return an array of java class
      */
-    @SuppressWarnings( "unchecked" )
     protected Collection<JavaClass> discoverClasses( final PluginToolsRequest request )
     {
         JavaProjectBuilder builder = new JavaProjectBuilder( new SortedClassLibraryBuilder() );
@@ -620,7 +619,7 @@ public class JavaJavadocMojoDescriptorExtractor
         
         MavenProject project = request.getProject();
 
-        for ( String source : (List<String>) project.getCompileSourceRoots() )
+        for ( String source : project.getCompileSourceRoots() )
         {
             builder.addSourceTree( new File( source ) );
         }
@@ -642,7 +641,6 @@ public class JavaJavadocMojoDescriptorExtractor
     protected void validate( MojoDescriptor mojoDescriptor )
         throws InvalidParameterException
     {
-        @SuppressWarnings( "unchecked" )
         List<Parameter> parameters = mojoDescriptor.getParameters();
 
         if ( parameters != null )
diff --git a/maven-script/maven-plugin-tools-ant/src/main/java/org/apache/maven/tools/plugin/extractor/ant/AntMojoDescriptorExtractor.java b/maven-script/maven-plugin-tools-ant/src/main/java/org/apache/maven/tools/plugin/extractor/ant/AntMojoDescriptorExtractor.java
index d0a1e68..c336838 100644
--- a/maven-script/maven-plugin-tools-ant/src/main/java/org/apache/maven/tools/plugin/extractor/ant/AntMojoDescriptorExtractor.java
+++ b/maven-script/maven-plugin-tools-ant/src/main/java/org/apache/maven/tools/plugin/extractor/ant/AntMojoDescriptorExtractor.java
@@ -97,7 +97,6 @@ public class AntMojoDescriptorExtractor
 
                     for ( MojoDescriptor descriptor : mojoDescriptors )
                     {
-                        @SuppressWarnings( "unchecked" )
                         Map<String, ?> paramMap = descriptor.getParameterMap();
 
                         if ( !paramMap.containsKey( "basedir" ) )
@@ -172,7 +171,6 @@ public class AntMojoDescriptorExtractor
                             descriptor.addParameter( param );
                         }
                         
-                        @SuppressWarnings( "unchecked" )
                         List<ComponentRequirement> requirements = descriptor.getRequirements();
                         Map<String, ComponentRequirement> reqMap = new HashMap<>();
 
diff --git a/maven-script/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java b/maven-script/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java
index 9a12df1..d8b00b3 100644
--- a/maven-script/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java
+++ b/maven-script/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java
@@ -71,7 +71,7 @@ public class BeanshellMojoDescriptorExtractor
 
             for ( File scriptFile : metadataFiles )
             {
-                String relativePath = null;
+                String relativePath;
 
                 if ( basedir.endsWith( "/" ) )
                 {
diff --git a/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoWrapper.java b/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoWrapper.java
index 56eba08..4de02e8 100644
--- a/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoWrapper.java
+++ b/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoWrapper.java
@@ -155,6 +155,7 @@ public class AntMojoWrapper
         unconstructedParts.clear();
     }
 
+    @SuppressWarnings( "unchecked" )
     public void setPluginContext( Map pluginContext )
     {
         this.pluginContext = pluginContext;
diff --git a/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntPropertyHelper.java b/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntPropertyHelper.java
index ee6c701..5941013 100644
--- a/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntPropertyHelper.java
+++ b/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntPropertyHelper.java
@@ -45,7 +45,7 @@ public class AntPropertyHelper
     private Log log;
     private ExpressionEvaluator exprEvaluator;
     private MavenProject mavenProject;
-    private Map<String, String> artifactMap = new HashMap<String, String>();
+    private Map<String, String> artifactMap = new HashMap<>();
 
     /**
      * @deprecated use the other constructor

Reply | Threaded
Open this post in threaded view
|

[maven-plugin-tools] 02/02: [MPLUGIN-340] Upgrade Apache Ant to 1.9.15

slachiewicz
In reply to this post by slachiewicz
This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch MPLUGIN-340
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git

commit 7517a07ba548772277319fb676ed0dd66eacf1e3
Author: Sylwester Lachiewicz <[hidden email]>
AuthorDate: Wed Oct 2 20:50:15 2019 +0200

    [MPLUGIN-340] Upgrade Apache Ant to 1.9.15
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index e20532c..27e1e58 100644
--- a/pom.xml
+++ b/pom.xml
@@ -94,7 +94,7 @@
     <javaVersion>7</javaVersion>
     <pluginTestingHarnessVersion>1.3</pluginTestingHarnessVersion>
     <mavenVersion>3.0</mavenVersion>
-    <antVersion>1.7.1</antVersion>
+    <antVersion>1.9.15</antVersion>
     <mavenInvokerPluginVersion>3.0.1</mavenInvokerPluginVersion>
     <maven.site.path>plugin-tools-archives/plugin-tools-LATEST</maven.site.path>
     <asmVersion>9.0</asmVersion>