This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new 970c8a6 [MJAVADOC-625] Support for multiple stylesheets
970c8a6 is described below
commit 970c8a661fa284d1d9b5d3302660bf4f1e4e13e5
Author: Martin Schelldorfer <[email protected]>
AuthorDate: Sat May 1 15:47:49 2021 +0200
[MJAVADOC-625] Support for multiple stylesheets
Signed-off-by: rfscholte <[email protected]>
---
.../MJAVADOC-625_addstylesheet/invoker.properties | 18 +++++++
src/it/projects/MJAVADOC-625_addstylesheet/pom.xml | 46 +++++++++++++++++
.../src/main/java/com/example/MJavaDoc625.java | 28 +++++++++++
.../src/main/javadoc/resources/addstylesheet.css | 23 +++++++++
.../src/main/javadoc/resources/addstylesheets1.css | 23 +++++++++
.../src/main/javadoc/resources/addstylesheets2.css | 23 +++++++++
.../MJAVADOC-625_addstylesheet/verify.groovy | 34 +++++++++++++
.../maven/plugins/javadoc/AbstractJavadocMojo.java | 57 +++++++++++++++++++++-
8 files changed, 250 insertions(+), 2 deletions(-)
diff --git a/src/it/projects/MJAVADOC-625_addstylesheet/invoker.properties
b/src/it/projects/MJAVADOC-625_addstylesheet/invoker.properties
new file mode 100644
index 0000000..b60ab5b
--- /dev/null
+++ b/src/it/projects/MJAVADOC-625_addstylesheet/invoker.properties
@@ -0,0 +1,18 @@
+# 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.
+
+invoker.goals=compile javadoc:javadoc
\ No newline at end of file
diff --git a/src/it/projects/MJAVADOC-625_addstylesheet/pom.xml
b/src/it/projects/MJAVADOC-625_addstylesheet/pom.xml
new file mode 100644
index 0000000..fea976f
--- /dev/null
+++ b/src/it/projects/MJAVADOC-625_addstylesheet/pom.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- 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. -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven.plugins.javadoc.it</groupId>
+ <artifactId>mjavadoc-625</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <url>https://issues.apache.org/jira/browse/MJAVADOC-625</url>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.8.0</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>@project.version@</version>
+ <configuration>
+ <addStylesheets>
+ <addStylesheet>resources/addstylesheet.css</addStylesheet>
+ <addStylesheet>resources/addstylesheets1.css</addStylesheet>
+ <addStylesheet>resources/addstylesheets2.css</addStylesheet>
+ </addStylesheets>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git
a/src/it/projects/MJAVADOC-625_addstylesheet/src/main/java/com/example/MJavaDoc625.java
b/src/it/projects/MJAVADOC-625_addstylesheet/src/main/java/com/example/MJavaDoc625.java
new file mode 100644
index 0000000..163e444
--- /dev/null
+++
b/src/it/projects/MJAVADOC-625_addstylesheet/src/main/java/com/example/MJavaDoc625.java
@@ -0,0 +1,28 @@
+package com.example;
+
+/*
+ * 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.
+ */
+
+/**
+ * MJAVADOC-625 Support for multiple stylesheets
+ */
+public class MJavaDoc625
+{
+
+}
diff --git
a/src/it/projects/MJAVADOC-625_addstylesheet/src/main/javadoc/resources/addstylesheet.css
b/src/it/projects/MJAVADOC-625_addstylesheet/src/main/javadoc/resources/addstylesheet.css
new file mode 100644
index 0000000..02172e1
--- /dev/null
+++
b/src/it/projects/MJAVADOC-625_addstylesheet/src/main/javadoc/resources/addstylesheet.css
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+body
+{
+ font-size: 20px;
+}
\ No newline at end of file
diff --git
a/src/it/projects/MJAVADOC-625_addstylesheet/src/main/javadoc/resources/addstylesheets1.css
b/src/it/projects/MJAVADOC-625_addstylesheet/src/main/javadoc/resources/addstylesheets1.css
new file mode 100644
index 0000000..5d34fde
--- /dev/null
+++
b/src/it/projects/MJAVADOC-625_addstylesheet/src/main/javadoc/resources/addstylesheets1.css
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+h1
+{
+ font-size: 26px;
+}
\ No newline at end of file
diff --git
a/src/it/projects/MJAVADOC-625_addstylesheet/src/main/javadoc/resources/addstylesheets2.css
b/src/it/projects/MJAVADOC-625_addstylesheet/src/main/javadoc/resources/addstylesheets2.css
new file mode 100644
index 0000000..cf005f5
--- /dev/null
+++
b/src/it/projects/MJAVADOC-625_addstylesheet/src/main/javadoc/resources/addstylesheets2.css
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+h2
+{
+ font-size: 24px;
+}
\ No newline at end of file
diff --git a/src/it/projects/MJAVADOC-625_addstylesheet/verify.groovy
b/src/it/projects/MJAVADOC-625_addstylesheet/verify.groovy
new file mode 100644
index 0000000..8a20228
--- /dev/null
+++ b/src/it/projects/MJAVADOC-625_addstylesheet/verify.groovy
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+def file = new File( basedir,
'target/site/apidocs/com/example/MJavaDoc625.html' );
+
+assert file.exists()
+
+def javaVersion = System.getProperty( 'java.specification.version' )
+if( javaVersion ==~ /(1\..+|9\..+)/ )
+{
+ assert new File(basedir, 'build.log').text.contains('--add-stylesheet
option is not supported on Java version < 10')
+}
+else
+{
+ assert 1 == file.text.count('addstylesheet.css')
+ assert 1 == file.text.count('addstylesheets1.css')
+ assert 1 == file.text.count('addstylesheets2.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 1409241..24d008e 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -1423,8 +1423,21 @@ public abstract class AbstractJavadocMojo
* stylesheetfile</a>.
*/
@Parameter( property = "stylesheetfile" )
- private String stylesheetfile;
-
+ private String stylesheetfile;
+
+ /**
+ * Specifies the path of an additional HTML stylesheet file relative to
the {@link #javadocDirectory}
+ * Example:
+ * <pre>
+ * <addStylesheets>
+ * <resources/addstylesheet.css</addStylesheet>
+ * </addStylesheets>
+ * </pre>
+ * @since 3.3.0
+ */
+ @Parameter
+ private String[] addStylesheets;
+
/**
* Specifies the class file that starts the taglet used in generating the
documentation for that tag.
* <br/>
@@ -3028,6 +3041,35 @@ public abstract class AbstractJavadocMojo
return getResource( new File( javadocOutputDirectory, DEFAULT_CSS_NAME
), stylesheetfile );
}
+
+ private String getAddStylesheet( final File javadocOutputDirectory, final
String stylesheet )
+ throws MavenReportException
+ {
+ if ( StringUtils.isEmpty( stylesheet ) )
+ {
+ return null;
+ }
+
+ File addstylesheetfile = new File( getJavadocDirectory(), stylesheet );
+ if ( addstylesheetfile.exists() )
+ {
+ String stylesheetfilename = getStylesheetFile(
javadocOutputDirectory );
+ if ( stylesheetfilename != null )
+ {
+ File stylesheetfile = new File( stylesheetfilename );
+ if ( stylesheetfile.getName().equals(
addstylesheetfile.getName() ) )
+ {
+ throw new MavenReportException( "additional stylesheet
must have a different name "
+ + "than
stylesheetfile: " + stylesheetfile.getName() );
+ }
+ }
+
+ return addstylesheetfile.getAbsolutePath();
+ }
+
+ throw new MavenReportException( "additional stylesheet file does not
exist: "
+ +
addstylesheetfile.getAbsolutePath() );
+ }
/**
* Method to get the help file to be used by the Javadoc Tool.
@@ -5507,6 +5549,17 @@ public abstract class AbstractJavadocMojo
addArgIfNotEmpty( arguments, "-stylesheetfile",
JavadocUtil.quotedPathArgument( getStylesheetFile(
javadocOutputDirectory ) ) );
+
+ if ( addStylesheets != null )
+ {
+ for ( String addStylesheet : addStylesheets )
+ {
+ addArgIfNotEmpty( arguments, "--add-stylesheet",
+ JavadocUtil.quotedPathArgument(
getAddStylesheet( javadocOutputDirectory,
+
addStylesheet ) ),
+ JavaVersion.parse( "10" ) );
+ }
+ }
if ( StringUtils.isNotEmpty( sourcepath ) && !isJavaDocVersionAtLeast(
SINCE_JAVADOC_1_5 ) )
{