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!

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).

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.

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
@stIncMale stIncMale force-pushed the HIBERNATE-52 branch 4 times, most recently from e6010cb to de745c4 Compare November 24, 2025 14:50
@stIncMale stIncMale marked this pull request as ready for review November 24, 2025 15:08
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 copied the canonical configuration file for logback from https://logback.qos.ch/manual/configuration.html (we were using the legacy one), and updated it with the changes we had.

connection.set("scm:https://github.com/mongodb/mongo-hibernate.git")
developerConnection.set("scm:https://github.com/mongodb/mongo-hibernate.git")
connection.set("scm:git:https://github.com/mongodb/mongo-hibernate.git")
developerConnection.set("scm:git:https://github.com/mongodb/mongo-hibernate.git")
Copy link
Member Author

Choose a reason for hiding this comment

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

The format is scm:[provider]:[provider_specific] according to https://maven.apache.org/pom.html#SCM.

@stIncMale stIncMale marked this pull request as draft November 24, 2025 18:49
@stIncMale
Copy link
Member Author

Talked with @vbabanin, his suggestions:

  • make the examples folder name to explicitly express that it's a Java module;
  • make a dedicated Evergreen task for running the examples.

@stIncMale stIncMale force-pushed the HIBERNATE-52 branch 2 times, most recently from d884419 to d8c4552 Compare November 25, 2025 23:37
@stIncMale stIncMale force-pushed the HIBERNATE-52 branch 2 times, most recently from a1c0265 to 3c745d9 Compare November 26, 2025 04:14
HIBERNATE-52
@stIncMale stIncMale marked this pull request as ready for review November 26, 2025 04:21
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
<enableAssertions>true</enableAssertions>
<useModulePath>true</useModulePath>
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 used useModulePath in both maven-surefire-plugin, maven-failsafe-plugin, and put the tests in a test module. This way we know the tests use the module path:

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