This is an automated email from the ASF dual-hosted git repository. ddekany pushed a commit to branch 3 in repository https://gitbox.apache.org/repos/asf/freemarker.git
commit 63d7c855931927418bf17a3ed701d55c6204c5d1 Author: ddekany <[email protected]> AuthorDate: Sat Dec 9 21:59:20 2023 +0100 Gradle build: Do not customize javadoc output anymore - It complicates the build, has to be reviewed for new javadoc versions, and almost nobody uses the javadoc HTML-s nowadays. --- .../build/core/JavadocStyleAdjustments.kt | 66 ---------------------- .../build/module/common/JavadocStyleAdjustments.kt | 46 --------------- 2 files changed, 112 deletions(-) diff --git a/buildSrc/core/src/main/kotlin/org/apache/freemarker/build/core/JavadocStyleAdjustments.kt b/buildSrc/core/src/main/kotlin/org/apache/freemarker/build/core/JavadocStyleAdjustments.kt deleted file mode 100644 index beba1b4e..00000000 --- a/buildSrc/core/src/main/kotlin/org/apache/freemarker/build/core/JavadocStyleAdjustments.kt +++ /dev/null @@ -1,66 +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. - */ - -package org.apache.freemarker.build.core - -import java.nio.charset.Charset -import java.nio.file.Files -import org.gradle.api.Action -import org.gradle.api.Task -import org.gradle.api.tasks.javadoc.Javadoc - -class JavadocStyleAdjustments: Action<Task> { - override fun execute(task: Task) { - val javadoc = task as Javadoc - val stylesheetPath = javadoc.destinationDir!!.toPath().resolve("stylesheet.css") - task.logger.info("Fixing JDK 8 ${stylesheetPath}") - - val ddSelectorStart = "(?:\\.contentContainer\\s+\\.(?:details|description)|\\.serializedFormContainer)\\s+dl\\s+dd\\b.*?\\{[^\\}]*\\b" - val ddPropertyEnd = "\\b.+?;" - - val fixRules = listOf( - Pair(Regex("/\\* (Javadoc style sheet) \\*/"), "/\\* \\1 - JDK 8 usability fix regexp substitutions applied \\*/"), - Pair(Regex("@import url\\('resources/fonts/dejavu.css'\\);\\s*"), ""), - Pair(Regex("['\"]DejaVu Sans['\"]"), "Arial"), - Pair(Regex("['\"]DejaVu Sans Mono['\"]"), "'Courier New'"), - Pair(Regex("['\"]DejaVu Serif['\"]"), "Arial"), - Pair(Regex("(?<=[\\s,:])serif\\b"), "sans-serif"), - Pair(Regex("(?<=[\\s,:])Georgia,\\s*"), ""), - Pair(Regex("['\"]Times New Roman['\"],\\s*"), ""), - Pair(Regex("(?<=[\\s,:])Times,\\s*"), ""), - Pair(Regex("(?<=[\\s,:])Arial\\s*,\\s*Arial\\b"), ""), - Pair(Regex("(${ddSelectorStart})margin${ddPropertyEnd}"), "\\1margin: 5px 0 10px 20px;"), - Pair(Regex("(${ddSelectorStart})font-family${ddPropertyEnd}"), "\\1") - ) - - val javadocEncoding = Charset.forName(javadoc.options.encoding) - - var stylesheetContent = String(Files.readAllBytes(stylesheetPath), javadocEncoding) - for (rule in fixRules) { - val prevContent = stylesheetContent - stylesheetContent = stylesheetContent.replace(rule.first, rule.second) - - if (prevContent == stylesheetContent) { - task.logger.warn("Javadoc style sheet did not contain anything matching: ${rule.first}") - } - } - - Files.write(stylesheetPath, stylesheetContent.toByteArray(javadocEncoding)) - } -} diff --git a/buildSrc/module-common/src/main/kotlin/org/apache/freemarker/build/module/common/JavadocStyleAdjustments.kt b/buildSrc/module-common/src/main/kotlin/org/apache/freemarker/build/module/common/JavadocStyleAdjustments.kt index a9cb9bf3..0e1b70b5 100644 --- a/buildSrc/module-common/src/main/kotlin/org/apache/freemarker/build/module/common/JavadocStyleAdjustments.kt +++ b/buildSrc/module-common/src/main/kotlin/org/apache/freemarker/build/module/common/JavadocStyleAdjustments.kt @@ -19,14 +19,10 @@ package org.apache.freemarker.build.module.common -import org.gradle.api.Action -import org.gradle.api.Task import org.gradle.api.plugins.JavaBasePlugin import org.gradle.api.tasks.javadoc.Javadoc import org.gradle.external.javadoc.StandardJavadocDocletOptions -import java.nio.charset.Charset import java.nio.charset.StandardCharsets -import java.nio.file.Files fun configureJavadocDefaults(javadoc: Javadoc) { javadoc.group = JavaBasePlugin.DOCUMENTATION_GROUP @@ -48,46 +44,4 @@ fun configureJavadocDefaults(javadoc: Javadoc) { // There are too many to check addStringOption("Xdoclint:all,-missing", "-quiet") } - - javadoc.doLast(JavadocStyleAdjustments()) -} - -class JavadocStyleAdjustments: Action<Task> { - override fun execute(task: Task) { - val javadoc = task as Javadoc - val stylesheetPath = javadoc.destinationDir!!.toPath().resolve("stylesheet.css") - task.logger.info("Fixing JDK 8 ${stylesheetPath}") - - val ddSelectorStart = "(?:\\.contentContainer\\s+\\.(?:details|description)|\\.serializedFormContainer)\\s+dl\\s+dd\\b.*?\\{[^\\}]*\\b" - val ddPropertyEnd = "\\b.+?;" - - val fixRules = listOf( - Pair(Regex("/\\* (Javadoc style sheet) \\*/"), "/\\* \\1 - JDK 8 usability fix regexp substitutions applied \\*/"), - Pair(Regex("@import url\\('resources/fonts/dejavu.css'\\);\\s*"), ""), - Pair(Regex("['\"]DejaVu Sans['\"]"), "Arial"), - Pair(Regex("['\"]DejaVu Sans Mono['\"]"), "'Courier New'"), - Pair(Regex("['\"]DejaVu Serif['\"]"), "Arial"), - Pair(Regex("(?<=[\\s,:])serif\\b"), "sans-serif"), - Pair(Regex("(?<=[\\s,:])Georgia,\\s*"), ""), - Pair(Regex("['\"]Times New Roman['\"],\\s*"), ""), - Pair(Regex("(?<=[\\s,:])Times,\\s*"), ""), - Pair(Regex("(?<=[\\s,:])Arial\\s*,\\s*Arial\\b"), ""), - Pair(Regex("(${ddSelectorStart})margin${ddPropertyEnd}"), "\\1margin: 5px 0 10px 20px;"), - Pair(Regex("(${ddSelectorStart})font-family${ddPropertyEnd}"), "\\1") - ) - - val javadocEncoding = Charset.forName(javadoc.options.encoding) - - var stylesheetContent = String(Files.readAllBytes(stylesheetPath), javadocEncoding) - for (rule in fixRules) { - val prevContent = stylesheetContent - stylesheetContent = stylesheetContent.replace(rule.first, rule.second) - - if (prevContent == stylesheetContent) { - task.logger.warn("Javadoc style sheet did not contain anything matching: ${rule.first}") - } - } - - Files.write(stylesheetPath, stylesheetContent.toByteArray(javadocEncoding)) - } }
