You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2021/08/22 16:31:57 UTC

[maven-pdf-plugin] branch MPDF-98 created (now 90e59a5)

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

slachiewicz pushed a change to branch MPDF-98
in repository https://gitbox.apache.org/repos/asf/maven-pdf-plugin.git.


      at 90e59a5  [MPDF-98] Require Java 8

This branch includes the following new commits:

     new cfb477c  [MPDF-95] Require Maven 3.1.1
     new 90e59a5  [MPDF-98] Require Java 8

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.


[maven-pdf-plugin] 01/02: [MPDF-95] Require Maven 3.1.1

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch MPDF-98
in repository https://gitbox.apache.org/repos/asf/maven-pdf-plugin.git

commit cfb477ca441f078cea05dae5a3ddd4cf14bfa7b7
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Fri Jun 4 10:25:24 2021 +0200

    [MPDF-95] Require Maven 3.1.1
---
 pom.xml                                            |  69 +++++--
 .../plugins/pdf/DocumentDescriptorReader.java      |   6 +-
 .../maven/plugins/pdf/DocumentModelBuilder.java    |   4 -
 .../java/org/apache/maven/plugins/pdf/PdfMojo.java | 228 ++-------------------
 .../plugins/pdf/DocumentDescriptorReaderTest.java  |   4 +-
 .../plugins/pdf/stubs/DefaultMavenProjectStub.java |  10 +-
 .../pdf/stubs/FilteringMavenProjectStub.java       |  12 +-
 .../plugins/pdf/stubs/ITextMavenProjectStub.java   |   9 +-
 8 files changed, 80 insertions(+), 262 deletions(-)

diff --git a/pom.xml b/pom.xml
index a34bff5..fdad34c 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>34</version>
-    <relativePath>../../pom/maven/maven-plugins/pom.xml</relativePath>
+    <relativePath/>
   </parent>
 
   <artifactId>maven-pdf-plugin</artifactId>
@@ -91,7 +91,7 @@ under the License.
   <properties>
     <doxiaVersion>1.10</doxiaVersion>
     <doxiaSitetoolsVersion>1.10</doxiaSitetoolsVersion>
-    <mavenVersion>2.2.1</mavenVersion>
+    <mavenVersion>3.1.1</mavenVersion>
     <javaVersion>7</javaVersion>
     <project.build.outputTimestamp>2020-04-07T21:04:00Z</project.build.outputTimestamp>
   </properties>
@@ -115,19 +115,20 @@ under the License.
     <dependency>
       <groupId>org.apache.maven.reporting</groupId>
       <artifactId>maven-reporting-exec</artifactId>
-      <version>1.4</version>
+      <version>1.5.1</version>
     </dependency>
   
     <!-- Maven -->
     <dependency>
       <groupId>org.apache.maven</groupId>
-      <artifactId>maven-project</artifactId>
+      <artifactId>maven-core</artifactId>
       <version>${mavenVersion}</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
-      <artifactId>maven-core</artifactId>
+      <artifactId>maven-compat</artifactId>
       <version>${mavenVersion}</version>
+      <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
@@ -140,11 +141,6 @@ under the License.
       <version>${mavenVersion}</version>
     </dependency>
     <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-artifact-manager</artifactId>
-      <version>${mavenVersion}</version>
-    </dependency>
-    <dependency>
       <groupId>org.apache.maven.plugin-tools</groupId>
       <artifactId>maven-plugin-annotations</artifactId>
       <scope>provided</scope>
@@ -160,6 +156,12 @@ under the License.
       <groupId>org.apache.maven.doxia</groupId>
       <artifactId>doxia-sink-api</artifactId>
       <version>${doxiaVersion}</version>
+      <exclusions>
+        <exclusion>
+          <artifactId>plexus-container-default</artifactId>
+          <groupId>org.codehaus.plexus</groupId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.doxia</groupId>
@@ -187,6 +189,12 @@ under the License.
       <groupId>org.apache.maven.doxia</groupId>
       <artifactId>doxia-integration-tools</artifactId>
       <version>${doxiaSitetoolsVersion}</version>
+      <exclusions>
+        <exclusion>
+          <artifactId>plexus-container-default</artifactId>
+          <groupId>org.codehaus.plexus</groupId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.doxia</groupId>
@@ -247,10 +255,6 @@ under the License.
           <groupId>org.codehaus.plexus</groupId>
           <artifactId>plexus-component-api</artifactId>
         </exclusion>
-        <exclusion>
-          <groupId>org.codehaus.plexus</groupId>
-          <artifactId>plexus-container-default</artifactId>
-        </exclusion>
       </exclusions>
     </dependency>
 
@@ -271,13 +275,14 @@ under the License.
     <dependency>
       <groupId>org.apache.maven.plugin-testing</groupId>
       <artifactId>maven-plugin-testing-harness</artifactId>
-      <version>1.3</version>
+      <version>3.1.0</version>
       <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-container-default</artifactId>
-      <version>1.0-alpha-9-stable-1</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.codehaus.plexus</groupId>
+          <artifactId>plexus-container-default</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
   </dependencies>
 
@@ -293,6 +298,30 @@ under the License.
     </pluginManagement>
 
     <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-enforcer-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>enforce</goal>
+            </goals>
+            <id>ensure-no-container-api</id>
+            <configuration>
+              <rules>
+                <bannedDependencies>
+                  <excludes>
+                    <exclude>org.codehaus.plexus:plexus-component-api</exclude>
+                    <exclude>org.codehaus.plexus:plexus-container-default</exclude>
+                  </excludes>
+                  <message>The new containers are not supported. You probably added a dependency that is missing the exclusions.</message>
+                </bannedDependencies>
+              </rules>
+              <fail>true</fail>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
 <!-- START SNIPPET: configuration -->
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
diff --git a/src/main/java/org/apache/maven/plugins/pdf/DocumentDescriptorReader.java b/src/main/java/org/apache/maven/plugins/pdf/DocumentDescriptorReader.java
index 7b72355..c893606 100644
--- a/src/main/java/org/apache/maven/plugins/pdf/DocumentDescriptorReader.java
+++ b/src/main/java/org/apache/maven/plugins/pdf/DocumentDescriptorReader.java
@@ -138,7 +138,7 @@ public class DocumentDescriptorReader
                     }
                     catch ( Exception e )
                     {
-                        addFeedback( "Failed to extract \'" + expression + "\' from: " + project, e );
+                        addFeedback( "Failed to extract '" + expression + "' from: " + project, e );
                     }
 
                     return null;
@@ -164,9 +164,7 @@ public class DocumentDescriptorReader
         }
         catch ( InterpolationException e )
         {
-            final IOException io = new IOException( "Error interpolating document descriptor" );
-            io.initCause( e );
-            throw io;
+            throw new IOException( "Error interpolating document descriptor", e );
         }
     }
 }
diff --git a/src/main/java/org/apache/maven/plugins/pdf/DocumentModelBuilder.java b/src/main/java/org/apache/maven/plugins/pdf/DocumentModelBuilder.java
index 025a597..d37028f 100644
--- a/src/main/java/org/apache/maven/plugins/pdf/DocumentModelBuilder.java
+++ b/src/main/java/org/apache/maven/plugins/pdf/DocumentModelBuilder.java
@@ -94,10 +94,6 @@ public class DocumentModelBuilder
         return getDocumentModel( project, decorationModel, date );
     }
 
-    // ----------------------------------------------------------------------
-    // Private methods
-    // ----------------------------------------------------------------------
-
     /**
      * Extract a DocumentModel from a MavenProject.
      *
diff --git a/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java b/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java
index 142c777..bb601cc 100644
--- a/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java
+++ b/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java
@@ -21,7 +21,6 @@ package org.apache.maven.plugins.pdf;
 
 import java.io.File;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.Reader;
 import java.io.StringReader;
 import java.io.StringWriter;
@@ -31,15 +30,10 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
-import java.util.Properties;
 
 import org.apache.commons.io.input.XmlStreamReader;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.versioning.ArtifactVersion;
-import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
-import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
-import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.doxia.Doxia;
 import org.apache.maven.doxia.docrenderer.AbstractDocumentRenderer;
 import org.apache.maven.doxia.docrenderer.DocumentRenderer;
@@ -71,13 +65,11 @@ import org.apache.maven.model.ReportPlugin;
 import org.apache.maven.model.Reporting;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugin.PluginManager;
 import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.plugins.annotations.ResolutionScope;
 import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectBuilder;
 import org.apache.maven.reporting.AbstractMavenReportRenderer;
 import org.apache.maven.reporting.MavenReport;
 import org.apache.maven.reporting.MavenReportException;
@@ -115,10 +107,6 @@ public class PdfMojo
      */
     private static final String EOL = System.getProperty( "line.separator" );
 
-    // ----------------------------------------------------------------------
-    // Mojo components
-    // ----------------------------------------------------------------------
-
     /**
      * FO Document Renderer.
      */
@@ -157,14 +145,6 @@ public class PdfMojo
     private SiteTool siteTool;
 
     /**
-     * The Plugin manager instance used to resolve Plugin descriptors.
-     *
-     * @since 1.1
-     */
-    @Component( role = PluginManager.class )
-    private PluginManager pluginManager;
-
-    /**
      * Doxia.
      *
      * @since 1.1
@@ -173,18 +153,6 @@ public class PdfMojo
     private Doxia doxia;
 
     /**
-     * Project builder.
-     *
-     * @since 1.1
-     */
-    @Component
-    private MavenProjectBuilder mavenProjectBuilder;
-
-    // ----------------------------------------------------------------------
-    // Mojo Parameters
-    // ----------------------------------------------------------------------
-
-    /**
      * The Maven Project Object.
      */
     @Parameter( defaultValue = "${project}", readonly = true, required = true )
@@ -318,10 +286,6 @@ public class PdfMojo
     @Parameter( defaultValue = "${project.reporting}", readonly = true )
     private Reporting reporting;
 
-    // ----------------------------------------------------------------------
-    // Instance fields
-    // ----------------------------------------------------------------------
-
     /**
      * The current document Renderer.
      * @see #implementation
@@ -362,10 +326,6 @@ public class PdfMojo
      */
     private PlexusContainer container;
 
-    // ----------------------------------------------------------------------
-    // Public methods
-    // ----------------------------------------------------------------------
-
     /** {@inheritDoc} */
     public void execute()
         throws MojoExecutionException, MojoFailureException
@@ -415,10 +375,6 @@ public class PdfMojo
         return includeReports;
     }
 
-    // ----------------------------------------------------------------------
-    // Private methods
-    // ----------------------------------------------------------------------
-
     /**
      * Init and validate parameters
      */
@@ -1331,26 +1287,18 @@ public class PdfMojo
         }
         catch ( ParseException e )
         {
-            StringBuilder sb = new StringBuilder( 1024 );
-
-            sb.append( EOL );
-            sb.append( "Error when parsing the generated report xdoc file: " );
-            sb.append( generatedReport.getAbsolutePath() );
-            sb.append( EOL );
-            sb.append( e.getMessage() );
-            sb.append( EOL );
-
-            sb.append( "You could:" ).append( EOL );
-            sb.append( "  * exclude all reports using -DincludeReports=false" ).append( EOL );
-            sb.append( "  * remove the " );
-            sb.append( fullGoal );
-            sb.append( " from the <reporting/> part. To not affect the site generation, " );
-            sb.append( "you could create a PDF profile." );
-
-            sb.append( EOL ).append( "Ignoring the \"" ).append( localReportName )
-                    .append( "\" report in the PDF." ).append( EOL );
-
-            getLog().error( sb.toString() );
+            String sb = EOL
+                    + "Error when parsing the generated report xdoc file: "
+                    + generatedReport.getAbsolutePath() + EOL
+                    + e.getMessage() + EOL
+                    + "You could:" + EOL
+                    + "  * exclude all reports using -DincludeReports=false" + EOL
+                    + "  * remove the "
+                    + fullGoal
+                    + " from the <reporting/> part. To not affect the site generation, "
+                    + "you could create a PDF profile." + EOL
+                    + "Ignoring the \"" + localReportName + "\" report in the PDF." + EOL;
+            getLog().error( sb );
             getLog().debug( e );
 
             return false;
@@ -1376,11 +1324,6 @@ public class PdfMojo
     protected List<MavenReportExecution> getReports()
         throws MojoExecutionException
     {
-        if ( !isMaven3OrMore() )
-        {
-            getLog().error( "Report generation is not supported with Maven <= 2.x" );
-        }
-
         MavenReportExecutorRequest mavenReportExecutorRequest = new MavenReportExecutorRequest();
         mavenReportExecutorRequest.setLocalRepository( localRepository );
         mavenReportExecutorRequest.setMavenSession( session );
@@ -1428,51 +1371,9 @@ public class PdfMojo
             mpir.setArtifactId( "maven-project-info-reports-plugin" );
             reportingPlugins.add( mpir );
         }
-        return reportingPlugins.toArray( new ReportPlugin[reportingPlugins.size()] );
-    }
-
-    /**
-     * Check the current Maven version to see if it's Maven 3.0 or newer.
-     */
-    protected static boolean isMaven3OrMore()
-    {
-        try
-        {
-            ArtifactVersion mavenVersion = new DefaultArtifactVersion( getMavenVersion() );
-            return VersionRange.createFromVersionSpec( "[3.0,)" ).containsVersion( mavenVersion );
-        }
-        catch ( InvalidVersionSpecificationException e )
-        {
-            return false;
-        }
-//        return new ComparableVersion( getMavenVersion() ).compareTo( new ComparableVersion( "3.0" ) ) >= 0;
+        return reportingPlugins.toArray( new ReportPlugin[0] );
     }
 
-    protected static String getMavenVersion()
-    {
-        // This relies on the fact that MavenProject is the in core classloader
-        // and that the core classloader is for the maven-core artifact
-        // and that should have a pom.properties file
-        // if this ever changes, we will have to revisit this code.
-        final Properties properties = new Properties();
-
-        try ( InputStream in = MavenProject.class.getClassLoader().getResourceAsStream(
-                "META-INF/maven/org.apache.maven/maven-core/pom.properties" ) )
-        {
-            properties.load( in );
-        }
-        catch ( IOException ioe )
-        {
-            return "";
-        }
-
-        return properties.getProperty( "version" ).trim();
-    }
-
-    // ----------------------------------------------------------------------
-    // static methods
-    // ----------------------------------------------------------------------
-
     /**
      * Write the given content to the given file.
      * <br/>
@@ -1520,10 +1421,6 @@ public class PdfMojo
         return excludesLocales;
     }
 
-    // ----------------------------------------------------------------------
-    // Inner class
-    // ----------------------------------------------------------------------
-
     /**
      * A sink to render a Maven report as a generated xdoc file, with some known workarounds.
      *
@@ -1556,103 +1453,4 @@ public class PdfMojo
         }
     }
 
-    /**
-     * Renderer Maven report similar to org.apache.maven.plugins.site.CategorySummaryDocumentRenderer
-     *
-     * @since 1.1
-     */
-    private static class ProjectInfoRenderer
-        extends AbstractMavenReportRenderer
-    {
-        private final List<MavenReport> generatedReports;
-
-        private final I18N i18n;
-
-        private final Locale locale;
-
-        ProjectInfoRenderer( Sink sink, List<MavenReport> generatedReports, I18N i18n, Locale locale )
-        {
-            super( sink );
-
-            this.generatedReports = generatedReports;
-            this.i18n = i18n;
-            this.locale = locale;
-        }
-
-        /** {@inheritDoc} */
-        public String getTitle()
-        {
-            return i18n.getString( "pdf-plugin", locale, "report.project-info.title" );
-        }
-
-        /** {@inheritDoc} */
-        public void renderBody()
-        {
-            sink.section1();
-            sink.sectionTitle1();
-            sink.text( i18n.getString( "pdf-plugin", locale, "report.project-info.title" ) );
-            sink.sectionTitle1_();
-
-            sink.paragraph();
-            sink.text( i18n.getString( "pdf-plugin", locale, "report.project-info.description1" ) + " " );
-            sink.link( "http://maven.apache.org" );
-            sink.text( "Maven" );
-            sink.link_();
-            sink.text( " " + i18n.getString( "pdf-plugin", locale, "report.project-info.description2" ) );
-            sink.paragraph_();
-
-            sink.section2();
-            sink.sectionTitle2();
-            sink.text( i18n.getString( "pdf-plugin", locale, "report.project-info.sectionTitle" ) );
-            sink.sectionTitle2_();
-
-            sink.table();
-
-            sink.tableRows( new int[] { Sink.JUSTIFY_LEFT, Sink.JUSTIFY_LEFT }, false );
-
-            String name = i18n.getString( "pdf-plugin", locale, "report.project-info.column.document" );
-            String description = i18n.getString( "pdf-plugin", locale, "report.project-info.column.description" );
-
-            sink.tableRow();
-
-            sink.tableHeaderCell( SinkEventAttributeSet.CENTER );
-
-            sink.text( name );
-
-            sink.tableHeaderCell_();
-
-            sink.tableHeaderCell( SinkEventAttributeSet.CENTER );
-
-            sink.text( description );
-
-            sink.tableHeaderCell_();
-
-            sink.tableRow_();
-
-            if ( generatedReports != null )
-            {
-                for ( final MavenReport report : generatedReports )
-                {
-                    sink.tableRow();
-                    sink.tableCell();
-                    sink.link( report.getOutputName() + ".html" );
-                    sink.text( report.getName( locale ) );
-                    sink.link_();
-                    sink.tableCell_();
-                    sink.tableCell();
-                    sink.text( report.getDescription( locale ) );
-                    sink.tableCell_();
-                    sink.tableRow_();
-                }
-            }
-
-            sink.tableRows_();
-
-            sink.table_();
-
-            sink.section2_();
-
-            sink.section1_();
-        }
-    }
 }
diff --git a/src/test/java/org/apache/maven/plugins/pdf/DocumentDescriptorReaderTest.java b/src/test/java/org/apache/maven/plugins/pdf/DocumentDescriptorReaderTest.java
index d402633..ab07d3f 100644
--- a/src/test/java/org/apache/maven/plugins/pdf/DocumentDescriptorReaderTest.java
+++ b/src/test/java/org/apache/maven/plugins/pdf/DocumentDescriptorReaderTest.java
@@ -65,8 +65,8 @@ public class DocumentDescriptorReaderTest
         assertEquals( "Table of Contents", model.getToc().getName() );
         assertEquals( 5, model.getToc().getItems().size() );
         assertNotNull( model.getMeta() );
-        assertTrue( model.getMeta().getTitle().indexOf(
-                "User guide in en of Test filtering version 1.0-SNAPSHOT" ) == 0 );
+        assertEquals( 0, model.getMeta().getTitle().indexOf(
+                "User guide in en of Test filtering version 1.0-SNAPSHOT" ) );
         assertEquals( "vsiveton@apache.org ltheussl@apache.org", model.getMeta().getAuthor() );
     }
 
diff --git a/src/test/java/org/apache/maven/plugins/pdf/stubs/DefaultMavenProjectStub.java b/src/test/java/org/apache/maven/plugins/pdf/stubs/DefaultMavenProjectStub.java
index 240dfb3..1975fb9 100644
--- a/src/test/java/org/apache/maven/plugins/pdf/stubs/DefaultMavenProjectStub.java
+++ b/src/test/java/org/apache/maven/plugins/pdf/stubs/DefaultMavenProjectStub.java
@@ -25,12 +25,11 @@ import java.util.Collections;
 import java.util.List;
 
 import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.DefaultArtifactRepository;
+import org.apache.maven.artifact.repository.MavenArtifactRepository;
 import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
-import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.ReaderFactory;
 
 /**
@@ -67,11 +66,10 @@ public class DefaultMavenProjectStub
     }
 
     /** {@inheritDoc} */
-    public List getRemoteArtifactRepositories()
+    public List<ArtifactRepository> getRemoteArtifactRepositories()
     {
-        ArtifactRepository repository =
-            new DefaultArtifactRepository( "central", "http://repo1.maven.org/maven2",
-                                           new DefaultRepositoryLayout() );
+        ArtifactRepository repository = new MavenArtifactRepository( "central", "https://repo.maven.apache.org/maven2",
+                new DefaultRepositoryLayout(), null, null );
 
         return Collections.singletonList( repository );
     }
diff --git a/src/test/java/org/apache/maven/plugins/pdf/stubs/FilteringMavenProjectStub.java b/src/test/java/org/apache/maven/plugins/pdf/stubs/FilteringMavenProjectStub.java
index 93a587f..27467b5 100644
--- a/src/test/java/org/apache/maven/plugins/pdf/stubs/FilteringMavenProjectStub.java
+++ b/src/test/java/org/apache/maven/plugins/pdf/stubs/FilteringMavenProjectStub.java
@@ -26,12 +26,12 @@ import java.util.List;
 import java.util.Properties;
 
 import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.DefaultArtifactRepository;
+import org.apache.maven.artifact.repository.MavenArtifactRepository;
 import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
+import org.apache.maven.model.Developer;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
-import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.ReaderFactory;
 
 /**
@@ -73,7 +73,7 @@ public class FilteringMavenProjectStub
     }
 
     /** {@inheritDoc} */
-    public List getDevelopers()
+    public List<Developer> getDevelopers()
     {
         return getModel().getDevelopers();
     }
@@ -85,11 +85,11 @@ public class FilteringMavenProjectStub
     }
 
     /** {@inheritDoc} */
-    public List getRemoteArtifactRepositories()
+    public List<ArtifactRepository> getRemoteArtifactRepositories()
     {
         ArtifactRepository repository =
-            new DefaultArtifactRepository( "central", "http://repo1.maven.org/maven2",
-                                           new DefaultRepositoryLayout() );
+            new MavenArtifactRepository( "central", "https://repo.maven.apache.org/maven2",
+                    new DefaultRepositoryLayout(), null,null );
 
         return Collections.singletonList( repository );
     }
diff --git a/src/test/java/org/apache/maven/plugins/pdf/stubs/ITextMavenProjectStub.java b/src/test/java/org/apache/maven/plugins/pdf/stubs/ITextMavenProjectStub.java
index 0b2e5bf..b988477 100644
--- a/src/test/java/org/apache/maven/plugins/pdf/stubs/ITextMavenProjectStub.java
+++ b/src/test/java/org/apache/maven/plugins/pdf/stubs/ITextMavenProjectStub.java
@@ -25,12 +25,11 @@ import java.util.Collections;
 import java.util.List;
 
 import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.DefaultArtifactRepository;
+import org.apache.maven.artifact.repository.MavenArtifactRepository;
 import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
-import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.ReaderFactory;
 
 /**
@@ -61,11 +60,11 @@ public class ITextMavenProjectStub
     }
 
     /** {@inheritDoc} */
-    public List getRemoteArtifactRepositories()
+    public List<ArtifactRepository> getRemoteArtifactRepositories()
     {
         ArtifactRepository repository =
-            new DefaultArtifactRepository( "central", "http://repo1.maven.org/maven2",
-                                           new DefaultRepositoryLayout() );
+            new MavenArtifactRepository( "central", "https://repo.maven.apache.org/maven2",
+                        new DefaultRepositoryLayout(), null, null );
 
         return Collections.singletonList( repository );
     }

[maven-pdf-plugin] 02/02: [MPDF-98] Require Java 8

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch MPDF-98
in repository https://gitbox.apache.org/repos/asf/maven-pdf-plugin.git

commit 90e59a515c610a86357bacf8bba975397729bc8e
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Fri Jun 4 10:25:24 2021 +0200

    [MPDF-98] Require Java 8
---
 pom.xml                                            |  2 +-
 .../org/apache/maven/plugins/pdf/DateBean.java     |  4 ++--
 .../maven/plugins/pdf/DocumentModelBuilder.java    |  4 +---
 .../apache/maven/plugins/pdf/PdfAggregateMojo.java |  2 +-
 .../java/org/apache/maven/plugins/pdf/PdfMojo.java | 23 ++++++++--------------
 .../plugins/pdf/DocumentModelBuilderTest.java      |  1 -
 .../org/apache/maven/plugins/pdf/PdfMojoTest.java  |  6 ------
 .../pdf/stubs/ModelBuilderMavenProjectStub.java    |  5 ++---
 8 files changed, 15 insertions(+), 32 deletions(-)

diff --git a/pom.xml b/pom.xml
index fdad34c..2931e2c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -92,7 +92,7 @@ under the License.
     <doxiaVersion>1.10</doxiaVersion>
     <doxiaSitetoolsVersion>1.10</doxiaSitetoolsVersion>
     <mavenVersion>3.1.1</mavenVersion>
-    <javaVersion>7</javaVersion>
+    <javaVersion>8</javaVersion>
     <project.build.outputTimestamp>2020-04-07T21:04:00Z</project.build.outputTimestamp>
   </properties>
 
diff --git a/src/main/java/org/apache/maven/plugins/pdf/DateBean.java b/src/main/java/org/apache/maven/plugins/pdf/DateBean.java
index 15b6d5d..68511ed 100644
--- a/src/main/java/org/apache/maven/plugins/pdf/DateBean.java
+++ b/src/main/java/org/apache/maven/plugins/pdf/DateBean.java
@@ -45,8 +45,8 @@ public class DateBean
     private static final SimpleDateFormat SECOND = new SimpleDateFormat( "ss", Locale.US );
     private static final SimpleDateFormat MILLI_SECOND = new SimpleDateFormat( "SSS", Locale.US );
     private static final SimpleDateFormat DATE = new SimpleDateFormat( "yyyy-MM-dd", Locale.US );
-    private static final SimpleDateFormat TIME = new SimpleDateFormat( "HH:mm:ss\'Z\'", Locale.US );
-    private static final SimpleDateFormat DATE_TIME = new SimpleDateFormat( "yyyy-MM-dd\'T\'HH:mm:ss\'Z\'", Locale.US );
+    private static final SimpleDateFormat TIME = new SimpleDateFormat( "HH:mm:ss'Z'", Locale.US );
+    private static final SimpleDateFormat DATE_TIME = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US );
 
     static
     {
diff --git a/src/main/java/org/apache/maven/plugins/pdf/DocumentModelBuilder.java b/src/main/java/org/apache/maven/plugins/pdf/DocumentModelBuilder.java
index d37028f..3e30f15 100644
--- a/src/main/java/org/apache/maven/plugins/pdf/DocumentModelBuilder.java
+++ b/src/main/java/org/apache/maven/plugins/pdf/DocumentModelBuilder.java
@@ -216,10 +216,8 @@ public class DocumentModelBuilder
 
         final List<DocumentAuthor> ret = new ArrayList<>( 4 );
 
-        for ( Object o : project.getDevelopers() )
+        for ( Developer developer : project.getDevelopers() )
         {
-            final Developer developer = (Developer) o;
-
             final DocumentAuthor author = new DocumentAuthor();
             author.setName( developer.getName() );
             author.setEmail( developer.getEmail() );
diff --git a/src/main/java/org/apache/maven/plugins/pdf/PdfAggregateMojo.java b/src/main/java/org/apache/maven/plugins/pdf/PdfAggregateMojo.java
index 691c8a4..7576320 100644
--- a/src/main/java/org/apache/maven/plugins/pdf/PdfAggregateMojo.java
+++ b/src/main/java/org/apache/maven/plugins/pdf/PdfAggregateMojo.java
@@ -211,7 +211,7 @@ public class PdfAggregateMojo extends PdfMojo
         tocItem.setName( (String) item.get( "name" ) );
         tocItem.setRef( stagedId + "/" + item.get( "ref" ) );
 
-        List<Map<String, Object>> items = (ArrayList) item.get( "items" );
+        List<Map<String, Object>> items = (List) item.get( "items" );
 
         for ( Map<String, Object> it : items )
         {
diff --git a/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java b/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java
index bb601cc..c5b7198 100644
--- a/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java
+++ b/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java
@@ -50,9 +50,7 @@ import org.apache.maven.doxia.index.IndexingSink;
 import org.apache.maven.doxia.module.xdoc.XdocSink;
 import org.apache.maven.doxia.parser.ParseException;
 import org.apache.maven.doxia.parser.manager.ParserNotFoundException;
-import org.apache.maven.doxia.sink.Sink;
 import org.apache.maven.doxia.sink.impl.SinkAdapter;
-import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
 import org.apache.maven.doxia.site.decoration.DecorationModel;
 import org.apache.maven.doxia.site.decoration.io.xpp3.DecorationXpp3Reader;
 import org.apache.maven.doxia.siterenderer.Renderer;
@@ -64,13 +62,11 @@ import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.ReportPlugin;
 import org.apache.maven.model.Reporting;
 import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.plugins.annotations.ResolutionScope;
 import org.apache.maven.project.MavenProject;
-import org.apache.maven.reporting.AbstractMavenReportRenderer;
 import org.apache.maven.reporting.MavenReport;
 import org.apache.maven.reporting.MavenReportException;
 import org.apache.maven.reporting.exec.MavenReportExecution;
@@ -328,7 +324,7 @@ public class PdfMojo
 
     /** {@inheritDoc} */
     public void execute()
-        throws MojoExecutionException, MojoFailureException
+        throws MojoExecutionException
     {
         init();
 
@@ -580,7 +576,7 @@ public class PdfMojo
             String excludes = getDefaultExcludesWithLocales( getAvailableLocales(), getDefaultLocale() );
             List<String> siteFiles =
                 siteDirectory.exists() ? FileUtils.getFileNames( siteDirectory, "**/*", excludes, false )
-                                : new ArrayList<String>();
+                                : new ArrayList<>();
             File siteDirectoryLocale = new File( siteDirectory, locale.getLanguage() );
             if ( !locale.getLanguage().equals( getDefaultLocale().getLanguage() ) && siteDirectoryLocale.exists() )
             {
@@ -773,7 +769,7 @@ public class PdfMojo
                     String siteDescriptorContent = IOUtil.toString( reader );
 
                     siteDescriptorContent =
-                        siteTool.getInterpolatedSiteDescriptorContent( new HashMap<String, String>( 2 ), project,
+                        siteTool.getInterpolatedSiteDescriptorContent( new HashMap<>( 2 ), project,
                                                                        siteDescriptorContent );
 
                     decoration = new DecorationXpp3Reader().read( new StringReader( siteDescriptorContent ) );
@@ -839,7 +835,7 @@ public class PdfMojo
         try
         {
             final SiteRenderingContext context =
-                siteRenderer.createContextForSkin( skinArtifact, new HashMap<String, Object>( 2 ), decorationModel,
+                siteRenderer.createContextForSkin( skinArtifact, new HashMap<>( 2 ), decorationModel,
                                                    project.getName(), locale );
             context.addSiteDirectory( new File( siteDirectory, locale.getLanguage() ) );
 
@@ -1115,10 +1111,7 @@ public class PdfMojo
             this.generatedMavenReports = new HashMap<>( 2 );
         }
 
-        if ( this.generatedMavenReports.get( locale ) == null )
-        {
-            this.generatedMavenReports.put( locale, new ArrayList<MavenReport>( 2 ) );
-        }
+        this.generatedMavenReports.computeIfAbsent( locale, k -> new ArrayList<>( 2 ) );
 
         return this.generatedMavenReports.get( locale );
     }
@@ -1409,16 +1402,16 @@ public class PdfMojo
      */
     private static String getDefaultExcludesWithLocales( List<Locale> locales, Locale defaultLocale )
     {
-        String excludesLocales = FileUtils.getDefaultExcludesAsString();
+        StringBuilder excludesLocales = new StringBuilder( FileUtils.getDefaultExcludesAsString() );
         for ( final Locale locale : locales )
         {
             if ( !locale.getLanguage().equals( defaultLocale.getLanguage() ) )
             {
-                excludesLocales = excludesLocales + ",**/" + locale.getLanguage() + "/*";
+                excludesLocales.append( ",**/" ).append( locale.getLanguage() ).append( "/*" );
             }
         }
 
-        return excludesLocales;
+        return excludesLocales.toString();
     }
 
     /**
diff --git a/src/test/java/org/apache/maven/plugins/pdf/DocumentModelBuilderTest.java b/src/test/java/org/apache/maven/plugins/pdf/DocumentModelBuilderTest.java
index 84ba98c..f8c2770 100644
--- a/src/test/java/org/apache/maven/plugins/pdf/DocumentModelBuilderTest.java
+++ b/src/test/java/org/apache/maven/plugins/pdf/DocumentModelBuilderTest.java
@@ -33,7 +33,6 @@ import org.apache.maven.doxia.site.decoration.io.xpp3.DecorationXpp3Reader;
 import org.apache.maven.plugins.pdf.stubs.ModelBuilderMavenProjectStub;
 
 import org.codehaus.plexus.PlexusTestCase;
-import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
diff --git a/src/test/java/org/apache/maven/plugins/pdf/PdfMojoTest.java b/src/test/java/org/apache/maven/plugins/pdf/PdfMojoTest.java
index 6d45d81..e6e77ad 100644
--- a/src/test/java/org/apache/maven/plugins/pdf/PdfMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/pdf/PdfMojoTest.java
@@ -37,10 +37,8 @@ public class PdfMojoTest
     /**
      * Tests the basic functioning of the pdf generation using the FO implementation.
      *
-     * @throws Exception if any.
      */
     public void testPdfMojo()
-        throws Exception
     {
         executePdfMojo( "pom.xml", "fo/maven-pdf-plugin-doc.pdf" );
     }
@@ -48,10 +46,8 @@ public class PdfMojoTest
     /**
      * Tests the basic functioning of the pdf generation with iText.
      *
-     * @throws Exception if any.
      */
     public void testITextImpl()
-        throws Exception
     {
         executePdfMojo( "iText_pom.xml", "itext/maven-pdf-plugin-doc.pdf" );
      }
@@ -59,10 +55,8 @@ public class PdfMojoTest
     /**
      * Tests the basic functioning of the pdf generation using the FO implementation.
      *
-     * @throws Exception if any.
      */
     public void testPdfMojoNoDocDesriptor()
-        throws Exception
     {
         executePdfMojo( "no_docdescriptor_pom.xml", "no/unnamed.pdf" );
     }
diff --git a/src/test/java/org/apache/maven/plugins/pdf/stubs/ModelBuilderMavenProjectStub.java b/src/test/java/org/apache/maven/plugins/pdf/stubs/ModelBuilderMavenProjectStub.java
index b74cf35..0883c6c 100644
--- a/src/test/java/org/apache/maven/plugins/pdf/stubs/ModelBuilderMavenProjectStub.java
+++ b/src/test/java/org/apache/maven/plugins/pdf/stubs/ModelBuilderMavenProjectStub.java
@@ -27,7 +27,6 @@ import org.apache.maven.model.Model;
 import org.apache.maven.model.Organization;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
-import org.codehaus.plexus.util.IOUtil;
 import org.apache.commons.io.input.XmlStreamReader;
 
 /**
@@ -73,7 +72,7 @@ public class ModelBuilderMavenProjectStub
     }
 
     /** {@inheritDoc} */
-    public List getDevelopers()
+    public List<Developer> getDevelopers()
     {
         return getModel().getDevelopers();
     }
@@ -85,7 +84,7 @@ public class ModelBuilderMavenProjectStub
     }
 
     /** {@inheritDoc} */
-    public void setDevelopers( List list )
+    public void setDevelopers( List<Developer> list )
     {
         getModel().setDevelopers( list );
     }