Repository: mockito/mockito
Issue: task mockitoJavadoc fails when compiling in windows

When compiling the mockito project using gradle in a command line in Windows following compile error occurs:

javadoc: error - Illegal package name: "<script"
javadoc: error - Illegal package name: "type="
javadoc: error - Illegal package name: "text/javascript"
javadoc: error - Illegal package name: "src="
javadoc: error - Illegal package name: "{@docRoot}/js/jdk6-project-version-insert.js"
javadoc: error - Illegal package name: "></script>"
javadoc: error - Illegal package name: "<script"
javadoc: error - Illegal package name: "type="
javadoc: error - Illegal package name: "text/javascript"
javadoc: error - Illegal package name: "src="
javadoc: error - Illegal package name: "{@docRoot}/js/jquery-1.7.min.js"
javadoc: error - Illegal package name: "></script>"
javadoc: error - Illegal package name: "<script"
javadoc: error - Illegal package name: "type="
javadoc: error - Illegal package name: "text/javascript"
javadoc: error - Illegal package name: "src="
javadoc: error - Illegal package name: "{@docRoot}/js/highlight-8.6-java/highlight.pack.js"
javadoc: error - Illegal package name: "></script>"
javadoc: error - Illegal package name: "<link"
javadoc: error - Illegal package name: "rel="
javadoc: error - Illegal package name: "type="
javadoc: error - Illegal package name: "text/css"
javadoc: error - Illegal package name: "href="
javadoc: error - Illegal package name: "{@docRoot}/js/highlight-8.6-java/styles/obsidian.css"
javadoc: error - Illegal package name: "/>"
javadoc: error - Illegal package name: "<script"
javadoc: error - Illegal package name: "type="
javadoc: error - Illegal package name: "text/javascript"
javadoc: error - Illegal package name: ">"
javadoc: error - Illegal package name: "="
javadoc: error - Illegal package name: "&&"
javadoc: error - Illegal package name: "parseInt($.browser.version)"
javadoc: error - Illegal package name: "<"
javadoc: error - Illegal package name: "9;"
javadoc: error - Illegal package name: "if(!usingOldIE)"
javadoc: error - Illegal package name: "{"
javadoc: error - Illegal package name: "$("
javadoc: error - Illegal package name: ").append("
javadoc: error - Illegal package name: "<link rel=\"
javadoc: error - Illegal package name: "icon\\"
javadoc: error - Illegal package name: " href=\"
javadoc: error - Illegal package name: "{@docRoot}/favicon.ico?v=cafebabe\\"
javadoc: error - Illegal package name: ">"
javadoc: error - Illegal package name: ")"
javadoc: error - Illegal package name: "$("
javadoc: error - Illegal package name: ","
javadoc: error - Illegal package name: "window.parent.document).append("
javadoc: error - Illegal package name: "<link rel=\"
javadoc: error - Illegal package name: "icon\\"
javadoc: error - Illegal package name: " href=\"
javadoc: error - Illegal package name: "{@docRoot}/favicon.ico?v=cafebabe\\"
javadoc: error - Illegal package name: ">"
javadoc: error - Illegal package name: ")"
javadoc: error - Illegal package name: "hljs.initHighlightingOnLoad();"
javadoc: error - Illegal package name: "injectProjectVersionForJavadocJDK6("
javadoc: error - Illegal package name: "Mockito 2.0.29-beta API"
javadoc: error - Illegal package name: ","
javadoc: error - Illegal package name: "em#mockito-version-header-javadoc7-header"
javadoc: error - Illegal package name: ","
javadoc: error - Illegal package name: "em#mockito-version-header-javadoc7-footer"
javadoc: error - Illegal package name: ");"
javadoc: error - Illegal package name: "}"
javadoc: error - Illegal package name: "</script>"
javadoc: error - Illegal package name: ""
javadoc: warning - No source files for package stylesheet
javadoc: warning - No source files for package var
javadoc: warning - No source files for package usingOldIE
javadoc: warning - No source files for package $.browser.msie
javadoc: warning - No source files for package head
javadoc: warning - No source files for package shortcut
javadoc: warning - No source files for package head
javadoc: warning - No source files for package shortcut
64 errors
8 warnings

I tracked the issue down to gradle/javadoc.gradle where the gradle scripts sets the bottom property to a java script with multiple lines. 

Changing that to a single line seems to be make it possible to complete the mockitoJavaDoc task without any errors.


Issue comments:
I think most of us work on Linux/OSX, it probably has to do with the JDK
version and windows line endings.

So minifying this javascript code may work ?

-- Brice

On Fri, Jul 10, 2015 at 8:19 AM, Meang Akira Tanaka <
notifications@github.com> wrote:

> When compiling the mockito project using gradle in a command line in
> Windows following compile error occurs:
> 
> javadoc: error - Illegal package name: " javadoc: error - Illegal package
> name: "type="
> javadoc: error - Illegal package name: "text/javascript"
> javadoc: error - Illegal package name: "src="
> javadoc: error - Illegal package name:
> "{@docRoot}/js/jdk6-project-version-insert.js"
> javadoc: error - Illegal package name: ">"
> javadoc: error - Illegal package name: " javadoc: error - Illegal package
> name: "type="
> javadoc: error - Illegal package name: "text/javascript"
> javadoc: error - Illegal package name: "src="
> javadoc: error - Illegal package name: "{@docRoot}/js/jquery-1.7.min.js"
> javadoc: error - Illegal package name: ">"
> javadoc: error - Illegal package name: " javadoc: error - Illegal package
> name: "type="
> javadoc: error - Illegal package name: "text/javascript"
> javadoc: error - Illegal package name: "src="
> javadoc: error - Illegal package name:
> "{@docRoot}/js/highlight-8.6-java/highlight.pack.js"
> javadoc: error - Illegal package name: ">"
> javadoc: error - Illegal package name: " javadoc: error - Illegal package
> name: "rel="
> javadoc: error - Illegal package name: "type="
> javadoc: error - Illegal package name: "text/css"
> javadoc: error - Illegal package name: "href="
> javadoc: error - Illegal package name:
> "{@docRoot}/js/highlight-8.6-java/styles/obsidian.css"
> javadoc: error - Illegal package name: "/>"
> javadoc: error - Illegal package name: " javadoc: error - Illegal package
> name: "type="
> javadoc: error - Illegal package name: "text/javascript"
> javadoc: error - Illegal package name: ">"
> javadoc: error - Illegal package name: "="
> javadoc: error - Illegal package name: "&&"
> javadoc: error - Illegal package name: "parseInt($.browser.version)"
> javadoc: error - Illegal package name: "<"
> javadoc: error - Illegal package name: "9;"
> javadoc: error - Illegal package name: "if(!usingOldIE)"
> javadoc: error - Illegal package name: "{"
> javadoc: error - Illegal package name: "$("
> javadoc: error - Illegal package name: ").append("
> javadoc: error - Illegal package name: " javadoc: error - Illegal package
> name: "icon\"
> javadoc: error - Illegal package name: " href=\"
> javadoc: error - Illegal package name:
> "{@docRoot}/favicon.ico?v=cafebabe\"
> javadoc: error - Illegal package name: ">"
> javadoc: error - Illegal package name: ")"
> javadoc: error - Illegal package name: "$("
> javadoc: error - Illegal package name: ","
> javadoc: error - Illegal package name: "window.parent.document).append("
> javadoc: error - Illegal package name: " javadoc: error - Illegal package
> name: "icon\"
> javadoc: error - Illegal package name: " href=\"
> javadoc: error - Illegal package name:
> "{@docRoot}/favicon.ico?v=cafebabe\"
> javadoc: error - Illegal package name: ">"
> javadoc: error - Illegal package name: ")"
> javadoc: error - Illegal package name: "hljs.initHighlightingOnLoad();"
> javadoc: error - Illegal package name:
> "injectProjectVersionForJavadocJDK6("
> javadoc: error - Illegal package name: "Mockito 2.0.29-beta API"
> javadoc: error - Illegal package name: ","
> javadoc: error - Illegal package name:
> "em#mockito-version-header-javadoc7-header"
> javadoc: error - Illegal package name: ","
> javadoc: error - Illegal package name:
> "em#mockito-version-header-javadoc7-footer"
> javadoc: error - Illegal package name: ");"
> javadoc: error - Illegal package name: "}"
> javadoc: error - Illegal package name: ""
> javadoc: error - Illegal package name: ""
> javadoc: warning - No source files for package stylesheet
> javadoc: warning - No source files for package var
> javadoc: warning - No source files for package usingOldIE
> javadoc: warning - No source files for package $.browser.msie
> javadoc: warning - No source files for package head
> javadoc: warning - No source files for package shortcut
> javadoc: warning - No source files for package head
> javadoc: warning - No source files for package shortcut
> 64 errors
> 8 warnings
> 
> I tracked the issue down to gradle/javadoc.gradle where the gradle scripts
> sets the bottom property to a java script with multiple lines.
> 
> Changing that to a single line seems to be make it possible to complete
> the mockitoJavaDoc task without any errors.
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/mockito/mockito/issues/256.

Fixed via 34f8c69

Hi Brice

Unfortunately it did not work... I have submitted an alternative suggestion

br

Meang


Pull request review comments:
Good idea !


Patch that resolved the issue:
diff --git a/gradle/javadoc.gradle b/gradle/javadoc.gradle
index 55052e9f3e..4d5daa5d43 100644
--- a/gradle/javadoc.gradle
+++ b/gradle/javadoc.gradle
@@ -40,8 +40,8 @@ task mockitoJavadoc(type: Javadoc) {
         <script type="text/javascript">
           var usingOldIE = \$.browser.msie && parseInt(\$.browser.version) < 9;
           if(!usingOldIE) {
-              \$("head").append("<link rel=\\"shortcut icon\\" href=\\"{@docRoot}/favicon.ico?v=cafebabe\\">")
-              \$("head", window.parent.document).append("<link rel=\\"shortcut icon\\" href=\\"{@docRoot}/favicon.ico?v=cafebabe\\">")
+              \$("head").append("<link rel=\\"shortcut icon\\" href=\\"{@docRoot}/favicon.ico?v=cafebabe\\">");
+              \$("head", window.parent.document).append("<link rel=\\"shortcut icon\\" href=\\"{@docRoot}/favicon.ico?v=cafebabe\\">");
               hljs.initHighlightingOnLoad();
               \$("pre.code").css("font-size", "0.9em");
               injectProjectVersionForJavadocJDK6("Mockito ${project.version} API",
@@ -49,7 +49,7 @@ task mockitoJavadoc(type: Javadoc) {
                                                  "em#mockito-version-header-javadoc7-footer");
           }
         </script>
-    """)
+    """.replaceAll(/\r|\n/, ""))
 //    options.stylesheetFile file("src/javadoc/stylesheet.css")
 //    options.addStringOption('top', 'some html')
     if (JavaVersion.current().isJava8Compatible()) {


Test patch: