From ebde546af6d92545416c37ba52c5b0f57ce28546 Mon Sep 17 00:00:00 2001 From: Konrad Windszus Date: Tue, 20 Sep 2022 10:20:16 +0200 Subject: [PATCH] [MJAVADOC-685] Deprecate parameter "stylesheet" (#162) Remove custom Maven stylesheet CSS as incompatible with javadoc at least since JDK8 --- .../plugins/javadoc/AbstractJavadocMojo.java | 70 +++---------------- .../maven/plugins/javadoc/css/stylesheet.css | 64 ----------------- .../plugins/javadoc/JavadocReportTest.java | 12 ---- 3 files changed, 11 insertions(+), 135 deletions(-) delete mode 100644 src/main/resources/org/apache/maven/plugins/javadoc/css/stylesheet.css 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 91d734ff7..08d9e9584 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 @@ */ 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 maven's javadoc stylesheet or - * java's default stylesheet when a stylesheetfile parameter is not specified. + * java's default stylesheet when a {@link #stylesheetfile} parameter is not specified. *
* Possible values: maven or java. - *
+ * @deprecated This is no longer evaluated, instead use {@link #addStylesheets} to customize the CSS. */ @Parameter( property = "stylesheet", defaultValue = "java" ) + @Deprecated private String stylesheet; /** @@ -2908,11 +2899,11 @@ private String getBottomText() /** * Method to get the stylesheet path file to be used by the Javadoc Tool. *
- * 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. *
- * If the {@code stylesheetfile} is defined, return the file as String. + * If the {@link #stylesheetfile} is defined, return the file as String. *
- * 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. src/main/java, src/main/resources or src/main/javadoc) * or from a resource in the Javadoc plugin dependencies. * @@ -2930,8 +2921,9 @@ private Optional getStylesheetFile( final File javadocOutputDirectory ) 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 @@ private void addLinkArguments( List arguments ) 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 @@ private void copyAllResources( File javadocOutputDirectory ) copyAdditionalJavadocResources( javadocOutputDirectory ); } - /** - * Copies the {@code DEFAULT_CSS_NAME} css file from the current class - * loader to the outputDirectory only if {@code stylesheetfile} is empty and - * {@code stylesheet} is equals to maven. - * - * @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 doc-files directories from javadocDirectory of * the current project or of the projects in the reactor to the outputDirectory. 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 ec149bb5d..000000000 --- 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 4200ec055..b0ff531f7 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 @@ else if ( JavaVersion.JAVA_VERSION.isAtLeast( "10" ) ) 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" );