Skip to content

Aggregate javadoc using build-logic #4457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

runningcode
Copy link
Contributor

@runningcode runningcode commented May 27, 2025

📜 Description

This PR has a few parts to it:

  1. Adds a new build-logic module to organize our build logic.
  2. Adds two convention plugins.
    • sentry.javadoc publishes the javadoc
      to a consumable configuration.
    • sentry.javadoc.aggregate consumes the published javadoc and
      aggregates them in the root build folder.
  3. Deletes the stylesheet.css. This was causing the javadoc to look
    unusable. Deleting it fixes this.
  4. Each subproject publishes the javadoc to its own subfolder. The
    previous behavior would overwrite the javadoc with each new project
    in the same directory which meant some parts of the javadoc were
    unreachable.

The producer/consumer configuration is based on this blog post: https://www.liutikas.net/2024/12/11/Together-In-Isolation.html
It should be project isolation compatible.

Here is what the javadoc looks like right now: https://getsentry.github.io/sentry-java/
This is what the javadoc will look like without the stylesheet:
image

💡 Motivation and Context

The previous mechanism for publishing javadoc was broken because it combines the classpath of all subproject dependencies leading to some version conflicts. This is why the publication was disabled here: #4445

💚 How did you test it?

I checked the build folder that the correct javadoc was published but wasn't able to test the github action.

📝 Checklist

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

build.gradle.kts Outdated
@@ -246,31 +247,6 @@ spotless {
}
}

tasks.register("aggregateJavadocs", Javadoc::class.java) {
setDestinationDir(project.layout.buildDirectory.file("docs/javadoc").get().asFile)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would previously put all the javadocs from all subprojects in the root which meant a lot of the files were overwritten like index.html.

@runningcode runningcode force-pushed the no/aggregate-javadoc branch 3 times, most recently from f4724d7 to d4be83a Compare May 27, 2025 13:16
Copy link
Contributor

github-actions bot commented May 27, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 415.16 ms 447.29 ms 32.13 ms
Size 1.58 MiB 2.08 MiB 510.85 KiB

Previous results on branch: no/aggregate-javadoc

Startup times

Revision Plain With Sentry Diff
283a4b4 406.41 ms 475.78 ms 69.37 ms
ba39ab5 463.60 ms 488.32 ms 24.72 ms
a151608 459.64 ms 525.40 ms 65.76 ms
79d6db9 389.84 ms 421.86 ms 32.02 ms

App size

Revision Plain With Sentry Diff
283a4b4 1.58 MiB 2.08 MiB 510.85 KiB
ba39ab5 1.58 MiB 2.08 MiB 510.84 KiB
a151608 1.58 MiB 2.08 MiB 510.84 KiB
79d6db9 1.58 MiB 2.08 MiB 510.84 KiB

@runningcode runningcode force-pushed the no/aggregate-javadoc branch 2 times, most recently from c2dbb1e to 2651164 Compare May 27, 2025 13:38
@@ -237,7 +238,7 @@ spotless {
kotlin {
target("**/*.kt")
ktlint()
targetExclude("**/sentry-native/**")
targetExclude("**/sentry-native/**", "**/build/**")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to add this exclusion otherwise spotless tries to format the generated code in the build folder. This was causing an issue since the generated accessors have an underscore (_) in the path name and this is was failing the check.

This PR has a few parts to it:
1. Adds a new `build-logic` module to organize our build logic.
2. Adds two convention plugins.
   - `sentry.javadoc` publishes the javadoc
   to a consumable configuration.
   - `sentry.javadoc.aggregate` consumes the published javadoc and
     aggregates them in the root build folder.
3. Deletes the `stylesheet.css`. This was causing the javadoc to look
   unusable. Deleting it fixes this.
4. Each subproject publishes the javadoc to its own subfolder. The
   previous behavior would overwrite the javadoc with each new project
   in the same directory which meant some parts of the javadoc were
   unreachable.

The producer/consumer configuration is based on this blog post: https://www.liutikas.net/2024/12/11/Together-In-Isolation.html
It should be project isolation compatible.
@runningcode runningcode force-pushed the no/aggregate-javadoc branch from 2651164 to 3414ddc Compare May 27, 2025 14:26
fs.copy {
// Get the third to last part (project name) to use as the directory name for the output
val parts = file.path.split('/')
val projectName = parts[parts.size - 4]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be some safety around this in case the parts.size is < 4?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good point. To be honest, this logic is a bit hacky. The ArtifactView has this information as the component idenitifer, but I can’t have the ArtifactView as an input to the task since it isn’t serializeable. This was my hack around this.

Since these are fully qualified paths it is nearly impossible for them to be less than 4. If they are then we should fail and investigate. The bigger issue is if these are not the project names but I’m not sure how to check for that.

@runningcode runningcode force-pushed the no/aggregate-javadoc branch from b2401ba to 1e77db3 Compare May 28, 2025 07:18
@runningcode runningcode force-pushed the no/aggregate-javadoc branch from 1e77db3 to 9aecae9 Compare May 28, 2025 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants