arianne / stendhal

Stendhal is a fun friendly and free multiplayer online adventure game with an old school feel.
https://arianne-project.org
GNU General Public License v2.0
599 stars 201 forks source link

Cannot Build Java Documentation on Windows #659

Closed AntumDeluge closed 9 months ago

AntumDeluge commented 9 months ago

Note: This bug is likely related to Java & not directly to the Stendhal project.

🐞 Describe the bug

Somewhere between version 1.41 & 1.42 filenames became too long to build Java documentation on Windows. Windows has a limit of 260 characters in path names. I believe this is the cause of the error. According to the article, it is possible to enable long paths in Windows 10. I have set the registry key & rebooted, but still cannot build. I believe the problem is in the second condition: "The application manifest must also include the longPathAware element". I'm guessing the javadoc.exe executable does not include this manifest element. I'm not sure if this is something that can be invoked using a command line parameter in build.xml, or if it needs to be compiled into the executable.

I could move the source code to directory with a shorter root path. But that seems like a temporary solution.

πŸ”₯ How to reproduce

Steps to reproduce the behavior:

  1. After setting up latest source code on a Windows system run ant javadocs.
  2. See error output:
$ ant javadocs
Buildfile: <redacted>\Development\Arianne\stendhal\build.xml

clean_javadocs:

javadocs:
  [javadoc] Generating Javadoc
  [javadoc] Javadoc execution

BUILD FAILED
<redacted>\Development\Arianne\stendhal\buildtools\ant_modules\docs.xml:39: Javadoc failed: java.io.IOException: Cannot run program "<redacted>\Java\jdk\bin\javadoc.exe": CreateProcess error=206, The filename or extension is too long
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
        at java.base/java.lang.Runtime.exec(Runtime.java:594)
        at org.apache.tools.ant.taskdefs.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58)
        at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:424)
        at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:438)
        at org.apache.tools.ant.taskdefs.Javadoc.execute(Javadoc.java:1916)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:299)
        at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
        at org.apache.tools.ant.Task.perform(Task.java:350)
        at org.apache.tools.ant.Target.execute(Target.java:449)
        at org.apache.tools.ant.Target.performTasks(Target.java:470)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1401)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1374)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1264)
        at org.apache.tools.ant.Main.runBuild(Main.java:818)
        at org.apache.tools.ant.Main.startAnt(Main.java:223)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)
Caused by: java.io.IOException: CreateProcess error=206, The filename or extension is too long
        at java.base/java.lang.ProcessImpl.create(Native Method)
        at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:499)
        at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:158)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1110)
        ... 22 more

Total time: 1 second

$ java -version
java version "17.0.6" 2023-01-17 LTS
Java(TM) SE Runtime Environment (build 17.0.6+9-LTS-190)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.6+9-LTS-190, mixed mode, sharing)

It should be noted that the problem occurs in the javadocs target of buildtools/ant_modules/docs.xml on the line <fileset dir="${src}" includes="**/*.java"/>. Removing the "src" directory from the build allows the process to complete.

🌍 Environment

πŸ”­ Additional information

Some other resources I looked at while trying to fix the problem:

javadoc.exe manifest exported with Resource Hacker:

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
    <assemblyIdentity name="javadoc.exe" version="17.0.6.0" processorArchitecture="X86" type="win32"></assemblyIdentity>
    <description>Java(TM) SE process</description>
    <dependency>
        <dependentAssembly>
            <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
        </dependentAssembly>
    </dependency>
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
        <security>
            <requestedPrivileges>
                <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
            </requestedPrivileges>
        </security>
    </trustInfo>
    <asmv3:application>
        <asmv3:windowsSettings xmlns:dpi1="http://schemas.microsoft.com/SMI/2005/WindowsSettings" xmlns:dpi2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
            <dpi1:dpiAware>true/PM</dpi1:dpiAware>
            <dpi2:dpiAwareness>PerMonitorV2, PerMonitor, system</dpi2:dpiAwareness>
        </asmv3:windowsSettings>
    </asmv3:application>
    <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
        <application>
            <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"></supportedOS>
            <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"></supportedOS>
            <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"></supportedOS>
            <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"></supportedOS>
            <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"></supportedOS>
        </application>
    </compatibility>
</assembly>

As per the instructions here, I added the following to the manifests of both javadoc.exe & java.exe, but problem persists:

@@ -14,9 +14,10 @@
                </security>
        </trustInfo>
        <asmv3:application>
-               <asmv3:windowsSettings xmlns:dpi1="http://schemas.microsoft.com/SMI/2005/WindowsSettings" xmlns:dpi2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
-                       <dpi1:dpiAware>true/PM</dpi1:dpiAware>
-                       <dpi2:dpiAwareness>PerMonitorV2, PerMonitor, system</dpi2:dpiAwareness>
+               <asmv3:windowsSettings xmlns:ws1="http://schemas.microsoft.com/SMI/2005/WindowsSettings" xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
+                       <ws1:dpiAware>true/PM</ws1:dpiAware>
+                       <ws2:dpiAwareness>PerMonitorV2, PerMonitor, system</ws2:dpiAwareness>
+                       <ws2:longPathAware>true</ws2:longPathAware>
                </asmv3:windowsSettings>
        </asmv3:application>
        <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
AntumDeluge commented 9 months ago

Looking at the diff of build.xml between version 1.41 & 1.42 it seems the problem is in this change:

       <!-- include marauroa source if available -->
-      <sourcepath path="../marauroa/src/" if:true="${include.marauroa}"/>
-      <sourcepath path="${src}"/>
+      <fileset dir="${marauroa_src}" includes="**/*.java" if:true="${include.marauroa}"/>
+      <fileset dir="${src}" includes="**/*.java"/>

It seems the javadoc executable can't handle the longer names on Windows when using fileset element as opposed to sourcepath.