Jesus Salvo created MJAVADOC-671:
------------------------------------

             Summary: Generated javadoc.bat fails to execute in Windows10
                 Key: MJAVADOC-671
                 URL: https://issues.apache.org/jira/browse/MJAVADOC-671
             Project: Maven Javadoc Plugin
          Issue Type: Bug
          Components: javadoc
    Affects Versions: 3.2.0
            Reporter: Jesus Salvo
         Attachments: scratch.zip

In Windows10, I am consistently having this error generated:


{code:java}
[ERROR] Failed to execute goal 
org.apache.maven.plugins:maven-javadoc-plugin:3.2.0:jar (attach-javadocs) on 
project work: MavenReportException: Error while generating Javadoc:
[ERROR] Exit code: 1 - javadoc: error - cannot read options (The system cannot 
find the file specified)
[ERROR]
[ERROR] Command line was: cmd.exe /X /C 
"C:\java\x64\1.8.0-282-openjdk\jre\..\bin\javadoc.exe @options @argfile"
[ERROR]
[ERROR] Refer to the generated Javadoc files in 
'C:\projects\scratch\work\target\apidocs' dir. {code}
 

[^scratch.zip]

Extract the contents of the attached scratch.zip into Windows10, then simply 
run `mvn clean package` from the scratch directory, and you get the above error.

The error is not generated in Linux.
h2. *Investigations done*

When `mvn clean package` fails in Windows10, if you change directory 
target\apidocs and run the generated *javadoc.bat* file directly, you get the 
exact same error above:
{code:java}
C:\projects\scratch\work\target\apidocs>
C:\projects\scratch\work\target\apidocs>javadoc.bat

C:\projects\scratch\work\target\apidocs>cmd.exe /X /C 
"C:\java\x64\1.8.0-282-openjdk\jre\..\bin\javadoc.exe @options @argfile"
javadoc: error - cannot read options (The system cannot find the file specified)
1 error {code}
 

If I then modify the generated *javadoc.bat* file so that, instead of having 
this:

{code:java}
cmd.exe /X /C "C:\java\x64\1.8.0-282-openjdk\jre\..\bin\javadoc.exe @options 
@argfile" {code}
you replace it with this: 

{code:java}
cmd.exe /X /C "cd C:\projects\scratch\work\target\apidocs && 
C:\java\x64\1.8.0-282-openjdk\jre\..\bin\javadoc.exe @options @argfile"{code}
... essentially ensuring the current and working directory of the shell 
executed by cmd.exe is that apidocs directory, then execute *javadoc.bat* 
again, the issue is resolved :


{code:java}
C:\projects\scratch\work\target\apidocs>cmd.exe /X /C "cd 
C:\projects\scratch\work\target\apidocs && 
C:\java\x64\1.8.0-282-openjdk\jre\..\bin\javadoc.exe @options @argfile"
Loading source file 
C:\projects\scratch\work\src\main\java\org\examples\Bar.java...
Loading source file 
C:\projects\scratch\work\src\main\java\org\examples\Foo.java...
Constructing Javadoc information...
Standard Doclet version 1.8.0_282
Building tree for all the packages and classes...
Generating C:\projects\scratch\work\target\apidocs\org\examples\Bar.html...
Generating C:\projects\scratch\work\target\apidocs\org\examples\Foo.html...
Generating 
C:\projects\scratch\work\target\apidocs\org\examples\package-frame.html...
Generating 
C:\projects\scratch\work\target\apidocs\org\examples\package-summary.html...
Generating 
C:\projects\scratch\work\target\apidocs\org\examples\package-tree.html...
Generating C:\projects\scratch\work\target\apidocs\constant-values.html...
Generating 
C:\projects\scratch\work\target\apidocs\org\examples\class-use\Bar.html...
Generating 
C:\projects\scratch\work\target\apidocs\org\examples\class-use\Foo.html...
Generating 
C:\projects\scratch\work\target\apidocs\org\examples\package-use.html...
Building index for all the packages and classes...
Generating C:\projects\scratch\work\target\apidocs\overview-tree.html...
Generating C:\projects\scratch\work\target\apidocs\index-all.html...
Generating C:\projects\scratch\work\target\apidocs\deprecated-list.html...
Building index for all classes...
Generating C:\projects\scratch\work\target\apidocs\allclasses-frame.html...
Generating C:\projects\scratch\work\target\apidocs\allclasses-noframe.html...
Generating C:\projects\scratch\work\target\apidocs\index.html...
Generating C:\projects\scratch\work\target\apidocs\help-doc.html... {code}
 

This seems to be due to the way in Windows10 what the default directory is when 
cmd.exe is executed, which is slightly different compared to Windows7, which I 
also posted the  question to stackoverflow:

[https://stackoverflow.com/questions/66165972/windows10-cmd-exe-default-directory-different-to-windows7]
h2. *Suggested fix*

If the detected operation system is Windows10, add a "cd ..." command to ensure 
that javadoc.exe is executed from the correct directory.

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to