Skip to content

Build: Make bson-kotlin and bson-kotlinx optional #1148

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

Merged
merged 1 commit into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions driver-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def classifiers = ["linux-x86_64", "linux-aarch_64", "osx-x86_64", "osx-aarch_64
dependencies {
api project(path: ':bson', configuration: 'default')
implementation project(path: ':bson-record-codec', configuration: 'default')
implementation project(path: ':bson-kotlin', configuration: 'default')
implementation project(path: ':bson-kotlinx', configuration: 'default')
implementation project(path: ':bson-kotlin', configuration: 'default'), optional
implementation project(path: ':bson-kotlinx', configuration: 'default'), optional

implementation "com.github.jnr:jnr-unixsocket:$jnrUnixsocketVersion", optional
api platform("io.netty:netty-bom:$nettyVersion")
Expand Down
1 change: 1 addition & 0 deletions driver-kotlin-coroutine/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ dependencies {

api(project(path = ":bson", configuration = "default"))
api(project(path = ":driver-reactive-streams", configuration = "default"))
implementation(project(path = ":bson-kotlin", configuration = "default"))
Copy link
Member Author

Choose a reason for hiding this comment

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

Adds a direct dependency - should we also add kotlinx here as well?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure. What are the pros and cons?

Copy link
Member Author

Choose a reason for hiding this comment

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

With just bson-kotlin:

Pros: Minimizes the dependencies - doesn't drag in kotlinx serialization.
Cons: bson-kotlinx becomes an extra opt in requirement.

implementation("org.mongodb:mongodb-driver-kotlin-coroutine:4.10.0")
implementation("org.mongodb:bson-kotlinx:4.10.0")

I think this PR is the best course of action - the automatic extra dependency on bson-kotlin is small. So don't think we should add kotlinx automagically.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, I'm just not sure how widely kotlinx serialization will be used. I guess we can always make it non-optional in the future. We may need a documentation update for this.


testImplementation("org.jetbrains.kotlin:kotlin-reflect")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
Expand Down
3 changes: 1 addition & 2 deletions driver-kotlin-sync/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.jetbrains.kotlin.jvm")
`java-library`
kotlin("plugin.serialization")
Copy link
Member Author

Choose a reason for hiding this comment

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

This wasn't used or needed - same goes for bson-kotlinx in the test.


// Test based plugins
id("com.diffplug.spotless")
Expand Down Expand Up @@ -62,6 +61,7 @@ dependencies {

api(project(path = ":bson", configuration = "default"))
api(project(path = ":driver-sync", configuration = "default"))
implementation(project(path = ":bson-kotlin", configuration = "default"))

testImplementation("org.jetbrains.kotlin:kotlin-reflect")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
Expand All @@ -73,7 +73,6 @@ dependencies {
integrationTestImplementation("org.jetbrains.kotlin:kotlin-test-junit")
integrationTestImplementation(project(path = ":driver-sync"))
integrationTestImplementation(project(path = ":driver-core"))
integrationTestImplementation(project(path = ":bson-kotlinx"))
}

kotlin { explicitApi() }
Expand Down