Skip to content
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

Mongo Driver version 3.8.2 used but expecting 3.10.0 #182

Open
andrewcanby-finocomp opened this issue Jan 5, 2021 · 3 comments
Open

Mongo Driver version 3.8.2 used but expecting 3.10.0 #182

andrewcanby-finocomp opened this issue Jan 5, 2021 · 3 comments

Comments

@andrewcanby-finocomp
Copy link

Background

The documentation for Gorm for MongoDB version 7.0 says there is:

Support for MongoDB Driver 3.10.0

At first glance I thought this meant the bundled version was updated to 3.10.0, but it still seems to be on 3.8.2.

However - looking at the code it seems to imply it should be 3.10.0.

Example

Create a vanilla Grails 4.0.4 project setup using:

  1. grails create-app --profile=rest-api mongo-version-test
  2. Add the dependency compile "org.grails.plugins:mongodb"
  3. Run ./gradlew assemble dependencyInsight --dependency "org.mongodb:mongodb-driver" to see dependency resolved as 3.8.2.

Sample project

https://github.com/andrewcanby-finocomp/gorm-mongo-driver-version

@puneetbehl
Copy link
Contributor

It might be that version 3.8.2 is forced by Spring BOM. Please try setting the following in the build.gradle

ext['mongodb.version']='3.10.0'

@andrewcanby-finocomp
Copy link
Author

Thanks @puneetbehl - I gave it a go and saw this:

❯ ./gradlew assemble dependencyInsight --dependency "org.mongodb:mongodb-driver"
Starting a Gradle Daemon, 1 busy and 1 incompatible Daemons could not be reused, use --status for details

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'mongo-version-test'.
> Could not resolve all files for configuration ':runtime'.
   > Could not find org.grails.plugins:mongodb:3.10.0.
     Searched in the following locations:
       - https://repo.grails.org/grails/core/org/grails/plugins/mongodb/3.10.0/mongodb-3.10.0.pom
       - https://repo.grails.org/grails/core/org/grails/plugins/mongodb/3.10.0/mongodb-3.10.0.jar
     Required by:
         project :

I had tried this before and saw the error but didn't persist. It seems like the Gorm for Mongo uses the same version param?

If I also change the dependencies section to an explicit version:

compile "org.grails.plugins:mongodb:7.0.1"

Then it does resolve the correct version:

❯ ./gradlew assemble dependencyInsight --dependency "org.mongodb:mongodb-driver"

> Task :dependencyInsight
org.mongodb:mongodb-driver:3.10.0 (selected by rule)
   variant "compile" [
      org.gradle.status              = release (not requested)
      org.gradle.usage               = java-api
      org.gradle.libraryelements     = jar (compatible with: classes+resources)
      org.gradle.category            = library (not requested)

      Requested attributes not found in the selected variant:
         org.gradle.dependency.bundling = external
         org.gradle.jvm.version         = 8
   ]

org.mongodb:mongodb-driver:3.10.0
+--- org.grails:grails-datastore-gorm-mongodb:7.0.1
|    \--- org.grails.plugins:mongodb:7.0.1
|         \--- compileClasspath
\--- org.grails:grails-datastore-gorm-mongodb-ext:7.0.1
     \--- org.grails.plugins:mongodb:7.0.1 (*)

org.mongodb:mongodb-driver-core:3.10.0 (selected by rule)
   variant "compile" [
      org.gradle.status              = release (not requested)
      org.gradle.usage               = java-api
      org.gradle.libraryelements     = jar (compatible with: classes+resources)
      org.gradle.category            = library (not requested)

      Requested attributes not found in the selected variant:
         org.gradle.dependency.bundling = external
         org.gradle.jvm.version         = 8
   ]

org.mongodb:mongodb-driver-core:3.10.0
\--- org.mongodb:mongodb-driver:3.10.0
     +--- org.grails:grails-datastore-gorm-mongodb:7.0.1
     |    \--- org.grails.plugins:mongodb:7.0.1
     |         \--- compileClasspath
     \--- org.grails:grails-datastore-gorm-mongodb-ext:7.0.1
          \--- org.grails.plugins:mongodb:7.0.1 (*)

(*) - dependencies omitted (listed previously)

A web-based, searchable dependency report is available by adding the --scan option.

BUILD SUCCESSFUL in 9s

The changes are here: andrewcanby-finocomp/gorm-mongo-driver-version@283bac0

So it works... but I feel like this is more of a workaround, and people might get tripped up on it.

In the grails-bom project the version is specified as mongo https://github.com/grails/grails-core/blob/v4.0.6/grails-bom/plugins.properties#L2, which ends up filling a property called mongodb.version in the pom file. I can envisage changing how this works might be a bit painful 😬

@puneetbehl
Copy link
Contributor

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

No branches or pull requests

2 participants