# Aggregated javadoc when using buildSrc

**URL:** <https://discuss.gradle.org/t/aggregated-javadoc-when-using-buildsrc/45003>\
**Category:** Help/Discuss\
**Created:** [February 26, 2023, 8:38pm UTC](https://discuss.gradle.org/t/aggregated-javadoc-when-using-buildsrc/45003 "2023-02-26T20:38:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![flow](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/flow/32/1968_2.png) [@flow](https://discuss.gradle.org/u/flow)\
**Post date:** [February 26, 2023, 8:38pm UTC](https://discuss.gradle.org/t/aggregated-javadoc-when-using-buildsrc/45003/1 "2023-02-26T20:38:54Z")

</div>

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

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

```

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

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [February 27, 2023, 12:15pm UTC](https://discuss.gradle.org/t/aggregated-javadoc-when-using-buildsrc/45003/2 "2023-02-27T12:15:14Z")

</div>

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](https://docs.gradle.org/current/userguide/cross_project_publications.html)

The [The Test Report Aggregation Plugin](https://docs.gradle.org/current/userguide/test_report_aggregation_plugin.html) and [The JaCoCo Report Aggregation Plugin](https://docs.gradle.org/current/userguide/jacoco_report_aggregation_plugin.html) use exactly that approach to build aggregate test reports and JaCoCo reports, you can probably also take inspiration from them.

---

<div class="post-metadata">

**Author:** ![flow](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/flow/32/1968_2.png) [@flow](https://discuss.gradle.org/u/flow)\
**Post date:** [March 1, 2023, 9:56am UTC](https://discuss.gradle.org/t/aggregated-javadoc-when-using-buildsrc/45003/3 "2023-03-01T09:56:29Z")

</div>

Thanks for the pointers. 🙂

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](https://stackoverflow.com/questions/75578003/how-to-create-an-aggregated-javadoc-gradle-task-on-the-root-project-when-using-b), because I believe many projects have an aggregated javadoc task like my `javadocAll` and may want to migrate to buildSrc at some point.

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [March 1, 2023, 3:43pm UTC](https://discuss.gradle.org/t/aggregated-javadoc-when-using-buildsrc/45003/4 "2023-03-01T15:43:15Z")

</div>

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.
