You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kw...@apache.org on 2022/09/15 10:47:26 UTC

[maven-javadoc-plugin] 01/01: [MJAVADOC-685] Deprecate parameter "stylesheet"

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

kwin pushed a commit to branch bugfix/deprecate-stylesheet
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git

commit b895f1eebbc9a8cd739101f97bca107fc9803b15
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Thu Sep 15 12:47:19 2022 +0200

    [MJAVADOC-685] Deprecate parameter "stylesheet"
    
    Remove custom Maven stylesheet CSS as incompatible with javadoc at least
    since JDK8
---
 .../maven/plugins/javadoc/AbstractJavadocMojo.java | 70 ++++------------------
 .../maven/plugins/javadoc/css/stylesheet.css       | 64 --------------------
 .../maven/plugins/javadoc/JavadocReportTest.java   | 12 ----
 3 files changed, 11 insertions(+), 135 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
index 91d734ff..fc51774d 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -20,7 +20,6 @@ package org.apache.maven.plugins.javadoc;
  */
 
 import org.apache.commons.lang3.BooleanUtils;
-import org.apache.commons.lang3.ClassUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.maven.archiver.MavenArchiver;
 import org.apache.maven.artifact.Artifact;
@@ -205,20 +204,11 @@ public abstract class AbstractJavadocMojo
     protected static final String FILES_FILE_NAME = "files";
 
     /**
-     * The current class directory
-     */
-    private static final String RESOURCE_DIR = ClassUtils.getPackageName( JavadocReport.class ).replace( '.', '/' );
-
-    /**
-     * Default css file name
+     * Default css file name, used as file name in the output directory for the temporary custom stylesheet file
+     * loaded from classloader resources.
      */
     private static final String DEFAULT_CSS_NAME = "stylesheet.css";
 
-    /**
-     * Default location for css
-     */
-    private static final String RESOURCE_CSS_DIR = RESOURCE_DIR + "/css";
-
     private static final String PACKAGE_LIST = "package-list";
     private static final String ELEMENT_LIST = "element-list";
 
@@ -1255,12 +1245,13 @@ public abstract class AbstractJavadocMojo
 
     /**
      * Specifies whether the stylesheet to be used is the <code>maven</code>'s javadoc stylesheet or
-     * <code>java</code>'s default stylesheet when a <i>stylesheetfile</i> parameter is not specified.
+     * <code>java</code>'s default stylesheet when a {@link #stylesheetfile} parameter is not specified.
      * <br/>
      * Possible values: <code>maven<code> or <code>java</code>.
-     * <br/>
+     * @deprecated This is no longer evalued, instead use {@link #addStylesheets} to customiz
      */
     @Parameter( property = "stylesheet", defaultValue = "java" )
+    @Deprecated
     private String stylesheet;
 
     /**
@@ -2908,11 +2899,11 @@ public abstract class AbstractJavadocMojo
     /**
      * Method to get the stylesheet path file to be used by the Javadoc Tool.
      * <br/>
-     * If the {@code stylesheetfile} is empty, return the file as String definded by {@code stylesheet} value.
+     * If the {@link #stylesheetfile} is empty, return the file as String defined by {@link #stylesheet} value.
      * <br/>
-     * If the {@code stylesheetfile} is defined, return the file as String.
+     * If the {@link #stylesheetfile} is defined, return the file as String.
      * <br/>
-     * Note: since 2.6, the {@code stylesheetfile} could be a path from a resource in the project source
+     * Note: since 2.6, the {@link #stylesheetfile} could be a path from a resource in the project source
      * directories (i.e. <code>src/main/java</code>, <code>src/main/resources</code> or <code>src/main/javadoc</code>)
      * or from a resource in the Javadoc plugin dependencies.
      *
@@ -2930,8 +2921,9 @@ public abstract class AbstractJavadocMojo
                 return Optional.empty();
             }
 
-            // maven, see #copyDefaultStylesheet(File)
-            return Optional.of( new File( javadocOutputDirectory, DEFAULT_CSS_NAME ) );
+            getLog().warn( "Parameter 'stylesheet' is no longer evaluated, rather use 'addStylesheets'"
+                + " to customize the CSS!" );
+            return Optional.empty();
         }
 
         if ( new File( stylesheetfile ).exists() )
@@ -4238,18 +4230,6 @@ public abstract class AbstractJavadocMojo
     private void copyAllResources( File javadocOutputDirectory )
         throws MavenReportException
     {
-        // ----------------------------------------------------------------------
-        // Copy default resources
-        // ----------------------------------------------------------------------
-
-        try
-        {
-            copyDefaultStylesheet( javadocOutputDirectory );
-        }
-        catch ( IOException e )
-        {
-            throw new MavenReportException( "Unable to copy default stylesheet: " + e.getMessage(), e );
-        }
 
         // ----------------------------------------------------------------------
         // Copy javadoc resources
@@ -4278,34 +4258,6 @@ public abstract class AbstractJavadocMojo
         copyAdditionalJavadocResources( javadocOutputDirectory );
     }
 
-    /**
-     * Copies the {@code DEFAULT_CSS_NAME} css file from the current class
-     * loader to the <code>outputDirectory</code> only if {@code stylesheetfile} is empty and
-     * {@code stylesheet} is equals to <code>maven</code>.
-     *
-     * @param anOutputDirectory the output directory
-     * @throws java.io.IOException if any
-     * @see #DEFAULT_CSS_NAME
-     * @see JavadocUtil#copyResource(java.net.URL, java.io.File)
-     */
-    private void copyDefaultStylesheet( File anOutputDirectory )
-        throws IOException
-    {
-        if ( StringUtils.isNotEmpty( stylesheetfile ) )
-        {
-            return;
-        }
-
-        if ( !stylesheet.equalsIgnoreCase( "maven" ) )
-        {
-            return;
-        }
-
-        URL url = getClass().getClassLoader().getResource( RESOURCE_CSS_DIR + "/" + DEFAULT_CSS_NAME );
-        File outFile = new File( anOutputDirectory, DEFAULT_CSS_NAME );
-        JavadocUtil.copyResource( url, outFile );
-    }
-
     /**
      * Method that copy all <code>doc-files</code> directories from <code>javadocDirectory</code> of
      * the current project or of the projects in the reactor to the <code>outputDirectory</code>.
diff --git a/src/main/resources/org/apache/maven/plugins/javadoc/css/stylesheet.css b/src/main/resources/org/apache/maven/plugins/javadoc/css/stylesheet.css
deleted file mode 100644
index ec149bb5..00000000
--- a/src/main/resources/org/apache/maven/plugins/javadoc/css/stylesheet.css
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied.  See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-
-/* Javadoc style sheet */
-
-/* Define colors, fonts and other style attributes here to override the defaults  */
-
-/* Page background color */
-body { background-color: #FFFFFF }
-
-a:link, a:visited {
- color: blue;
- }
-
-a:active, a:hover, #leftcol a:active, #leftcol a:hover {
- color: #f30 !important;
- }
-
-a:link.selfref, a:visited.selfref {
- color: #555 !important;
- }
-
-.a td {
- background: #ddd;
- color: #000;
- }
-
-/* Table colors */
-.TableHeadingColor     { background: #036; color:#FFFFFF } /* Dark blue */
-.TableSubHeadingColor  { background: #bbb; color:#fff } /* Dark grey */
-.TableRowColor         { background: #efefef } /* White */
-
-/* Font used in left-hand frame lists */
-.FrameTitleFont   { font-size: medium; font-family: normal; color:#000000 }
-.FrameHeadingFont { font-size: medium; font-family: normal; color:#000000 }
-.FrameItemFont    { font-size: medium; font-family: normal; color:#000000 }
-
-/* Example of smaller, sans-serif font in frames */
-/* .FrameItemFont  { font-size: 10pt; font-family: Helvetica, Arial, sans-serif } */
-
-/* Navigation bar fonts and colors */
-.NavBarCell1    { background-color:#ddd;}/* Light mauve */
-.NavBarCell1Rev { background-color:#888;}/* Dark Blue */
-.NavBarFont1    { font-family: Arial, Helvetica, sans-serif; color:#000000;}
-.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;}
-
-.NavBarCell2    { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;}
-.NavBarCell3    { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;}
diff --git a/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java b/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java
index 4200ec05..b0ff531f 100644
--- a/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java
+++ b/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java
@@ -1284,18 +1284,6 @@ public class JavadocReportTest
         String optionsContent = readFile( options );
         assertFalse( optionsContent.contains( "-stylesheetfile" ) );
 
-        // stylesheet == maven
-        setVariableValueToObject( mojo, "stylesheet", "maven" );
-        mojo.execute();
-
-        content = readFile( stylesheetfile );
-        assertTrue( content.contains( "/* Javadoc style sheet */" )
-            && content.contains( "Licensed to the Apache Software Foundation (ASF) under one" ) );
-
-        optionsContent = readFile( options );
-        assertTrue( optionsContent.contains( "-stylesheetfile" ) );
-        assertTrue( optionsContent.contains( "'" + stylesheetfile.toFile().getAbsolutePath().replaceAll( "\\\\", "/" ) + "'" ) );
-
         // stylesheetfile defined as a project resource
         setVariableValueToObject( mojo, "stylesheet", null );
         setVariableValueToObject( mojo, "stylesheetfile", "com/mycompany/app/javadoc/css/stylesheet.css" );