From 03919262cf2f95e721d5964d06397c882e40d613 Mon Sep 17 00:00:00 2001 From: Chuhaa Date: Tue, 8 Mar 2022 23:31:40 +0530 Subject: [PATCH] Remove runtime from java dependency --- mongodb-native/build.gradle | 17 ++++++++++++++++- mongodb/Ballerina.toml | 2 +- mongodb/iterator.bal | 5 ++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/mongodb-native/build.gradle b/mongodb-native/build.gradle index 4710de1c..e77a5723 100644 --- a/mongodb-native/build.gradle +++ b/mongodb-native/build.gradle @@ -3,6 +3,12 @@ plugins { id "com.github.johnrengelman.shadow" } +configurations { + dist { + transitive true + } +} + repositories { mavenCentral() @@ -19,9 +25,18 @@ dependencies { implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.21' compile group: 'org.ballerinalang', name: 'ballerina-lang', version: project.ballerinaLangVersion compile (group: 'org.ballerinalang', name: 'ballerina-runtime', version: project.ballerinaLangVersion) { - transitive = false + transitive = true } compile group: 'org.mongodb', name: 'mongo-java-driver', version: '3.8.2' + dist group: 'org.mongodb', name: 'mongo-java-driver', version: '3.8.2' +} + +jar { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + dependsOn configurations.dist + from { configurations.dist.collect { it.isDirectory() ? it : zipTree(it) } } { + exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA' + } } build.dependsOn(shadowJar) diff --git a/mongodb/Ballerina.toml b/mongodb/Ballerina.toml index 26e77af4..5889aaf0 100644 --- a/mongodb/Ballerina.toml +++ b/mongodb/Ballerina.toml @@ -10,7 +10,7 @@ icon = "icon.png" repository = "https://github.com/ballerina-platform/module-ballerinax-mongodb" [[platform.java11.dependency]] -path = "../mongodb-native/build/libs/mongodb-native-3.2.1-all.jar" +path = "../mongodb-native/build/libs/mongodb-native-3.2.1.jar" groupId = "org.ballerinalang" artifactId = "mongodb-native" version = "3.2.1" diff --git a/mongodb/iterator.bal b/mongodb/iterator.bal index 4f87d19f..2d9baec7 100644 --- a/mongodb/iterator.bal +++ b/mongodb/iterator.bal @@ -29,7 +29,6 @@ public class ResultIterator { if (self.isClosed) { return closedStreamInvocationError(); } - Error? closeErrorIgnored = (); if (self.err is Error) { return self.err; } else { @@ -42,10 +41,10 @@ public class ResultIterator { return streamRecord; } else if (result is Error) { self.err = result; - closeErrorIgnored = self.close(); + check self.close(); return self.err; } else { - closeErrorIgnored = self.close(); + check self.close(); return result; } }