You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2019/04/03 19:15:50 UTC

[maven-reporting-impl] branch MSHARED-813 created (now 9e004c2)

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

rfscholte pushed a change to branch MSHARED-813
in repository https://gitbox.apache.org/repos/asf/maven-reporting-impl.git.


      at 9e004c2  [MSHARED-813] Require Java 7

This branch includes the following new commits:

     new 9e004c2  [MSHARED-813] 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.



[maven-reporting-impl] 01/01: [MSHARED-813] Require Java 7

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

rfscholte pushed a commit to branch MSHARED-813
in repository https://gitbox.apache.org/repos/asf/maven-reporting-impl.git

commit 9e004c22f08ad33a088788ed706a9fc86b344642
Author: rfscholte <rf...@apache.org>
AuthorDate: Wed Apr 3 21:15:43 2019 +0200

    [MSHARED-813] Require Java 7
---
 pom.xml                                            | 12 ++--
 .../maven/reporting/AbstractMavenReport.java       | 77 +++++++++-------------
 .../reporting/AbstractMavenReportRenderer.java     | 23 +++----
 3 files changed, 50 insertions(+), 62 deletions(-)

diff --git a/pom.xml b/pom.xml
index 9b3ea46..ed59557 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,13 +23,13 @@
   <parent>
     <groupId>org.apache.maven.shared</groupId>
     <artifactId>maven-shared-components</artifactId>
-    <version>30</version>
-    <relativePath>../../pom/maven/maven-shared-components/pom.xml</relativePath>
+    <version>33</version>
+    <relativePath/>
   </parent>
 
   <groupId>org.apache.maven.reporting</groupId>
   <artifactId>maven-reporting-impl</artifactId>
-  <version>3.0.1-SNAPSHOT</version>
+  <version>3.1.0-SNAPSHOT</version>
 
   <name>Apache Maven Reporting Implementation</name>
   <description>Abstract classes to manage report generation.</description>
@@ -71,8 +71,7 @@
     <mavenVersion>3.0</mavenVersion>
     <doxiaVersion>1.7</doxiaVersion>
     <doxiaSitetoolsVersion>1.7.4</doxiaSitetoolsVersion>
-    <maven.compiler.source>1.6</maven.compiler.source>
-    <maven.compiler.target>1.6</maven.compiler.target>
+    <javaVersion>7</javaVersion>
   </properties>
 
   <dependencies>
@@ -158,7 +157,6 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-invoker-plugin</artifactId>
-        <version>3.0.1</version><!-- TODO remove version when upgrading parent pom -->
         <configuration>
           <debug>true</debug>
           <projectsDirectory>src/it</projectsDirectory>
@@ -173,6 +171,8 @@
           <properties>
             <maven.compiler.source>${maven.compiler.source}</maven.compiler.source>
             <maven.compiler.target>${maven.compiler.target}</maven.compiler.target>
+            <!-- e.g. ensure that Java7 picks up TLSv1.2 when connecting with Central -->
+            <https.protocols>${https.protocols}</https.protocols>
           </properties>
         </configuration>
         <executions>
diff --git a/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java b/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
index ee3ce9a..8a2b3aa 100644
--- a/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
+++ b/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
@@ -33,7 +33,6 @@ import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.shared.utils.WriterFactory;
-import org.apache.maven.shared.utils.io.IOUtil;
 import org.codehaus.plexus.util.ReaderFactory;
 
 import java.io.File;
@@ -55,7 +54,6 @@ import java.util.Map;
  * </ul>
  *
  * @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
- * @version $Id$
  * @since 2.0
  * @see #execute() <code>Mojo.execute()</code>, from maven-plugin-api
  * @see #generate(Sink, SinkFactory, Locale) <code>MavenMultiPageReport.generate( Sink, SinkFactory, Locale )</code>,
@@ -111,9 +109,9 @@ public abstract class AbstractMavenReport
      * This method is called when the report generation is invoked directly as a standalone Mojo.
      *
      * @throws MojoExecutionException if an error occurs when generating the report
-     * @see org.apache.maven.plugins.site.ReportDocumentRender
      * @see org.apache.maven.plugin.Mojo#execute()
      */
+    @Override
     public void execute()
         throws MojoExecutionException
     {
@@ -122,24 +120,24 @@ public abstract class AbstractMavenReport
             return;
         }
 
-        Writer writer = null;
-        try
-        {
-            File outputDirectory = new File( getOutputDirectory() );
+        File outputDirectory = new File( getOutputDirectory() );
+
+        String filename = getOutputName() + ".html";
 
-            String filename = getOutputName() + ".html";
+        Locale locale = Locale.getDefault();
 
-            Locale locale = Locale.getDefault();
+        SiteRenderingContext siteContext = new SiteRenderingContext();
+        siteContext.setDecoration( new DecorationModel() );
+        siteContext.setTemplateName( "org/apache/maven/doxia/siterenderer/resources/default-site.vm" );
+        siteContext.setLocale( locale );
+        siteContext.setTemplateProperties( getTemplateProperties() );
 
-            SiteRenderingContext siteContext = new SiteRenderingContext();
-            siteContext.setDecoration( new DecorationModel() );
-            siteContext.setTemplateName( "org/apache/maven/doxia/siterenderer/resources/default-site.vm" );
-            siteContext.setLocale( locale );
-            siteContext.setTemplateProperties( getTemplateProperties() );
+        RenderingContext context = new RenderingContext( outputDirectory, filename );
 
-            RenderingContext context = new RenderingContext( outputDirectory, filename );
+        SiteRendererSink sink = new SiteRendererSink( context );
 
-            SiteRendererSink sink = new SiteRendererSink( context );
+        try
+        {
 
             generate( sink, null, locale );
 
@@ -147,35 +145,19 @@ public abstract class AbstractMavenReport
             {
                 outputDirectory.mkdirs();
 
-                writer =
+                try ( Writer writer =
                     new OutputStreamWriter( new FileOutputStream( new File( outputDirectory, filename ) ),
-                                            getOutputEncoding() );
-
-                getSiteRenderer().generateDocument( writer, sink, siteContext );
-
-                //getSiteRenderer().copyResources( siteContext, new File( project.getBasedir(), "src/site/resources" ),
-                //                            outputDirectory );
+                                            getOutputEncoding() ) )
+                {
+                    getSiteRenderer().generateDocument( writer, sink, siteContext );
+                }
             }
         }
-        catch ( RendererException e )
+        catch ( RendererException | IOException | MavenReportException e )
         {
             throw new MojoExecutionException(
                 "An error has occurred in " + getName( Locale.ENGLISH ) + " report generation.", e );
         }
-        catch ( IOException e )
-        {
-            throw new MojoExecutionException(
-                "An error has occurred in " + getName( Locale.ENGLISH ) + " report generation.", e );
-        }
-        catch ( MavenReportException e )
-        {
-            throw new MojoExecutionException(
-                "An error has occurred in " + getName( Locale.ENGLISH ) + " report generation.", e );
-        }
-        finally
-        {
-            IOUtil.close( writer );
-        }
     }
 
     /**
@@ -185,7 +167,7 @@ public abstract class AbstractMavenReport
      */
     private Map<String, Object> getTemplateProperties()
     {
-        Map<String, Object> templateProperties = new HashMap<String, Object>();
+        Map<String, Object> templateProperties = new HashMap<>();
         templateProperties.put( "project", getProject() );
         templateProperties.put( "inputEncoding", getInputEncoding() );
         templateProperties.put( "outputEncoding", getOutputEncoding() );
@@ -205,6 +187,8 @@ public abstract class AbstractMavenReport
      * @throws MavenReportException if any
      * @deprecated use {@link #generate(Sink, SinkFactory, Locale)} instead.
      */
+    @Deprecated
+    @Override
     public void generate( org.codehaus.doxia.sink.Sink sink, Locale locale )
         throws MavenReportException
     {
@@ -217,9 +201,10 @@ public abstract class AbstractMavenReport
      * @param sink
      * @param locale
      * @throws MavenReportException
-     * @see org.apache.maven.reporting.MavenReport#generate(org.apache.maven.doxia.sink.Sink, java.util.Locale)
+     * @see org.apache.maven.reporting.MavenReport#generate(org.codehaus.doxia.sink.Sink, Locale)
      * @deprecated use {@link #generate(Sink, SinkFactory, Locale)} instead.
      */
+    @Deprecated
     public void generate( Sink sink, Locale locale )
         throws MavenReportException
     {
@@ -234,6 +219,7 @@ public abstract class AbstractMavenReport
      * @param locale
      * @throws MavenReportException
      */
+    @Override
     public void generate( Sink sink, SinkFactory sinkFactory, Locale locale )
         throws MavenReportException
     {
@@ -254,15 +240,15 @@ public abstract class AbstractMavenReport
     }
 
     /**
-     * {@inheritDoc}
      * @return CATEGORY_PROJECT_REPORTS
      */
+    @Override
     public String getCategoryName()
     {
         return CATEGORY_PROJECT_REPORTS;
     }
 
-    /** {@inheritDoc} */
+    @Override
     public File getReportOutputDirectory()
     {
         if ( reportOutputDirectory == null )
@@ -273,7 +259,7 @@ public abstract class AbstractMavenReport
         return reportOutputDirectory;
     }
 
-    /** {@inheritDoc} */
+    @Override
     public void setReportOutputDirectory( File reportOutputDirectory )
     {
         this.reportOutputDirectory = reportOutputDirectory;
@@ -341,14 +327,15 @@ public abstract class AbstractMavenReport
 
     /**
      * @see org.apache.maven.reporting.MavenReport#isExternalReport()
-     * @return <tt>false</tt> by default.
+     * @return {@code false} by default.
      */
+    @Override
     public boolean isExternalReport()
     {
         return false;
     }
 
-    /** {@inheritDoc} */
+    @Override
     public boolean canGenerateReport()
     {
         return true;
diff --git a/src/main/java/org/apache/maven/reporting/AbstractMavenReportRenderer.java b/src/main/java/org/apache/maven/reporting/AbstractMavenReportRenderer.java
index 0890438..5acd06e 100644
--- a/src/main/java/org/apache/maven/reporting/AbstractMavenReportRenderer.java
+++ b/src/main/java/org/apache/maven/reporting/AbstractMavenReportRenderer.java
@@ -32,17 +32,17 @@ import java.util.Map;
 import java.util.Properties;
 
 /**
- * An abstract class to manage report generation, with many helper methods to ease the job: you just need to
- * implement getTitle() and renderBody().
- *
+ * <p>An abstract class to manage report generation, with many helper methods to ease the job: you just need to
+ * implement getTitle() and renderBody().</p>
+ * 
+ * <p><strong>TODO</strong> Later it may be appropriate to create something like a VelocityMavenReportRenderer
+ * that could take a velocity template and pipe that through Doxia rather than coding them
+ * up like this.</p>
+ * 
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
  * @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
  * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
- * @version $Id$
  * @since 2.0
- * @TODO Later it may be appropriate to create something like a VelocityMavenReportRenderer
- * that could take a velocity template and pipe that through Doxia rather than coding them
- * up like this.
  * @see #getTitle()
  * @see #renderBody()
  */
@@ -66,6 +66,7 @@ public abstract class AbstractMavenReportRenderer
     }
 
     /** {@inheritDoc} */
+    @Override
     public void render()
     {
         sink.head();
@@ -179,7 +180,7 @@ public abstract class AbstractMavenReportRenderer
      * @see Sink#section3_()
      * @see Sink#section4_()
      * @see Sink#section5_()
-     * @IllegalStateException if too many closing sections.
+     * @throws IllegalStateException if too many closing sections.
      */
     protected void endSection()
     {
@@ -291,7 +292,7 @@ public abstract class AbstractMavenReportRenderer
      * <p>If <code>asHtml</code> is true, add the text as Html</p>
      *
      * @param text the text to put in this cell, could be null.
-     * @param asHtml <tt>true</tt> to add the text as Html, <tt>false</tt> otherwise.
+     * @param asHtml {@code true} to add the text as Html, {@code false} otherwise.
      * @see #linkPatternedText(String)
      * @see Sink#tableCell()
      * @see Sink#tableCell_()
@@ -606,7 +607,7 @@ public abstract class AbstractMavenReportRenderer
 
         // Map defined by key/value name/href
         // If href == null, it means
-        List<String> segments = new ArrayList<String>();
+        List<String> segments = new ArrayList<>();
 
         // TODO Special case http://jira.codehaus.org/browse/MEV-40
         if ( text.indexOf( "${" ) != -1 )
@@ -725,7 +726,7 @@ public abstract class AbstractMavenReportRenderer
     // Abstract methods
     // ----------------------------------------------------------------------
 
-    /** {@inheritDoc} */
+    @Override
     public abstract String getTitle();
 
     /**