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

rfscholte pushed a commit to branch MJAVADOC-625
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git

commit e9891bf8c7fa15d54147f39cc2bd79d52ef55f4a
Author: Martin Schelldorfer <[email protected]>
AuthorDate: Mon Oct 21 09:55:51 2019 +0200

    Support for multiple stylesheets
    
    (cherry picked from commit 93390aa968a09e5a0f0e05998017967ccb7805ba)
---
 src/it/projects/MJAVADOC-625/pom.xml               | 84 +++++++++++-----------
 .../main/javadoc/resources/addstylesheets1.css}    | 13 ++--
 .../main/javadoc/resources/addstylesheets2.css}    | 13 ++--
 src/it/projects/MJAVADOC-625/verify.groovy         |  2 +
 .../maven/plugins/javadoc/AbstractJavadocMojo.java | 36 ++++++++--
 5 files changed, 84 insertions(+), 64 deletions(-)

diff --git a/src/it/projects/MJAVADOC-625/pom.xml 
b/src/it/projects/MJAVADOC-625/pom.xml
index 6e26644..ecf3b83 100644
--- a/src/it/projects/MJAVADOC-625/pom.xml
+++ b/src/it/projects/MJAVADOC-625/pom.xml
@@ -1,50 +1,48 @@
 <?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
+<!-- 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. -->
 
-  http://www.apache.org/licenses/LICENSE-2.0
+<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>
 
-  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.
--->
+       <url>https://issues.apache.org/jira/browse/MJAVADOC-625</url>
 
-<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> -->
+                               <groupId>com.github.schelldorfer</groupId>
+                               <artifactId>maven-javadoc-plugin</artifactId>
+                               <version>3.1.2</version>
+                               <configuration>
+                                       
<addStylesheet>src/main/javadoc/resources/addstylesheet.css</addStylesheet>
+                                       <addStylesheets>
+                                               
<addStylesheet>src/main/javadoc/resources/addstylesheets1.css</addStylesheet>
+                                               
<addStylesheet>src/main/javadoc/resources/addstylesheets2.css</addStylesheet>
+                                       </addStylesheets>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
 
-  <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>
-            
<addStylesheet>src/main/javadoc/resources/addstylesheet.css</addStylesheet>
-          </configuration>
-        </plugin>
-      </plugins>
-  </build>
-  
 </project>
diff --git a/src/it/projects/MJAVADOC-625/verify.groovy 
b/src/it/projects/MJAVADOC-625/src/main/javadoc/resources/addstylesheets1.css
similarity index 83%
copy from src/it/projects/MJAVADOC-625/verify.groovy
copy to 
src/it/projects/MJAVADOC-625/src/main/javadoc/resources/addstylesheets1.css
index 05ca2c5..5d34fde 100644
--- a/src/it/projects/MJAVADOC-625/verify.groovy
+++ 
b/src/it/projects/MJAVADOC-625/src/main/javadoc/resources/addstylesheets1.css
@@ -6,9 +6,9 @@
  * 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
@@ -17,8 +17,7 @@
  * under the License.
  */
 
-def file = new File( basedir, 
'target/site/apidocs/com/example/MJavaDoc625.html' );
-
-assert file.exists()
-
-assert 1 == file.text.count('addstylesheet.css')
+h1
+{
+   font-size: 26px;
+}
\ No newline at end of file
diff --git a/src/it/projects/MJAVADOC-625/verify.groovy 
b/src/it/projects/MJAVADOC-625/src/main/javadoc/resources/addstylesheets2.css
similarity index 83%
copy from src/it/projects/MJAVADOC-625/verify.groovy
copy to 
src/it/projects/MJAVADOC-625/src/main/javadoc/resources/addstylesheets2.css
index 05ca2c5..cf005f5 100644
--- a/src/it/projects/MJAVADOC-625/verify.groovy
+++ 
b/src/it/projects/MJAVADOC-625/src/main/javadoc/resources/addstylesheets2.css
@@ -6,9 +6,9 @@
  * 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
@@ -17,8 +17,7 @@
  * under the License.
  */
 
-def file = new File( basedir, 
'target/site/apidocs/com/example/MJavaDoc625.html' );
-
-assert file.exists()
-
-assert 1 == file.text.count('addstylesheet.css')
+h2
+{
+   font-size: 24px;
+}
\ No newline at end of file
diff --git a/src/it/projects/MJAVADOC-625/verify.groovy 
b/src/it/projects/MJAVADOC-625/verify.groovy
index 05ca2c5..8cd0936 100644
--- a/src/it/projects/MJAVADOC-625/verify.groovy
+++ b/src/it/projects/MJAVADOC-625/verify.groovy
@@ -22,3 +22,5 @@ def file = new File( basedir, 
'target/site/apidocs/com/example/MJavaDoc625.html'
 assert file.exists()
 
 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 6d56a95..ccad2e1 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -1427,10 +1427,24 @@ public abstract class AbstractJavadocMojo
     
     /**
      * Specifies the path of an additional HTML stylesheet file.
+     * @since 3.1.2
      */
     @Parameter
     private String addStylesheet;
     
+    /**
+     * Specifies the path of an additional HTML stylesheet file.
+     * Example:
+     * <pre>
+     *     &lt;addStylesheets&gt;
+     *         
&lt;src/main/javadoc/resources/addstylesheet.css&lt;/addStylesheet&gt;
+     *     &lt;/addStylesheets&gt;
+     * </pre>
+     * @since 3.1.2
+     */
+    @Parameter
+    private String[] addStylesheets;
+    
     /**
      * Specifies the class file that starts the taglet used in generating the 
documentation for that tag.
      * <br/>
@@ -3035,21 +3049,21 @@ public abstract class AbstractJavadocMojo
         return getResource( new File( javadocOutputDirectory, DEFAULT_CSS_NAME 
), stylesheetfile );
     }
     
-    private String getAddStylesheet( final File javadocOutputDirectory )
+    private String getAddStylesheet( final File javadocOutputDirectory, final 
String stylesheet )
             throws MavenReportException
     {
-        if ( StringUtils.isEmpty( addStylesheet ) )
+        if ( StringUtils.isEmpty( stylesheet ) )
         {
             return null;
         }
         
-        File addstylesheetfile = new File( addStylesheet );
+        File addstylesheetfile = new File( stylesheet );
         if ( addstylesheetfile.exists() )
         {
-            String stylesheet = getStylesheetFile( javadocOutputDirectory );
-            if ( stylesheet != null )
+            String stylesheetfilename = getStylesheetFile( 
javadocOutputDirectory );
+            if ( stylesheetfilename != null )
             {
-                File stylesheetfile = new File( stylesheet );
+                File stylesheetfile = new File( stylesheetfilename );
                 if ( stylesheetfile.getName().equals( 
addstylesheetfile.getName() ) )
                 {
                     throw new MavenReportException( "additional stylesheet 
must have a different name "
@@ -5544,7 +5558,15 @@ public abstract class AbstractJavadocMojo
                           JavadocUtil.quotedPathArgument( getStylesheetFile( 
javadocOutputDirectory ) ) );
         
         addArgIfNotEmpty( arguments, "--add-stylesheet",
-                          JavadocUtil.quotedPathArgument( getAddStylesheet( 
javadocOutputDirectory ) ) );
+                          JavadocUtil.quotedPathArgument( getAddStylesheet( 
javadocOutputDirectory, addStylesheet ) ) );
+        if ( addStylesheets != null && addStylesheets.length != 0 )
+        {
+            for ( String as : addStylesheets )
+            {
+                addArgIfNotEmpty( arguments, "--add-stylesheet",
+                        JavadocUtil.quotedPathArgument( getAddStylesheet( 
javadocOutputDirectory, as ) ) );
+            }
+        }
 
         if ( StringUtils.isNotEmpty( sourcepath ) && !isJavaDocVersionAtLeast( 
SINCE_JAVADOC_1_5 ) )
         {

Reply via email to