Repository navigation
feat(deps): make the MongoDB driver an optional dependency - #167
Open
ashleycaselli wants to merge 1 commit into
Open
ashleycaselli wants to merge 1 commit into
ashleycaselli wants to merge 1 commit into
Conversation
nanopub-java declared the legacy all-in-one org.mongodb:mongo-java-driver 3.12.14 (end of life) as a compile dependency, so every project using the library got a copy of com.mongodb.* and org.bson.*, clashing with the modern driver in projects that declare one themselves (e.g. nanopub-registry). The dependency is now org.mongodb:mongodb-driver-sync 5.13.0, marked optional: it is only on the classpath of projects that declare a driver. The rest of the library loads no MongoDB class. NanopubDb is ported to the current API (MongoClients, MongoDatabase, MongoCollection), so getMongoClient() now returns com.mongodb.client.MongoClient. NanopubStream needed no change. The command-line jar still includes the driver, as the assembly packs the project's optional dependencies. Projects that use NanopubDb or NanopubStream.fromMongoCursor have to declare org.mongodb:mongodb-driver-sync themselves. Closes #166 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #166
nanopub-java declared the legacy all-in-one
org.mongodb:mongo-java-driver3.12.14 (end of life) as a compile dependency. So every project using the library got a copy ofcom.mongodb.*andorg.bson.*, which clashed with the modern driver in projects that declare one themselves (knowledgepixels/nanopub-registry#180).Changes
org.mongodb:mongodb-driver-sync5.13.0, marked<optional>true</optional>. It is now only on the classpath of projects that declare a driver themselves.NanopubDb: ported from the legacy API (com.mongodb.MongoClient,DB,DBCollection,BasicDBObject) to the current one (MongoClients.create(MongoClientSettings),MongoDatabase,MongoCollection<Document>,Filters.eq). Same connection parameters and behaviour.getMongoClient()now returnscom.mongodb.client.MongoClient; nothing in the known dependent projects calls it.NanopubStream: unchanged, sinceMongoCursor,DocumentandBinaryare the same in the new driver.NanopubDborNanopubStream.fromMongoCursormust declaremongodb-driver-syncthemselves.CLI jar
The
cliprofile's assembly (jar-with-dependencies) packs the project's own optional dependencies, so the driver (mongodb-driver-sync,mongodb-driver-core,bson) is in the CLI jar without changes to the profile. Checked by:get --mongodb-host 127.0.0.1 --mongodb-port 1 …from the packed jar, which reaches the driver and times out on the closed port with aMongoTimeoutException, not aNoClassDefFoundError.The driver is deliberately not added to the
cliprofile, as that profile activates wheneverCIis set and could then bring the driver back into dependent builds on CI.Verified
GetNanopub,NanopubStream,FetchIndexFromDb,RunandNanopubImplload and pass bytecode verification, and nanopubs parse.mongo-java-driver3.12.14). nanopub-registry declaresmongodb-driver-syncitself.NanopubDbTest: with a mocked client, it checks the connection settings with and without credentials, the_idlookup, reading a stored nanopub from the test suite, an unknown artifact code, andisAccessible().🤖 Generated with Claude Code