Javadoc generation fails because of invalid/missing packages of dependency

Hey all I am new to gradle and currently trying to port my maven setup to gradle. I encounter issues using the javadocJar task and would like to ask if you can point me in the right direction?
build.gradle: Plugily Paste
project on github (uses maven): Plugily-Projects/ScoreboardLib at development (github.com)

BuildScan to see the issue:
Build Scan™ for ‘scoreboard’ just now | Gradle Cloud Services

Basically my question is now:
Can I define the javadoc process to only javadoc classes without dependencies and build the doc jar or are there any other options?

(Removing the causing dependdencies from the code solves the javadoc building… but that would mean I can’t use the dependency anymore which would be bad…)

This is a bug in the JavaDoc tool I’d say.
It does not happen with Maven because it additionally sets the -sourcepath option.
But according to the JavaDoc tool documentation that option should only have an effect if you tell the tool to document a package. Then it should look in the specified path, otherwise in the current path and beneath.

As concrete files to be documented are specified, the JavaDoc tool should not search for packages and thus the option should be irrelevant. And even if packages were given, it seems the tool finds Java files that are in JARs on the classpath, which also does not sound correct per-se. Besides that it is imho a packaging error of that protocol support library, as they package their .java files alongside their .class files.

So I would recommend you report a bug to that library, so they do not package the sources, a second one to the JavaDoc tool, that considers these files, and as a work-around you can set the -sourcepath option for the javdoc task like

javadoc {
    options.addFileOption 'sourcepath', ...
}

Hey, thank you for your answer. The mentioned workaround did not work for me it throws the same issue. Yeah of course I could report it but I don’t think that they are fixing it soon. The project seems to be a bit inactive. May its a issue on jitpack itself as it gets them from jitpack?

JitPack generally is broken by design imho and should be avoided wherever possible, except for short-term testing with specific branches or commits, but not for production releases, but that’s a different topic.

While JitPack manipulates things like artifact coordinates and metadata files (and sometimes fails to do it properly) which files are packed into an artifact should usually not be affected, but a problem of the actual build, but I didn’t inspect that project whether it is the case or not.

Whether it will be fixed in that library and in the JavaDoc tool is a separate topic of course, but nevertheless it should imho be reported, because if it is not reported, it for sure does not get fixed. :slight_smile:

But yeah, both projects will probably not fix it short-term, which is why I provided you with the work-around too. I tested it in your project, so it does work, maybe you did not do it correctly? I didn’t give the full code, because I just tested it quickly hackily with addStringOption and the hard-coded local path to the respective directory, but the proper work-around should use addFileOption.
If it does not work how you tried it, maybe provide the build script variant you tried, and also the build/tmp/javadoc/javadoc.options file.

here you go.

-classpath 'E:\\Development\\IdeaProjects\\ScoreboardLib\\build\\classes\\java\\main;E:\\Development\\IdeaProjects\\ScoreboardLib\\build\\resources\\main;C:\\Users\\Max\\.gradle\\caches\\modules-2\\files-2.1\\org.spigotmc\\spigot-api\\1.12.2-R0.1-SNAPSHOT\\a38cb171545121dc90ca6bcaf5072c4ec9bc9ca6\\spigot-api-1.12.2-R0.1-SNAPSHOT.jar;C:\\Users\\Max\\.gradle\\caches\\modules-2\\files-2.1\\com.viaversion\\viaversion-api\\4.0.0\\3a1e72a1cb52bacae346747433189f4161b4e586\\viaversion-api-4.0.0.jar;C:\\Users\\Max\\.gradle\\caches\\modules-2\\files-2.1\\com.github.ProtocolSupport\\ProtocolSupport\\master\\148f0673030ccf39b7073b944892397f0aa8ea56\\ProtocolSupport-master.jar;C:\\Users\\Max\\.gradle\\caches\\modules-2\\files-2.1\\commons-lang\\commons-lang\\2.6\\ce1edb914c94ebc388f086c6827e8bdeec71ac2\\commons-lang-2.6.jar;C:\\Users\\Max\\.gradle\\caches\\modules-2\\files-2.1\\com.googlecode.json-simple\\json-simple\\1.1.1\\c9ad4a0850ab676c5c64461a05ca524cdfff59f1\\json-simple-1.1.1.jar;C:\\Users\\Max\\.gradle\\caches\\modules-2\\files-2.1\\net.md-5\\bungeecord-chat\\1.12-SNAPSHOT\\8dc8702a89837c3fbd25081519b78cfd93bd99c7\\bungeecord-chat-1.12-SNAPSHOT.jar;C:\\Users\\Max\\.gradle\\caches\\modules-2\\files-2.1\\com.google.guava\\guava\\21.0\\3a3d111be1be1b745edfa7d91678a12d7ed38709\\guava-21.0.jar;C:\\Users\\Max\\.gradle\\caches\\modules-2\\files-2.1\\com.google.code.gson\\gson\\2.8.5\\f645ed69d595b24d4cf8b3fbb64cc505bede8829\\gson-2.8.5.jar;C:\\Users\\Max\\.gradle\\caches\\modules-2\\files-2.1\\org.yaml\\snakeyaml\\1.19\\2d998d3d674b172a588e54ab619854d073f555b5\\snakeyaml-1.19.jar;C:\\Users\\Max\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.commons\\commons-lang3\\3.8.1\\6505a72a097d9270f7a9e7bf42c4238283247755\\commons-lang3-3.8.1.jar;C:\\Users\\Max\\.gradle\\caches\\modules-2\\files-2.1\\it.unimi.dsi\\fastutil\\8.2.2\\975aab42e32a96ecb9696971a87c87a049055452\\fastutil-8.2.2.jar;C:\\Users\\Max\\.gradle\\caches\\modules-2\\files-2.1\\junit\\junit\\4.10\\e4f1766ce7404a08f45d859fb9c226fc9e41a861\\junit-4.10.jar;C:\\Users\\Max\\.gradle\\caches\\modules-2\\files-2.1\\org.hamcrest\\hamcrest-core\\1.1\\860340562250678d1a344907ac75754e259cdb14\\hamcrest-core-1.1.jar'
-d 'E:\\Development\\IdeaProjects\\ScoreboardLib\\build\\docs\\javadoc'
-doctitle 'scoreboard 1.2.1-SNAPSHOT1 API'
-encoding 'UTF-8'
-notimestamp 
-quiet 
-windowtitle 'scoreboard 1.2.1-SNAPSHOT1 API'
'E:\\Development\\IdeaProjects\\ScoreboardLib\\src\\main\\java\\me\\tigerhix\\lib\\scoreboard\\ScoreboardLib.java'
'E:\\Development\\IdeaProjects\\ScoreboardLib\\src\\main\\java\\me\\tigerhix\\lib\\scoreboard\\common\\EntryBuilder.java'
'E:\\Development\\IdeaProjects\\ScoreboardLib\\src\\main\\java\\me\\tigerhix\\lib\\scoreboard\\common\\animate\\AnimatableString.java'
'E:\\Development\\IdeaProjects\\ScoreboardLib\\src\\main\\java\\me\\tigerhix\\lib\\scoreboard\\common\\animate\\FrameAnimatedString.java'
'E:\\Development\\IdeaProjects\\ScoreboardLib\\src\\main\\java\\me\\tigerhix\\lib\\scoreboard\\common\\animate\\HighlightedString.java'
'E:\\Development\\IdeaProjects\\ScoreboardLib\\src\\main\\java\\me\\tigerhix\\lib\\scoreboard\\common\\animate\\ScrollableString.java'
'E:\\Development\\IdeaProjects\\ScoreboardLib\\src\\main\\java\\me\\tigerhix\\lib\\scoreboard\\common\\animate\\StaticString.java'
'E:\\Development\\IdeaProjects\\ScoreboardLib\\src\\main\\java\\me\\tigerhix\\lib\\scoreboard\\common\\Strings.java'
'E:\\Development\\IdeaProjects\\ScoreboardLib\\src\\main\\java\\me\\tigerhix\\lib\\scoreboard\\type\\Entry.java'
'E:\\Development\\IdeaProjects\\ScoreboardLib\\src\\main\\java\\me\\tigerhix\\lib\\scoreboard\\type\\ScoreboardHandler.java'
'E:\\Development\\IdeaProjects\\ScoreboardLib\\src\\main\\java\\me\\tigerhix\\lib\\scoreboard\\type\\LegacySimpleScoreboard.java'
'E:\\Development\\IdeaProjects\\ScoreboardLib\\src\\main\\java\\me\\tigerhix\\lib\\scoreboard\\type\\Scoreboard.java'
'E:\\Development\\IdeaProjects\\ScoreboardLib\\src\\main\\java\\me\\tigerhix\\lib\\scoreboard\\type\\SimpleScoreboard.java'
'E:\\Development\\IdeaProjects\\ScoreboardLib\\src\\main\\java\\me\\tigerhix\\lib\\scoreboard\\util\\ServerVersion.java'

java {
    withSourcesJar()
    withJavadocJar()
}

javadoc {
    options.addFileOption './src'
    options.encoding = 'UTF-8'
}

my answer is flagged as spam hope that it will be there soon :wink:

options.addFileOption './src' adds an option named ./src without a value.
You need to add a file option named sourcepath with the directory to the source code as value as I showed in my comment before.

Besides that, you should not add a relative path as value, as there is no guarantee about the current working directory. It is not necessarily the project directory.