Do not overwrite the standard CSS files when Javadoc plugin is executed more than once without "mvn clean".


git-svn-id: https://svn.apache.org/repos/asf/sis/branches/JDK8@1744471 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Doclet.java b/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Doclet.java
index c949770..2f09dc6 100644
--- a/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Doclet.java
+++ b/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Doclet.java
@@ -50,7 +50,7 @@
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5
- * @version 0.5
+ * @version 0.7
  * @module
  */
 public final class Doclet extends HtmlDoclet {
@@ -97,7 +97,7 @@
             copyResources(customCSS.getParentFile(), output);
             final Rewriter r = new Rewriter();
             for (final File file : output.listFiles()) {
-                if (file.isDirectory()) {  // Do not process files in the root directory, only in sub-directories.
+                if (file.isDirectory()) {       // Do not process files in the root directory, only in sub-directories.
                     r.processDirectory(file);
                 }
             }
@@ -148,6 +148,7 @@
 
     /**
      * Copies the standard CSS file, then copies the custom CSS file.
+     * If the {@value #RENAMED_CSS} file already exists, it will not be overwritten.
      *
      * @param  inputFile        The custom CSS file to copy in the destination directory.
      * @param  outputDirectory  The directory where to copy the CSS file.
@@ -156,29 +157,31 @@
     private static void copyStylesheet(final File inputFile, final File outputDirectory) throws IOException {
         final File stylesheetFile = new File(outputDirectory, STYLESHEET);
         final File standardFile   = new File(outputDirectory, RENAMED_CSS);
-        /*
-         * Copy the standard CSS file, skipping the import of DejaVu font
-         * since our custom CSS file does not use it.
-         */
-        BufferedReader in  = openReader(stylesheetFile);
-        BufferedWriter out = openWriter(standardFile);
-        try {
-            String line;
-            while ((line = in.readLine()) != null) {
-                if (!line.equals("@import url('resources/fonts/dejavu.css');")) {
-                    out.write(line);
-                    out.newLine();
+        if (!standardFile.exists()) {
+            /*
+             * Copy the standard CSS file, skipping the import of DejaVu font
+             * since our custom CSS file does not use it.
+             */
+            BufferedReader in  = openReader(stylesheetFile);
+            BufferedWriter out = openWriter(standardFile);
+            try {
+                String line;
+                while ((line = in.readLine()) != null) {
+                    if (!line.equals("@import url('resources/fonts/dejavu.css');")) {
+                        out.write(line);
+                        out.newLine();
+                    }
                 }
+            } finally {
+                out.close();
+                in.close();
             }
-        } finally {
-            out.close();
-            in.close();
         }
         /*
          * Copy the custom CSS file, skipping comments for more compact file.
          */
-        in  = openReader(inputFile);
-        out = openWriter(stylesheetFile);
+        BufferedReader in  = openReader(inputFile);
+        BufferedWriter out = openWriter(stylesheetFile);
         try {
             String line;
             while ((line = in.readLine()) != null) {
diff --git a/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/package-info.java b/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/package-info.java
index 8ae4446..62f15e6 100644
--- a/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/package-info.java
+++ b/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/package-info.java
@@ -21,7 +21,7 @@
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5
- * @version 0.5
+ * @version 0.7
  * @module
  */
 package org.apache.sis.internal.doclet;