Aggregated javadoc when using buildSrc

I am currently attempting to migrate a project over to buildSrc. I previously had a task javadocAll in the root build.gradle:

task javadocAll(type: Javadoc) {
	source subprojects.collect {project ->
		project.sourceSets.main.allJava }
	destinationDir = javadocAllDir
	// Might need a classpath
	classpath = files(subprojects.collect {project ->
	options.linkSource = true
	options.use = true
	options.links = ["${javaMajor}/docs/api/"] as String[]

How do I migrate this task to a project using buildSrc?

No matter whether you use buildSrc or not, you should not access other projects outputs like that, it is bad practice, unsafe, and prone to problems.

Instead you should share stuff as documented at Sharing outputs between projects

The The Test Report Aggregation Plugin and The JaCoCo Report Aggregation Plugin use exactly that approach to build aggregate test reports and JaCoCo reports, you can probably also take inspiration from them.

Thanks for the pointers. :slight_smile:

However, I wonder if I really want to share outputs. It’s not like I want to aggregate the outputs of individual javadoc tasks, as then the inter-project javadoc links would probably not appear.

I lately used io.freefair.aggregate-javadoc in my buildSrc migration branch, and it seems to do mostly what I want.

FTR, I also cross posted this question to Stackoverflow, because I believe many projects have an aggregated javadoc task like my javadocAll and may want to migrate to buildSrc at some point.

Again, whether you use buildSrc or not is absolutely irrelevant to your question.
And whether you use buildSrc or not is also irrelevant to your current approach being unsafe and bad practice.

I didn’t say that you should get the JavaDoc output from the other projects.
Getting the sources would also be an output.
Look at the things I gave you.
The aggregated JaCoCo report also needs the sources from the other projects and gets them also the proper way.