Skip to content

HIBERNATE-213: fix release publishing for the multi-module build - #196

Merged
jyemin merged 2 commits into
mongodb:mainfrom
jyemin:HIBERNATE-213
Aug 4, 2026
Merged

HIBERNATE-213: fix release publishing for the multi-module build#196
jyemin merged 2 commits into
mongodb:mainfrom
jyemin:HIBERNATE-213

Conversation

@jyemin

@jyemin jyemin commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Fixes three defects in the release process.

  1. publish.sh expanded the Gradle task list as "${TASK}", making the two release task names a single argv element, so Gradle looked for one task named "publishArchives closeAndReleaseSonatypeStagingRepository". A bash array expanded with "${TASKS[@]}" passes them separately. Snapshot publishing was unaffected because publishSnapshots is a single word, which is why this went unnoticed until the first release attempt. SYSTEM_PROPERTIES becomes an array for the same reason, and RELEASE now uses ${RELEASE:-false}.

  2. publishArchives and publishSnapshots declared dependsOn(tasks.named(...)), which resolves to the root project's tasks alone, so the publications of the Spring Boot modules were never uploaded and the build still passed. Both lifecycle tasks now depend on the equivalent task in every project that applies mongo-hibernate-publish.

  3. The starter module applies plain java-library rather than the Java conventions, so it published neither a sources nor a javadoc jar; Maven Central requires both, and the staging repository would have failed to close. Producing the two jars moves from mongo-hibernate-java to mongo-hibernate-publish, since the requirement follows from publishing a module rather than from how the module is compiled.

Three defects, each of which on its own prevents a release.

publish.sh expanded the Gradle task list as "${TASK}", making the two
release task names a single argv element, so Gradle looked for one task
named "publishArchives closeAndReleaseSonatypeStagingRepository". A bash
array expanded with "${TASKS[@]}" passes them separately. Snapshot
publishing was unaffected because publishSnapshots is a single word,
which is why this went unnoticed until the first release attempt.
SYSTEM_PROPERTIES becomes an array for the same reason, and RELEASE now
uses ${RELEASE:-false}, the default-value expansion it was reaching for.

publishArchives and publishSnapshots declared dependsOn(tasks.named(...)),
which resolves to the root project's tasks alone, so the publications of
the Spring Boot modules were never uploaded and the build still passed.
Both lifecycle tasks now depend on the equivalent task in every project
that applies mongo-hibernate-publish.

The starter module applies plain java-library rather than the Java
conventions, so it published neither a sources nor a javadoc jar; Maven
Central requires both, and the staging repository would have failed to
close. Producing the two jars moves from mongo-hibernate-java to
mongo-hibernate-publish, since the requirement follows from publishing a
module rather than from how the module is compiled.
@jyemin
jyemin requested a review from a team as a code owner July 30, 2026 19:22
@jyemin
jyemin requested review from nhachicha, rozza and strogiyotec and removed request for nhachicha July 30, 2026 19:22
strogiyotec
strogiyotec previously approved these changes Aug 4, 2026
Comment thread .evergreen/publish.sh
############################################
source java-config.sh

RELEASE=${RELEASE:false}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should I create a follow up for java driver ? (maybe spark and kafka too) as java driver has the same issue
https://github.com/mongodb/mongo-java-driver/blob/main/.evergreen/publish.sh#L13
On the other hand, I checked that RELEASE variable is always set in pipeline so this fix should not have blocked us during the release

@rozza rozza Aug 4, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Its worth it, if you do a PR feel free to assign to me

Comment thread .evergreen/publish.sh
SYSTEM_PROPERTIES=(-Dorg.gradle.internal.publish.checksums.insecure=true)

./gradlew -version
./gradlew ${SYSTEM_PROPERTIES} --stacktrace --info "${TASK}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe the problem is is quotes " , java driver has the same pattern but doesn't use quotes instead of introducing the array , why do you think having array is better ?

@rozza rozza Aug 4, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree - just don't quote when calling ./gradlew - follows the java driver convention

Claude seems to think the array approach is safer because if quotes were added in the future it would still work. 🤷

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, and this is exactly how it broke in the first place: quotes were added around TASKS as a drive-by change, probably in response to a warning in the IDE.

Comment thread .evergreen/publish.sh
TASKS=(publishSnapshots)
fi

SYSTEM_PROPERTIES="-Dorg.gradle.internal.publish.checksums.insecure=true"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment thread build.gradle.kts Outdated
// A plain `tasks.named(name)` below would resolve to the root project's task alone, leaving the
// publications of the subprojects unpublished. The Callable defers looking at the projects until the task
// graph is built, by which point the subprojects have been evaluated and their plugins are visible.
fun publishingTaskInEveryProject(name: String) = Callable {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

how about adding 1 validation layer

fun publishingTaskInEveryProject(name: String) = Callable {
    val publishing = allprojects.filter { it.pluginManager.hasPlugin("mongo-hibernate-publish") }
    val withPublications = allprojects.filter {
        it.extensions.findByType<PublishingExtension>()?.publications?.isNotEmpty() == true
    }
    require((withPublications - publishing.toSet()).isEmpty()) {
        "Projects declare publications but don't apply mongo-hibernate-publish: ${withPublications - publishing.toSet()}"
    }
    publishing.map { it.tasks.named(name) }
}

This way we check that every project that want to be published must declare mongo-hibernate-publish

I am still debating if it will be useful, for example if I were to introduce a new module like Quarkus starter I would just copy paste the Spring boot starter

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Great idea. Tested, and applied.

Comment thread .evergreen/publish.sh
source java-config.sh

RELEASE=${RELEASE:false}
RELEASE=${RELEASE:-false}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍 Nice catch.

rozza
rozza previously approved these changes Aug 4, 2026

@rozza rozza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just one nit (optional).

I wondered why not just register the task inside the convention - but this seems to be the better approach as there is one single publish (archives/snapshot) task registered - rather than one per sub project.

FYI - buildSrc is not under spotless - something you may want to add in the future.

Comment thread build.gradle.kts Outdated
@jyemin
jyemin dismissed stale reviews from rozza and strogiyotec via 5be4c1d August 4, 2026 12:18
@jyemin
jyemin requested review from rozza and strogiyotec August 4, 2026 12:22

@rozza rozza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@jyemin
jyemin merged commit 564ef2b into mongodb:main Aug 4, 2026
7 checks passed
@jyemin
jyemin deleted the HIBERNATE-213 branch August 4, 2026 12:55
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.

3 participants