From 1dbf1a527e62a3fcbb1994968c7bcd9466d459fa Mon Sep 17 00:00:00 2001 From: Sasindu Alahakoon Date: Thu, 1 Aug 2024 14:22:34 +0530 Subject: [PATCH 1/4] Add package md as the readme file --- ballerina/Ballerina.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index bce49a1..07bed5f 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -8,6 +8,7 @@ repository = "https://github.com/ballerina-platform/module-ballerina-data.csv" license = ["Apache-2.0"] distribution = "2201.9.0" export = ["data.csv"] +readme = "Package.md" [platform.java17] graalvmCompatible = true From ea628f75abfd0f55dcf1ae49af00de662c58300b Mon Sep 17 00:00:00 2001 From: Sasindu Alahakoon Date: Thu, 1 Aug 2024 14:47:20 +0530 Subject: [PATCH 2/4] [Automated] Update the native jar versions --- ballerina/Ballerina.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index 07bed5f..bce49a1 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -8,7 +8,6 @@ repository = "https://github.com/ballerina-platform/module-ballerina-data.csv" license = ["Apache-2.0"] distribution = "2201.9.0" export = ["data.csv"] -readme = "Package.md" [platform.java17] graalvmCompatible = true From b0d7055a873659788d755e9496738330db4695d0 Mon Sep 17 00:00:00 2001 From: Sasindu Alahakoon Date: Thu, 1 Aug 2024 15:13:16 +0530 Subject: [PATCH 3/4] publish native package for the maven central --- native/build.gradle | 22 +++++++++++++++++++ .../lib/data/csvdata/utils/DiagnosticLog.java | 2 +- .../data/csvdata-native/resource-config.json | 2 +- ...{error.properties => csv_error.properties} | 0 4 files changed, 24 insertions(+), 2 deletions(-) rename native/src/main/resources/{error.properties => csv_error.properties} (100%) diff --git a/native/build.gradle b/native/build.gradle index d87213d..2fef0f3 100644 --- a/native/build.gradle +++ b/native/build.gradle @@ -68,6 +68,28 @@ spotbugsTest { enabled = false } +publishing { + publications { + mavenJava(MavenPublication) { + groupId project.group + artifactId "data.csv-native" + version = project.version + artifact jar + } + } + + repositories { + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/ballerina-platform/module-ballerina-data.csv") + credentials { + username = System.getenv("publishUser") + password = System.getenv("publishPAT") + } + } + } +} + compileJava { doFirst { options.compilerArgs = [ diff --git a/native/src/main/java/io/ballerina/lib/data/csvdata/utils/DiagnosticLog.java b/native/src/main/java/io/ballerina/lib/data/csvdata/utils/DiagnosticLog.java index e7569df..6de4ee3 100644 --- a/native/src/main/java/io/ballerina/lib/data/csvdata/utils/DiagnosticLog.java +++ b/native/src/main/java/io/ballerina/lib/data/csvdata/utils/DiagnosticLog.java @@ -35,7 +35,7 @@ public final class DiagnosticLog { private static final String ERROR_PREFIX = "error"; private static final String CSV_CONVERSION_ERROR = "Error"; private static final String UNSUPPORTED_OPERATION_ERROR = "Error"; - private static final ResourceBundle MESSAGES = ResourceBundle.getBundle("error", Locale.getDefault()); + private static final ResourceBundle MESSAGES = ResourceBundle.getBundle("csv_error", Locale.getDefault()); private DiagnosticLog() { } diff --git a/native/src/main/resources/META-INF/native-image/io.ballerina.stdlib/data/csvdata-native/resource-config.json b/native/src/main/resources/META-INF/native-image/io.ballerina.stdlib/data/csvdata-native/resource-config.json index befe09e..fea4f2b 100644 --- a/native/src/main/resources/META-INF/native-image/io.ballerina.stdlib/data/csvdata-native/resource-config.json +++ b/native/src/main/resources/META-INF/native-image/io.ballerina.stdlib/data/csvdata-native/resource-config.json @@ -1,6 +1,6 @@ { "bundles":[{ - "name":"error", + "name":"csv_error", "locales":[""] }] } diff --git a/native/src/main/resources/error.properties b/native/src/main/resources/csv_error.properties similarity index 100% rename from native/src/main/resources/error.properties rename to native/src/main/resources/csv_error.properties From 3e449724bc435148b7a4a21f711969f7aa285b73 Mon Sep 17 00:00:00 2001 From: Sasindu Alahakoon Date: Thu, 1 Aug 2024 15:19:33 +0530 Subject: [PATCH 4/4] Change the parser option field names --- .../user-config-tests/tests/user_configs.bal | 10 +++++----- ballerina/csv_api.bal | 6 +++--- ballerina/types.bal | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ballerina-tests/user-config-tests/tests/user_configs.bal b/ballerina-tests/user-config-tests/tests/user_configs.bal index deb2b4f..f968a9e 100644 --- a/ballerina-tests/user-config-tests/tests/user_configs.bal +++ b/ballerina-tests/user-config-tests/tests/user_configs.bal @@ -24,11 +24,11 @@ csv:ParseOption option4 = {nilValue: "", header: 4, skipLines: "1-5"}; csv:ParseOption option5 = {nilValue: "", header: 4, skipLines: "1-1"}; csv:ParseOption option6 = {nilValue: "()", header: false, skipLines: [1, 2]}; -csv:parseToRecordOption ptOption1 = {nilValue: "", header: 1, skipLines: [2, 4]}; -csv:parseToRecordOption ptOption2 = {nilValue: "", header: 1, skipLines: "2-4"}; -csv:parseToRecordOption ptOption3 = {nilValue: "", header: 4, skipLines: "1-5"}; -csv:parseToRecordOption ptOption4 = {nilValue: "", header: 4, skipLines: [-1, -2, 4, 2]}; -csv:parseToRecordOption ptOption5 = {header: false, skipLines: [-1, -2, 5, 3]}; +csv:ParseToRecordOption ptOption1 = {nilValue: "", header: 1, skipLines: [2, 4]}; +csv:ParseToRecordOption ptOption2 = {nilValue: "", header: 1, skipLines: "2-4"}; +csv:ParseToRecordOption ptOption3 = {nilValue: "", header: 4, skipLines: "1-5"}; +csv:ParseToRecordOption ptOption4 = {nilValue: "", header: 4, skipLines: [-1, -2, 4, 2]}; +csv:ParseToRecordOption ptOption5 = {header: false, skipLines: [-1, -2, 5, 3]}; // Invalid parser options csv:ParseOption invalidParserOptions1 = {header: 4}; diff --git a/ballerina/csv_api.bal b/ballerina/csv_api.bal index 3a51ab1..fbf5036 100644 --- a/ballerina/csv_api.bal +++ b/ballerina/csv_api.bal @@ -22,7 +22,7 @@ import ballerina/jballerina.java; # + options - Options to be used for filtering in the projection # + t - Target type # + return - On success, value belonging to the given target type, else returns an `csv:Error` value. -public isolated function parseStringToRecord(string s, parseToRecordOption options = {}, typedesc t = <>) +public isolated function parseStringToRecord(string s, ParseToRecordOption options = {}, typedesc t = <>) returns t|Error = @java:Method {'class: "io.ballerina.lib.data.csvdata.csv.Native"} external; # Converts byte[] to subtype of record array. @@ -31,7 +31,7 @@ public isolated function parseStringToRecord(string s, parseToRecordOption optio # + options - Options to be used for filtering in the projection # + t - Target type # + return - On success, value belonging to the given target type, else returns an `csv:Error` value. -public isolated function parseBytesToRecord(byte[] s, parseToRecordOption options = {}, typedesc t = <>) +public isolated function parseBytesToRecord(byte[] s, ParseToRecordOption options = {}, typedesc t = <>) returns t|Error = @java:Method {'class: "io.ballerina.lib.data.csvdata.csv.Native"} external; # Converts CSV byte-block-stream to subtype of record array. @@ -41,7 +41,7 @@ public isolated function parseBytesToRecord(byte[] s, parseToRecordOption option # + t - Target type # + return - On success, value belonging to the given target type, else returns an `csv:Error` value. public isolated function parseStreamToRecord(stream s, - parseToRecordOption options = {}, typedesc t = <>) + ParseToRecordOption options = {}, typedesc t = <>) returns t|Error = @java:Method {'class: "io.ballerina.lib.data.csvdata.csv.Native"} external; # Converts CSV string to subtype of anydata[][]. diff --git a/ballerina/types.bal b/ballerina/types.bal index eb7029f..3129d7c 100644 --- a/ballerina/types.bal +++ b/ballerina/types.bal @@ -55,7 +55,7 @@ public type ParseOption record {| |}; # Represents options for parsing data into records. -public type parseToRecordOption record {| +public type ParseToRecordOption record {| *ParseOption; # Custom headers for the data, if any. string[]? customHeaders = ();