Skip to content

Conversation

@stIncMale
Copy link
Member

@stIncMale stIncMale commented Nov 19, 2025

@vbabanin, thank you for the information about the @hidden standard tag! Note that I added it in a separate commit to make reviewing simpler.

The only way I see of completely removing the non-exported program elements from the API documentation is to move all those packages to a new com.mongodb.hibernate.internal module, which exports ... to com.mongodb.hibernate. This requires declaring in com.mongodb.hibernate that requires transitive com.mongodb.hibernate.internal, and also requires publishing the artifact for the com.mongodb.hibernate.internal module. Producing multiple Java modules also means using a multi-project Gradle build.

I also upgraded Gradle to 9.2.1 (fortunately, it was trivial as the automatic upgrade worked just fine) and Error Prone (to the latest version that still works for us).

HIBERNATE-52

tasks.withType<JavaCompile>().configureEach {
options.compilerArgs.addAll(listOf("-Xlint:all", "-Werror"))
options.compilerArgs.addAll(
listOf("-Xlint:all", "-Xlint:-requires-automatic", "-Xlint:-requires-transitive-automatic", "-Werror"))
Copy link
Member Author

Choose a reason for hiding this comment

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

It seems fine to declare requires and requires-transitive for automatic modules, as long as those modules get their names specified via the Automatic-Module-Name JAR manifest attribute. See https://dev.java/learn/modules/automatic-module/#depending-on-automatic-modules for more details.

useJavaOutput()
packageName("com.mongodb.hibernate.internal")
documentation.set(
"Generated by the <a href=\"https://github.com/gmazzo/gradle-buildconfig-plugin\">BuildConfig</a> plugin.\n\n@hidden")
Copy link
Member Author

Choose a reason for hiding this comment

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

I failed to exclude out generated code using -XepExcludedPaths - Error Prone seem to ignore this argument. So, to prevent it from complaining, I had to add the summary documentation line it complains about.

Comment on lines +44 to +45
addBooleanOption("Werror", false)
// TODO-HIBERNATE-129 addStringOption("-link-modularity-mismatch", "info")
Copy link
Member Author

Choose a reason for hiding this comment

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

We can't enable -Werror because of the single warning we have that can only be disabled in Java SE 18+.

disableWarningsInGeneratedCode = true
// Error Prone does not understand the `@hidden` standard tag
disable("InvalidBlockTag")
disable("AssignmentExpression")
Copy link
Member Author

Choose a reason for hiding this comment

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

I upgraded the Error Prone, and it now has the AssignmentExpression check enabled by default. We don't have a problem with people using such expressions lightly, but they can be useful in some situations. We already have a single instance of using an assignment expression in the codebase.

@stIncMale stIncMale marked this pull request as ready for review November 20, 2025 07:38
@stIncMale stIncMale requested a review from a team as a code owner November 20, 2025 07:38
@stIncMale stIncMale requested review from katcharov and vbabanin and removed request for a team and katcharov November 20, 2025 07:38
Copy link
Member Author

Choose a reason for hiding this comment

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

We no longer need this annotation, as now we can actually use sealed classes without the limitation of having to have all permits in the same package as the sealed class.

@stIncMale
Copy link
Member Author

I realized that I should add some open and provides directories to the module descriptor. Changing the PR status to "draft" meanwhile.

@stIncMale stIncMale marked this pull request as draft November 21, 2025 18:22
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.

1 participant