From a0d9ef1b9a6cc7d99c842f3a282b2ea853597057 Mon Sep 17 00:00:00 2001 From: gabfssilva Date: Mon, 22 Jan 2024 14:54:56 -0300 Subject: [PATCH] Initial setup for KMP --- .gitignore | 4 +- build.gradle.kts | 136 +++++++++++++---- buildSrc/src/main/kotlin/Dependency.kt | 52 ++----- connectors/amqp/build.gradle.kts | 10 +- .../com/river/connector/amqp/AmqpExt.kt | 0 .../com/river/connector/amqp/Message.kt | 0 .../river/connector/amqp/ReceivingMessage.kt | 0 .../connector/amqp/internal/InternalExt.kt | 0 .../com/river/connector/amqp/AmqpExtKtTest.kt | 0 connectors/apache/kafka/build.gradle.kts | 12 +- .../apache/kafka/KafkaReceiverExt.kt | 0 .../apache/kafka/MutableReceiverOptions.kt | 0 .../apache/kafka/MutableSenderOptions.kt | 0 .../connector/apache/kafka/PropertyBuilder.kt | 0 .../apache/kafka/KafkaReceiverExtKtTest.kt | 0 connectors/aws/build.gradle.kts | 25 ++- connectors/aws/dynamodb/build.gradle.kts | 4 +- .../aws/java-11-http-spi/build.gradle.kts | 7 + .../river/connector/aws/Java11HttpClient.kt | 0 .../connector/aws/Java11HttpClientBuilder.kt | 0 .../connector/aws/Java11HttpClientService.kt | 0 ...azon.awssdk.http.async.SdkAsyncHttpService | 0 connectors/aws/lambda/build.gradle.kts | 10 +- connectors/aws/s3/build.gradle.kts | 10 +- .../connector/aws/s3/S3AsyncClientExt.kt | 0 .../connector/aws/s3/S3AsyncClientExtTest.kt | 0 connectors/aws/ses/build.gradle.kts | 10 +- .../com/river/connector/aws/ses/SesExt.kt | 0 .../river/connector/aws/ses/internal/Ext.kt | 0 .../aws/ses/model/SendEmailRequest.kt | 0 .../connector/aws/sqs/SesFlowExtKtTest.kt | 0 connectors/aws/sns/build.gradle.kts | 10 +- .../connector/aws/sns/SnsAsyncClientExt.kt | 0 .../aws/sns/model/PublishMessageRequest.kt | 0 .../aws/sns/model/PublishMessageResponse.kt | 0 .../aws/sns/SnsAsyncClientExtTest.kt | 0 connectors/aws/sqs/build.gradle.kts | 10 +- .../connector/aws/sqs/SqsAsyncClientExt.kt | 0 .../connector/aws/sqs/model/Acknowledgment.kt | 0 .../aws/sqs/model/AcknowledgmentResult.kt | 0 .../aws/sqs/model/MessageAcknowledgment.kt | 0 .../river/connector/aws/sqs/model/OnError.kt | 0 .../aws/sqs/model/ReceiveConfiguration.kt | 0 .../sqs/model/ReceiveMessageRequestBuilder.kt | 0 .../aws/sqs/model/SendMessageRequest.kt | 0 .../aws/sqs/model/SendMessageResponse.kt | 0 .../aws/sqs/SqsAsyncClientExtTest.kt | 0 connectors/azure/build.gradle.kts | 10 +- .../azure/queue-storage/build.gradle.kts | 10 +- .../azure/queue/storage/QueueStorageExt.kt | 0 .../queue/storage/model/SendMessageRequest.kt | 0 .../queue/storage/QueueStorageExtKtTest.kt | 0 connectors/build.gradle.kts | 12 +- .../com/river/connector/console/ConsoleExt.kt | 0 .../connector/console/ConsoleExtKtTest.kt | 0 connectors/elasticsearch/build.gradle.kts | 12 +- .../river/connector/elasticsearch/Document.kt | 0 .../ElasticsearchAsyncClientExt.kt | 0 .../elasticsearch/PaginatedSearch.kt | 0 .../file/AsynchronousFileChannelExt.kt | 0 .../com/river/connector/file/FileExt.kt | 0 .../river/connector/file/InputStreamExt.kt | 0 .../com/river/connector/file/PathExt.kt | 0 .../kotlin/com/river/connector/file/ZipExt.kt | 0 .../file/model/ContentfulZipEntry.kt | 0 connectors/format/csv/build.gradle.kts | 11 +- .../com/river/connector/format/csv/CsvExt.kt | 0 .../connector/format/csv/CsvExtKtTest.kt | 0 connectors/format/json/build.gradle.kts | 10 +- .../river/connector/format/json/JsonExt.kt | 0 .../connector/format/json/JsonExtKtTest.kt | 0 .../flat/line/PositionalFlatLineExt.kt | 0 connectors/ftp/build.gradle.kts | 20 ++- .../com/river/connector/ftp/FTPClientExt.kt | 0 .../connector/ftp/model/FtpConfiguration.kt | 0 .../river/connector/ftp/FTPClientExtKtTest.kt | 0 .../river/connector/ftp/FtpServerMockExt.kt | 0 connectors/github/build.gradle.kts | 26 +++- .../com/river/connector/github/GithubApi.kt | 0 .../river/connector/github/GithubApiExt.kt | 0 .../river/connector/github/internal/Ext.kt | 0 .../github/internal/InternalGithubApiExt.kt | 0 .../connector/github/model/BlobContent.kt | 0 .../river/connector/github/model/Commit.kt | 0 .../river/connector/github/model/Content.kt | 0 .../com/river/connector/github/model/Enums.kt | 0 .../connector/github/model/FileContent.kt | 0 .../com/river/connector/github/model/Issue.kt | 0 .../connector/github/model/PullRequest.kt | 0 .../connector/github/model/QueryParameters.kt | 0 .../connector/github/model/Repository.kt | 0 .../river/connector/github/model/TreeRef.kt | 0 .../github/model/query/CommitQuery.kt | 0 .../github/model/query/IssueQuery.kt | 0 .../github/model/query/PageableQuery.kt | 0 .../github/model/query/PullRequestQuery.kt | 0 .../model/query/RepositoryIssueQuery.kt | 0 .../github/model/query/RepositoryQuery.kt | 0 .../connector/github/GithubApiExtKtTest.kt | 0 .../resources/commits/page_1.json | 0 .../resources/commits/page_2.json | 0 .../resources/commits/page_3.json | 0 connectors/google/drive/build.gradle.kts | 24 ++- .../river/connector/google/drive/FileList.kt | 0 .../connector/google/drive/FilesListQuery.kt | 0 .../connector/google/drive/GoogleDriveApi.kt | 0 .../google/drive/GoogleDriveApiExt.kt | 0 .../google/drive/internal/BearerTokenActor.kt | 0 connectors/http/build.gradle.kts | 10 +- .../com/river/connector/http/Authorization.kt | 0 .../river/connector/http/BodyHandlerExt.kt | 0 .../http/CustomHttpRequestBuilder.kt | 0 .../com/river/connector/http/HttpExt.kt | 0 .../com/river/connector/http/HttpMethod.kt | 0 .../river/connector/http/HttpRequestExt.kt | 0 .../kotlin/com/river/connector/http/SSEExt.kt | 0 .../river/connector/http/ServerSentEvent.kt | 0 connectors/jms/build.gradle.kts | 18 ++- .../kotlin/com/river/connector/jms/JmsExt.kt | 0 .../jms/model/CommitableJmsMessage.kt | 0 .../river/connector/jms/model/Credentials.kt | 0 .../river/connector/jms/model/DeliveryMode.kt | 0 .../connector/jms/model/JmsDestination.kt | 0 .../river/connector/jms/model/JmsMessage.kt | 0 .../river/connector/jms/model/JmsPrimitive.kt | 0 .../river/connector/jms/model/SessionMode.kt | 0 .../com/river/connector/jms/model/Types.kt | 0 .../com/river/connector/jms/JmsExtKtTest.kt | 0 connectors/mongodb/build.gradle.kts | 14 +- .../connector/mongodb/MongoCollectionExt.kt | 0 .../mongodb/MongoCollectionExtTest.kt | 0 connectors/openai/build.gradle.kts | 16 +- connectors/rdbms/jdbc/build.gradle.kts | 12 +- .../com/river/connector/rdbms/jdbc/Jdbc.kt | 0 .../com/river/connector/rdbms/jdbc/JdbcExt.kt | 0 .../river/connector/rdbms/jdbc/JdbcTest.kt | 0 connectors/rdbms/r2dbc/build.gradle.kts | 19 ++- .../connector/rdbms/r2dbc/R2dbcFlowExt.kt | 0 .../connector/rdbms/r2dbc/model/Returning.kt | 0 .../connector/rdbms/r2dbc/R2dbcFlowExtTest.kt | 0 .../src/{test => jvmTest}/resources/h2.sql | 0 connectors/red-hat/debezium/build.gradle.kts | 23 ++- .../connector/red/hat/debezium/DebeziumExt.kt | 0 .../internal/DebeziumChannelNotifier.kt | 0 .../hat/debezium/model/CommittableOffset.kt | 0 .../hat/debezium/model/CommittableRecord.kt | 0 .../red/hat/debezium/DebeziumExtKtTest.kt | 0 connectors/redis/build.gradle.kts | 10 +- .../connector/redis/RedissonClientExt.kt | 0 .../redis/internal/RedisAsyncSemaphore.kt | 0 .../redis/RedissonClientExtKtTest.kt | 0 core/build.gradle.kts | 21 +++ .../kotlin/com/river/core/AsyncSemaphore.kt | 0 .../kotlin/com/river/core/ChannelExt.kt | 0 .../com/river/core/ChannelReceiverContext.kt | 9 ++ .../kotlin/com/river/core/ConcurrencyInfo.kt | 0 .../com/river/core/ExperimentalRiverApi.kt | 0 .../kotlin/com/river/core/FlowAsyncExt.kt | 0 .../kotlin/com/river/core/FlowByteArrayExt.kt | 4 +- .../com/river/core/FlowByteBufferExt.kt | 19 +++ .../kotlin/com/river/core/FlowByteExt.kt | 0 .../kotlin/com/river/core/FlowDoubleExt.kt | 0 .../kotlin/com/river/core/FlowExt.kt | 0 .../kotlin/com/river/core/FlowFloatExt.kt | 0 .../kotlin/com/river/core/FlowIntExt.kt | 0 .../kotlin/com/river/core/FlowLongExt.kt | 0 .../kotlin/com/river/core/FlowShortExt.kt | 0 .../kotlin/com/river/core/FlowStringExt.kt | 76 +++++----- .../kotlin/com/river/core/GroupExt.kt | 0 .../kotlin/com/river/core/GroupStrategy.kt | 0 .../kotlin/com/river/core/IntersperseExt.kt | 0 .../kotlin/com/river/core/IterableAsyncExt.kt | 2 +- .../kotlin/com/river/core/ObjectPool.kt | 9 +- .../river/core/ParallelismIncreaseStrategy.kt | 0 .../kotlin/com/river/core/PollExt.kt | 0 .../kotlin/com/river/core/PromiseExt.kt | 0 .../kotlin/com/river/core/RiverPreview.kt | 0 .../kotlin/com/river/core/SchedulerExt.kt | 0 .../com/river/core/StoppableFlowCollector.kt | 0 .../kotlin/com/river/core/StoppableFlowExt.kt | 0 .../kotlin/com/river/core/SuspendExt.kt | 0 .../kotlin/com/river/core/ThrottleExt.kt | 0 .../kotlin/com/river/core/ThrottleStrategy.kt | 0 .../core/internal/DefaultAsyncSemaphore.kt | 87 +++++++++++ .../river/core/internal/DefaultObjectPool.kt | 5 +- .../InternalChannelReceiverContext.kt | 0 .../com/river/core/internal/MapAsyncFlow.kt | 0 .../core/internal/MutexBasedWindowedChunk.kt | 0 .../com/river/core/internal/PollingFlow.kt | 0 .../com/river/core/internal/SplitFlow.kt | 0 .../com/river/core/internal/StopableFlow.kt | 0 .../com/river/core/internal/ThrottleFlow.kt | 0 .../core/internal/UnorderedMapAsyncFlow.kt | 0 .../com/river/core/FlowAsyncExtKtTest.kt | 71 +++++---- .../kotlin/com/river/core/FlowExtKtTest.kt | 132 ++++++++++++++++ .../com/river/core/FlowNumberExtKtTest.kt | 21 +++ .../kotlin/com/river/core/PollExtTest.kt | 100 ++++++++++++ .../com/river/core/FlowByteBufferExt.kt | 0 .../kotlin/com/river/core/FlowStringJvmExt.kt | 42 +++++ .../com/river/core/FlowBigDecimalExt.kt | 20 --- .../core/internal/DefaultAsyncSemaphore.kt | 103 ------------- .../kotlin/com/river/core/FlowExtKtTest.kt | 143 ------------------ .../com/river/core/FlowNumberExtKtTest.kt | 34 ----- .../test/kotlin/com/river/core/PollExtTest.kt | 98 ------------ examples/debezium-csv-s3/build.gradle.kts | 23 ++- .../src/{main => jvmMain}/kotlin/Sample.kt | 0 .../build.gradle.kts | 23 ++- .../src/{main => jvmMain}/kotlin/Sample.kt | 0 examples/s3-csv-jdbc/build.gradle.kts | 20 ++- .../src/{main => jvmMain}/kotlin/Sample.kt | 0 .../src/{main => jvmMain}/kotlin/Setup.kt | 0 examples/sqs-to-http/build.gradle.kts | 19 ++- .../src/{main => jvmMain}/kotlin/Sample.kt | 0 .../src/{main => jvmMain}/kotlin/Setup.kt | 0 gradle.properties | 3 +- libs.versions.toml | 19 ++- settings.gradle.kts | 10 +- 217 files changed, 1007 insertions(+), 663 deletions(-) rename connectors/amqp/src/{main => jvmMain}/kotlin/com/river/connector/amqp/AmqpExt.kt (100%) rename connectors/amqp/src/{main => jvmMain}/kotlin/com/river/connector/amqp/Message.kt (100%) rename connectors/amqp/src/{main => jvmMain}/kotlin/com/river/connector/amqp/ReceivingMessage.kt (100%) rename connectors/amqp/src/{main => jvmMain}/kotlin/com/river/connector/amqp/internal/InternalExt.kt (100%) rename connectors/amqp/src/{test => jvmTest}/kotlin/com/river/connector/amqp/AmqpExtKtTest.kt (100%) rename connectors/apache/kafka/src/{main => jvmMain}/kotlin/com/river/connector/apache/kafka/KafkaReceiverExt.kt (100%) rename connectors/apache/kafka/src/{main => jvmMain}/kotlin/com/river/connector/apache/kafka/MutableReceiverOptions.kt (100%) rename connectors/apache/kafka/src/{main => jvmMain}/kotlin/com/river/connector/apache/kafka/MutableSenderOptions.kt (100%) rename connectors/apache/kafka/src/{main => jvmMain}/kotlin/com/river/connector/apache/kafka/PropertyBuilder.kt (100%) rename connectors/apache/kafka/src/{test => jvmTest}/kotlin/com/river/connector/apache/kafka/KafkaReceiverExtKtTest.kt (100%) rename connectors/aws/java-11-http-spi/src/{main => jvmMain}/kotlin/com/river/connector/aws/Java11HttpClient.kt (100%) rename connectors/aws/java-11-http-spi/src/{main => jvmMain}/kotlin/com/river/connector/aws/Java11HttpClientBuilder.kt (100%) rename connectors/aws/java-11-http-spi/src/{main => jvmMain}/kotlin/com/river/connector/aws/Java11HttpClientService.kt (100%) rename connectors/aws/java-11-http-spi/src/{main => jvmMain}/resources/META-INF/services/software.amazon.awssdk.http.async.SdkAsyncHttpService (100%) rename connectors/aws/s3/src/{main => jvmMain}/kotlin/com/river/connector/aws/s3/S3AsyncClientExt.kt (100%) rename connectors/aws/s3/src/{test => jvmTest}/kotlin/com/river/connector/aws/s3/S3AsyncClientExtTest.kt (100%) rename connectors/aws/ses/src/{main => jvmMain}/kotlin/com/river/connector/aws/ses/SesExt.kt (100%) rename connectors/aws/ses/src/{main => jvmMain}/kotlin/com/river/connector/aws/ses/internal/Ext.kt (100%) rename connectors/aws/ses/src/{main => jvmMain}/kotlin/com/river/connector/aws/ses/model/SendEmailRequest.kt (100%) rename connectors/aws/ses/src/{test => jvmTest}/kotlin/com/river/connector/aws/sqs/SesFlowExtKtTest.kt (100%) rename connectors/aws/sns/src/{main => jvmMain}/kotlin/com/river/connector/aws/sns/SnsAsyncClientExt.kt (100%) rename connectors/aws/sns/src/{main => jvmMain}/kotlin/com/river/connector/aws/sns/model/PublishMessageRequest.kt (100%) rename connectors/aws/sns/src/{main => jvmMain}/kotlin/com/river/connector/aws/sns/model/PublishMessageResponse.kt (100%) rename connectors/aws/sns/src/{test => jvmTest}/kotlin/com/river/connector/aws/sns/SnsAsyncClientExtTest.kt (100%) rename connectors/aws/sqs/src/{main => jvmMain}/kotlin/com/river/connector/aws/sqs/SqsAsyncClientExt.kt (100%) rename connectors/aws/sqs/src/{main => jvmMain}/kotlin/com/river/connector/aws/sqs/model/Acknowledgment.kt (100%) rename connectors/aws/sqs/src/{main => jvmMain}/kotlin/com/river/connector/aws/sqs/model/AcknowledgmentResult.kt (100%) rename connectors/aws/sqs/src/{main => jvmMain}/kotlin/com/river/connector/aws/sqs/model/MessageAcknowledgment.kt (100%) rename connectors/aws/sqs/src/{main => jvmMain}/kotlin/com/river/connector/aws/sqs/model/OnError.kt (100%) rename connectors/aws/sqs/src/{main => jvmMain}/kotlin/com/river/connector/aws/sqs/model/ReceiveConfiguration.kt (100%) rename connectors/aws/sqs/src/{main => jvmMain}/kotlin/com/river/connector/aws/sqs/model/ReceiveMessageRequestBuilder.kt (100%) rename connectors/aws/sqs/src/{main => jvmMain}/kotlin/com/river/connector/aws/sqs/model/SendMessageRequest.kt (100%) rename connectors/aws/sqs/src/{main => jvmMain}/kotlin/com/river/connector/aws/sqs/model/SendMessageResponse.kt (100%) rename connectors/aws/sqs/src/{test => jvmTest}/kotlin/com/river/connector/aws/sqs/SqsAsyncClientExtTest.kt (100%) rename connectors/azure/queue-storage/src/{main => jvmMain}/kotlin/com/river/connector/azure/queue/storage/QueueStorageExt.kt (100%) rename connectors/azure/queue-storage/src/{main => jvmMain}/kotlin/com/river/connector/azure/queue/storage/model/SendMessageRequest.kt (100%) rename connectors/azure/queue-storage/src/{test => jvmTest}/kotlin/com/river/connector/azure/queue/storage/QueueStorageExtKtTest.kt (100%) rename connectors/console/src/{main => jvmMain}/kotlin/com/river/connector/console/ConsoleExt.kt (100%) rename connectors/console/src/{test => jvmTest}/kotlin/com/river/connector/console/ConsoleExtKtTest.kt (100%) rename connectors/elasticsearch/src/{main => jvmMain}/kotlin/com/river/connector/elasticsearch/Document.kt (100%) rename connectors/elasticsearch/src/{main => jvmMain}/kotlin/com/river/connector/elasticsearch/ElasticsearchAsyncClientExt.kt (100%) rename connectors/elasticsearch/src/{main => jvmMain}/kotlin/com/river/connector/elasticsearch/PaginatedSearch.kt (100%) rename connectors/file/src/{main => jvmMain}/kotlin/com/river/connector/file/AsynchronousFileChannelExt.kt (100%) rename connectors/file/src/{main => jvmMain}/kotlin/com/river/connector/file/FileExt.kt (100%) rename connectors/file/src/{main => jvmMain}/kotlin/com/river/connector/file/InputStreamExt.kt (100%) rename connectors/file/src/{main => jvmMain}/kotlin/com/river/connector/file/PathExt.kt (100%) rename connectors/file/src/{main => jvmMain}/kotlin/com/river/connector/file/ZipExt.kt (100%) rename connectors/file/src/{main => jvmMain}/kotlin/com/river/connector/file/model/ContentfulZipEntry.kt (100%) rename connectors/format/csv/src/{main => jvmMain}/kotlin/com/river/connector/format/csv/CsvExt.kt (100%) rename connectors/format/csv/src/{test => jvmTest}/kotlin/com/river/connector/format/csv/CsvExtKtTest.kt (100%) rename connectors/format/json/src/{main => jvmMain}/kotlin/com/river/connector/format/json/JsonExt.kt (100%) rename connectors/format/json/src/{test => jvmTest}/kotlin/com/river/connector/format/json/JsonExtKtTest.kt (100%) rename connectors/format/positional-flat-line/src/{main => jvmMain}/kotlin/com/river/connector/format/positional/flat/line/PositionalFlatLineExt.kt (100%) rename connectors/ftp/src/{main => jvmMain}/kotlin/com/river/connector/ftp/FTPClientExt.kt (100%) rename connectors/ftp/src/{main => jvmMain}/kotlin/com/river/connector/ftp/model/FtpConfiguration.kt (100%) rename connectors/ftp/src/{test => jvmTest}/kotlin/com/river/connector/ftp/FTPClientExtKtTest.kt (100%) rename connectors/ftp/src/{test => jvmTest}/kotlin/com/river/connector/ftp/FtpServerMockExt.kt (100%) rename connectors/github/src/{main => jvmMain}/kotlin/com/river/connector/github/GithubApi.kt (100%) rename connectors/github/src/{main => jvmMain}/kotlin/com/river/connector/github/GithubApiExt.kt (100%) rename connectors/github/src/{main => jvmMain}/kotlin/com/river/connector/github/internal/Ext.kt (100%) rename connectors/github/src/{main => jvmMain}/kotlin/com/river/connector/github/internal/InternalGithubApiExt.kt (100%) rename connectors/github/src/{main => jvmMain}/kotlin/com/river/connector/github/model/BlobContent.kt (100%) rename connectors/github/src/{main => jvmMain}/kotlin/com/river/connector/github/model/Commit.kt (100%) rename connectors/github/src/{main => jvmMain}/kotlin/com/river/connector/github/model/Content.kt (100%) rename connectors/github/src/{main => jvmMain}/kotlin/com/river/connector/github/model/Enums.kt (100%) rename connectors/github/src/{main => jvmMain}/kotlin/com/river/connector/github/model/FileContent.kt (100%) rename connectors/github/src/{main => jvmMain}/kotlin/com/river/connector/github/model/Issue.kt (100%) rename connectors/github/src/{main => jvmMain}/kotlin/com/river/connector/github/model/PullRequest.kt (100%) rename connectors/github/src/{main => jvmMain}/kotlin/com/river/connector/github/model/QueryParameters.kt (100%) rename connectors/github/src/{main => jvmMain}/kotlin/com/river/connector/github/model/Repository.kt (100%) rename connectors/github/src/{main => jvmMain}/kotlin/com/river/connector/github/model/TreeRef.kt (100%) rename connectors/github/src/{main => jvmMain}/kotlin/com/river/connector/github/model/query/CommitQuery.kt (100%) rename connectors/github/src/{main => jvmMain}/kotlin/com/river/connector/github/model/query/IssueQuery.kt (100%) rename connectors/github/src/{main => jvmMain}/kotlin/com/river/connector/github/model/query/PageableQuery.kt (100%) rename connectors/github/src/{main => jvmMain}/kotlin/com/river/connector/github/model/query/PullRequestQuery.kt (100%) rename connectors/github/src/{main => jvmMain}/kotlin/com/river/connector/github/model/query/RepositoryIssueQuery.kt (100%) rename connectors/github/src/{main => jvmMain}/kotlin/com/river/connector/github/model/query/RepositoryQuery.kt (100%) rename connectors/github/src/{test => jvmTest}/kotlin/com/river/connector/github/GithubApiExtKtTest.kt (100%) rename connectors/github/src/{test => jvmTest}/resources/commits/page_1.json (100%) rename connectors/github/src/{test => jvmTest}/resources/commits/page_2.json (100%) rename connectors/github/src/{test => jvmTest}/resources/commits/page_3.json (100%) rename connectors/google/drive/src/{main => jvmMain}/kotlin/com/river/connector/google/drive/FileList.kt (100%) rename connectors/google/drive/src/{main => jvmMain}/kotlin/com/river/connector/google/drive/FilesListQuery.kt (100%) rename connectors/google/drive/src/{main => jvmMain}/kotlin/com/river/connector/google/drive/GoogleDriveApi.kt (100%) rename connectors/google/drive/src/{main => jvmMain}/kotlin/com/river/connector/google/drive/GoogleDriveApiExt.kt (100%) rename connectors/google/drive/src/{main => jvmMain}/kotlin/com/river/connector/google/drive/internal/BearerTokenActor.kt (100%) rename connectors/http/src/{main => jvmMain}/kotlin/com/river/connector/http/Authorization.kt (100%) rename connectors/http/src/{main => jvmMain}/kotlin/com/river/connector/http/BodyHandlerExt.kt (100%) rename connectors/http/src/{main => jvmMain}/kotlin/com/river/connector/http/CustomHttpRequestBuilder.kt (100%) rename connectors/http/src/{main => jvmMain}/kotlin/com/river/connector/http/HttpExt.kt (100%) rename connectors/http/src/{main => jvmMain}/kotlin/com/river/connector/http/HttpMethod.kt (100%) rename connectors/http/src/{main => jvmMain}/kotlin/com/river/connector/http/HttpRequestExt.kt (100%) rename connectors/http/src/{main => jvmMain}/kotlin/com/river/connector/http/SSEExt.kt (100%) rename connectors/http/src/{main => jvmMain}/kotlin/com/river/connector/http/ServerSentEvent.kt (100%) rename connectors/jms/src/{main => jvmMain}/kotlin/com/river/connector/jms/JmsExt.kt (100%) rename connectors/jms/src/{main => jvmMain}/kotlin/com/river/connector/jms/model/CommitableJmsMessage.kt (100%) rename connectors/jms/src/{main => jvmMain}/kotlin/com/river/connector/jms/model/Credentials.kt (100%) rename connectors/jms/src/{main => jvmMain}/kotlin/com/river/connector/jms/model/DeliveryMode.kt (100%) rename connectors/jms/src/{main => jvmMain}/kotlin/com/river/connector/jms/model/JmsDestination.kt (100%) rename connectors/jms/src/{main => jvmMain}/kotlin/com/river/connector/jms/model/JmsMessage.kt (100%) rename connectors/jms/src/{main => jvmMain}/kotlin/com/river/connector/jms/model/JmsPrimitive.kt (100%) rename connectors/jms/src/{main => jvmMain}/kotlin/com/river/connector/jms/model/SessionMode.kt (100%) rename connectors/jms/src/{main => jvmMain}/kotlin/com/river/connector/jms/model/Types.kt (100%) rename connectors/jms/src/{test => jvmTest}/kotlin/com/river/connector/jms/JmsExtKtTest.kt (100%) rename connectors/mongodb/src/{main => jvmMain}/kotlin/com/river/connector/mongodb/MongoCollectionExt.kt (100%) rename connectors/mongodb/src/{test => jvmTest}/kotlin/com/river/connector/mongodb/MongoCollectionExtTest.kt (100%) rename connectors/rdbms/jdbc/src/{main => jvmMain}/kotlin/com/river/connector/rdbms/jdbc/Jdbc.kt (100%) rename connectors/rdbms/jdbc/src/{main => jvmMain}/kotlin/com/river/connector/rdbms/jdbc/JdbcExt.kt (100%) rename connectors/rdbms/jdbc/src/{test => jvmTest}/kotlin/com/river/connector/rdbms/jdbc/JdbcTest.kt (100%) rename connectors/rdbms/r2dbc/src/{main => jvmMain}/kotlin/com/river/connector/rdbms/r2dbc/R2dbcFlowExt.kt (100%) rename connectors/rdbms/r2dbc/src/{main => jvmMain}/kotlin/com/river/connector/rdbms/r2dbc/model/Returning.kt (100%) rename connectors/rdbms/r2dbc/src/{test => jvmTest}/kotlin/com/river/connector/rdbms/r2dbc/R2dbcFlowExtTest.kt (100%) rename connectors/rdbms/r2dbc/src/{test => jvmTest}/resources/h2.sql (100%) rename connectors/red-hat/debezium/src/{main => jvmMain}/kotlin/com/river/connector/red/hat/debezium/DebeziumExt.kt (100%) rename connectors/red-hat/debezium/src/{main => jvmMain}/kotlin/com/river/connector/red/hat/debezium/internal/DebeziumChannelNotifier.kt (100%) rename connectors/red-hat/debezium/src/{main => jvmMain}/kotlin/com/river/connector/red/hat/debezium/model/CommittableOffset.kt (100%) rename connectors/red-hat/debezium/src/{main => jvmMain}/kotlin/com/river/connector/red/hat/debezium/model/CommittableRecord.kt (100%) rename connectors/red-hat/debezium/src/{test => jvmTest}/kotlin/com/river/connector/red/hat/debezium/DebeziumExtKtTest.kt (100%) rename connectors/redis/src/{main => jvmMain}/kotlin/com/river/connector/redis/RedissonClientExt.kt (100%) rename connectors/redis/src/{main => jvmMain}/kotlin/com/river/connector/redis/internal/RedisAsyncSemaphore.kt (100%) rename connectors/redis/src/{test => jvmTest}/kotlin/com/river/connector/redis/RedissonClientExtKtTest.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/AsyncSemaphore.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/ChannelExt.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/ChannelReceiverContext.kt (88%) rename core/src/{main => commonMain}/kotlin/com/river/core/ConcurrencyInfo.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/ExperimentalRiverApi.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/FlowAsyncExt.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/FlowByteArrayExt.kt (81%) create mode 100644 core/src/commonMain/kotlin/com/river/core/FlowByteBufferExt.kt rename core/src/{main => commonMain}/kotlin/com/river/core/FlowByteExt.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/FlowDoubleExt.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/FlowExt.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/FlowFloatExt.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/FlowIntExt.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/FlowLongExt.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/FlowShortExt.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/FlowStringExt.kt (60%) rename core/src/{main => commonMain}/kotlin/com/river/core/GroupExt.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/GroupStrategy.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/IntersperseExt.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/IterableAsyncExt.kt (98%) rename core/src/{main => commonMain}/kotlin/com/river/core/ObjectPool.kt (86%) rename core/src/{main => commonMain}/kotlin/com/river/core/ParallelismIncreaseStrategy.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/PollExt.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/PromiseExt.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/RiverPreview.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/SchedulerExt.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/StoppableFlowCollector.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/StoppableFlowExt.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/SuspendExt.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/ThrottleExt.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/ThrottleStrategy.kt (100%) create mode 100644 core/src/commonMain/kotlin/com/river/core/internal/DefaultAsyncSemaphore.kt rename core/src/{main => commonMain}/kotlin/com/river/core/internal/DefaultObjectPool.kt (93%) rename core/src/{main => commonMain}/kotlin/com/river/core/internal/InternalChannelReceiverContext.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/internal/MapAsyncFlow.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/internal/MutexBasedWindowedChunk.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/internal/PollingFlow.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/internal/SplitFlow.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/internal/StopableFlow.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/internal/ThrottleFlow.kt (100%) rename core/src/{main => commonMain}/kotlin/com/river/core/internal/UnorderedMapAsyncFlow.kt (100%) rename core/src/{test => commonTest}/kotlin/com/river/core/FlowAsyncExtKtTest.kt (71%) create mode 100644 core/src/commonTest/kotlin/com/river/core/FlowExtKtTest.kt create mode 100644 core/src/commonTest/kotlin/com/river/core/FlowNumberExtKtTest.kt create mode 100644 core/src/commonTest/kotlin/com/river/core/PollExtTest.kt rename core/src/{main => jvmMain}/kotlin/com/river/core/FlowByteBufferExt.kt (100%) create mode 100644 core/src/jvmMain/kotlin/com/river/core/FlowStringJvmExt.kt delete mode 100644 core/src/main/kotlin/com/river/core/FlowBigDecimalExt.kt delete mode 100644 core/src/main/kotlin/com/river/core/internal/DefaultAsyncSemaphore.kt delete mode 100644 core/src/test/kotlin/com/river/core/FlowExtKtTest.kt delete mode 100644 core/src/test/kotlin/com/river/core/FlowNumberExtKtTest.kt delete mode 100644 core/src/test/kotlin/com/river/core/PollExtTest.kt rename examples/debezium-csv-s3/src/{main => jvmMain}/kotlin/Sample.kt (100%) rename examples/ktor-server-json-streaming/src/{main => jvmMain}/kotlin/Sample.kt (100%) rename examples/s3-csv-jdbc/src/{main => jvmMain}/kotlin/Sample.kt (100%) rename examples/s3-csv-jdbc/src/{main => jvmMain}/kotlin/Setup.kt (100%) rename examples/sqs-to-http/src/{main => jvmMain}/kotlin/Sample.kt (100%) rename examples/sqs-to-http/src/{main => jvmMain}/kotlin/Setup.kt (100%) diff --git a/.gitignore b/.gitignore index 986f76c0..3d1331f6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ build .idea/ volume/ .DS_Store -data/ \ No newline at end of file +data/ +kotlin-js-store/ +local.properties \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 877c8781..bb45c94e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,17 +1,27 @@ +@file:OptIn(ExperimentalKotlinGradlePluginApi::class) + import org.jetbrains.dokka.gradle.AbstractDokkaTask +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import com.android.build.gradle.LibraryExtension as AndroidExtension plugins { - alias(libs.plugins.kotlin.jvm) + alias(libs.plugins.android) apply false + alias(libs.plugins.kotlin.multiplatform) + alias(libs.plugins.kotest.multiplatform) alias(libs.plugins.dokka) alias(libs.plugins.nexus.publish) apply false + alias(libs.plugins.setup.android.sdk) `maven-publish` signing - `java-library` } +group = "com.river-kt" + repositories { mavenCentral() + google() } tasks.dokkaHtmlMultiModule.configure { @@ -20,24 +30,90 @@ tasks.dokkaHtmlMultiModule.configure { moduleName.set(project.name) } +kotlin { + jvm { + withSourcesJar(false) + } +} + +setupAndroidSdk { + sdkToolsVersion("11076708_latest") +} + subprojects { - apply(plugin = "org.jetbrains.kotlin.jvm") + apply(plugin = "org.jetbrains.kotlin.multiplatform") + apply(plugin = "io.kotest.multiplatform") apply(plugin = "maven-publish") apply(plugin = "org.jetbrains.dokka") - apply(plugin = "java-library") apply(plugin = "signing") - version = "1.0.0-alpha12" - + version = "1.0.0-alpha13" group = "com.river-kt" - java { - withJavadocJar() - withSourcesJar() + kotlin { + jvmToolchain(17) + + compilerOptions { + freeCompilerArgs = listOf("-Xcontext-receivers") + } + + jvm().compilations.all { + compilerOptions.configure { + jvmTarget.set(JvmTarget.JVM_17) + freeCompilerArgs = listOf("-Xjsr305=strict", "-Xcontext-receivers") + } + } + + sourceSets { + val commonMain by getting { + dependencies { + api(rootProject.libs.coroutines) + api(rootProject.libs.kotlinx.datetime) + } + } + + val commonTest by getting { + dependencies { + api(rootProject.libs.kotest.assertions.core) + api(rootProject.libs.kotest.engine) + api(rootProject.libs.turbine) + api(rootProject.libs.kotlin.reflect) + } + + languageSettings { + optIn("com.river.core.ExperimentalRiverApi") + optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") + } + } + + val jvmTest by getting { + dependencies { + api(rootProject.libs.kotest.junit5) + } + } + + afterEvaluate { + if (androidEnabled()) { + val androidUnitTest by getting { + dependencies { + implementation(rootProject.libs.kotest.junit5) + } + } + } + } + } + } + + pluginManager.withPlugin("com.android.library") { + extensions.configure { + namespace = "com.river" + compileSdk = 30 + } } repositories { mavenCentral() + google() } tasks.withType().configureEach { @@ -79,15 +155,15 @@ subprojects { artifactId = project.name version = "${project.version}" - artifact(tasks["jar"]) - - artifact(tasks["sourcesJar"]) { - classifier = "sources" - } - - artifact(tasks["javadocJar"]) { - classifier = "javadoc" - } +// artifact(tasks["jar"]) +// +// artifact(tasks["sourcesJar"]) { +// classifier = "sources" +// } +// +// artifact(tasks["javadocJar"]) { +// classifier = "javadoc" +// } pom { name.set(project.name) @@ -118,7 +194,9 @@ subprojects { withXml { asNode().appendNode("dependencies").apply { - for (dependency in configurations["api"].dependencies) { + val dependencies = configurations.asMap["api"]?.dependencies ?: emptySet() + + for (dependency in dependencies) { appendNode("dependency").apply { appendNode("groupId", dependency.group) appendNode("artifactId", dependency.name) @@ -163,7 +241,7 @@ subprojects { useInMemoryPgpKeys(signingKeyId, signingSecretKey, signingPassword) sign(publishing.publications["maven"]) - sign(tasks["javadocJar"]) +// sign(tasks["javadocJar"]) } tasks.withType().configureEach { @@ -183,19 +261,15 @@ subprojects { ) } - tasks.javadoc { - if (JavaVersion.current().isJava9Compatible) { - (options as StandardJavadocDocletOptions).addBooleanOption("html5", true) - } - } - - dependencies { - api(rootProject.libs.coroutines) - testImplementation(rootProject.libs.kotest.junit5) - testImplementation(rootProject.libs.turbine) - } +// tasks.javadoc { +// if (JavaVersion.current().isJava9Compatible) { +// (options as StandardJavadocDocletOptions).addBooleanOption("html5", true) +// } +// } } fun Task.skipExamples() { onlyIf { !project.path.contains("examples") } } + +fun Project.androidEnabled() = pluginManager.hasPlugin("com.android.library") diff --git a/buildSrc/src/main/kotlin/Dependency.kt b/buildSrc/src/main/kotlin/Dependency.kt index 928fba9c..f8b243a1 100644 --- a/buildSrc/src/main/kotlin/Dependency.kt +++ b/buildSrc/src/main/kotlin/Dependency.kt @@ -1,47 +1,27 @@ import org.gradle.api.Project import org.gradle.api.artifacts.Dependency +import org.gradle.api.artifacts.ProjectDependency import org.gradle.api.artifacts.dsl.DependencyHandler import org.gradle.kotlin.dsl.project -object Modules { - val core = - Module(":core") - - val awsHttp11Spi = - Module(":connector:connector-aws:connector-aws-java-11-http-spi") - - val http = - Module(":connector:connector-http") - - val debezium = - Module(":connector:connector-red-hat:connector-red-hat-debezium") - - val json = - Module(":connector:connector-format:connector-format-json") - - val csv = - Module(":connector:connector-format:connector-format-csv") - - val s3 = - Module(":connector:connector-aws:connector-aws-s3") - - val sqs = - Module(":connector:connector-aws:connector-aws-sqs") - - val sns = - Module(":connector:connector-aws:connector-aws-sns") - - val jdbc = - Module(":connector:connector-rdbms:connector-rdbms-jdbc") - - val file = - Module(":connector:connector-file") +class Modules(val project: (String) -> ProjectDependency) { + val core by lazy { project(":core") } + val http by lazy { project(":connector:connector-http") } + val awsHttp11Spi by lazy { project(":connector:connector-aws:connector-aws-java-11-http-spi") } + val debezium by lazy { project(":connector:connector-red-hat:connector-red-hat-debezium") } + val json by lazy { project(":connector:connector-format:connector-format-json") } + val csv by lazy { project(":connector:connector-format:connector-format-csv") } + val s3 by lazy { project(":connector:connector-aws:connector-aws-s3") } + val sqs by lazy { project(":connector:connector-aws:connector-aws-sqs") } + val sns by lazy { project(":connector:connector-aws:connector-aws-sns") } + val jdbc by lazy { project(":connector:connector-rdbms:connector-rdbms-jdbc") } + val file by lazy { project(":connector:connector-file") } } -class Module(val name: String) +val DependencyHandler.modules + get() = Modules { project(it) } -val Project.modules - get() = Modules +fun modules(project: (String) -> ProjectDependency) = Modules(project) fun DependencyHandler.api(module: Module): Dependency? = add("api", this.project(module.name)) diff --git a/connectors/amqp/build.gradle.kts b/connectors/amqp/build.gradle.kts index ddd0806b..933bb81c 100644 --- a/connectors/amqp/build.gradle.kts +++ b/connectors/amqp/build.gradle.kts @@ -1,3 +1,9 @@ -dependencies { - api(libs.amqp) +kotlin { + sourceSets { + val jvmMain by getting { + dependencies { + api(libs.amqp) + } + } + } } diff --git a/connectors/amqp/src/main/kotlin/com/river/connector/amqp/AmqpExt.kt b/connectors/amqp/src/jvmMain/kotlin/com/river/connector/amqp/AmqpExt.kt similarity index 100% rename from connectors/amqp/src/main/kotlin/com/river/connector/amqp/AmqpExt.kt rename to connectors/amqp/src/jvmMain/kotlin/com/river/connector/amqp/AmqpExt.kt diff --git a/connectors/amqp/src/main/kotlin/com/river/connector/amqp/Message.kt b/connectors/amqp/src/jvmMain/kotlin/com/river/connector/amqp/Message.kt similarity index 100% rename from connectors/amqp/src/main/kotlin/com/river/connector/amqp/Message.kt rename to connectors/amqp/src/jvmMain/kotlin/com/river/connector/amqp/Message.kt diff --git a/connectors/amqp/src/main/kotlin/com/river/connector/amqp/ReceivingMessage.kt b/connectors/amqp/src/jvmMain/kotlin/com/river/connector/amqp/ReceivingMessage.kt similarity index 100% rename from connectors/amqp/src/main/kotlin/com/river/connector/amqp/ReceivingMessage.kt rename to connectors/amqp/src/jvmMain/kotlin/com/river/connector/amqp/ReceivingMessage.kt diff --git a/connectors/amqp/src/main/kotlin/com/river/connector/amqp/internal/InternalExt.kt b/connectors/amqp/src/jvmMain/kotlin/com/river/connector/amqp/internal/InternalExt.kt similarity index 100% rename from connectors/amqp/src/main/kotlin/com/river/connector/amqp/internal/InternalExt.kt rename to connectors/amqp/src/jvmMain/kotlin/com/river/connector/amqp/internal/InternalExt.kt diff --git a/connectors/amqp/src/test/kotlin/com/river/connector/amqp/AmqpExtKtTest.kt b/connectors/amqp/src/jvmTest/kotlin/com/river/connector/amqp/AmqpExtKtTest.kt similarity index 100% rename from connectors/amqp/src/test/kotlin/com/river/connector/amqp/AmqpExtKtTest.kt rename to connectors/amqp/src/jvmTest/kotlin/com/river/connector/amqp/AmqpExtKtTest.kt diff --git a/connectors/apache/kafka/build.gradle.kts b/connectors/apache/kafka/build.gradle.kts index d494b8d4..78c606a4 100644 --- a/connectors/apache/kafka/build.gradle.kts +++ b/connectors/apache/kafka/build.gradle.kts @@ -1,4 +1,10 @@ -dependencies { - api(libs.reactor.kafka) - api(libs.coroutines.reactive) +kotlin { + sourceSets { + val jvmMain by getting { + dependencies { + api(libs.reactor.kafka) + api(libs.coroutines.reactive) + } + } + } } diff --git a/connectors/apache/kafka/src/main/kotlin/com/river/connector/apache/kafka/KafkaReceiverExt.kt b/connectors/apache/kafka/src/jvmMain/kotlin/com/river/connector/apache/kafka/KafkaReceiverExt.kt similarity index 100% rename from connectors/apache/kafka/src/main/kotlin/com/river/connector/apache/kafka/KafkaReceiverExt.kt rename to connectors/apache/kafka/src/jvmMain/kotlin/com/river/connector/apache/kafka/KafkaReceiverExt.kt diff --git a/connectors/apache/kafka/src/main/kotlin/com/river/connector/apache/kafka/MutableReceiverOptions.kt b/connectors/apache/kafka/src/jvmMain/kotlin/com/river/connector/apache/kafka/MutableReceiverOptions.kt similarity index 100% rename from connectors/apache/kafka/src/main/kotlin/com/river/connector/apache/kafka/MutableReceiverOptions.kt rename to connectors/apache/kafka/src/jvmMain/kotlin/com/river/connector/apache/kafka/MutableReceiverOptions.kt diff --git a/connectors/apache/kafka/src/main/kotlin/com/river/connector/apache/kafka/MutableSenderOptions.kt b/connectors/apache/kafka/src/jvmMain/kotlin/com/river/connector/apache/kafka/MutableSenderOptions.kt similarity index 100% rename from connectors/apache/kafka/src/main/kotlin/com/river/connector/apache/kafka/MutableSenderOptions.kt rename to connectors/apache/kafka/src/jvmMain/kotlin/com/river/connector/apache/kafka/MutableSenderOptions.kt diff --git a/connectors/apache/kafka/src/main/kotlin/com/river/connector/apache/kafka/PropertyBuilder.kt b/connectors/apache/kafka/src/jvmMain/kotlin/com/river/connector/apache/kafka/PropertyBuilder.kt similarity index 100% rename from connectors/apache/kafka/src/main/kotlin/com/river/connector/apache/kafka/PropertyBuilder.kt rename to connectors/apache/kafka/src/jvmMain/kotlin/com/river/connector/apache/kafka/PropertyBuilder.kt diff --git a/connectors/apache/kafka/src/test/kotlin/com/river/connector/apache/kafka/KafkaReceiverExtKtTest.kt b/connectors/apache/kafka/src/jvmTest/kotlin/com/river/connector/apache/kafka/KafkaReceiverExtKtTest.kt similarity index 100% rename from connectors/apache/kafka/src/test/kotlin/com/river/connector/apache/kafka/KafkaReceiverExtKtTest.kt rename to connectors/apache/kafka/src/jvmTest/kotlin/com/river/connector/apache/kafka/KafkaReceiverExtKtTest.kt diff --git a/connectors/aws/build.gradle.kts b/connectors/aws/build.gradle.kts index cf86703b..99710161 100644 --- a/connectors/aws/build.gradle.kts +++ b/connectors/aws/build.gradle.kts @@ -1,12 +1,25 @@ subprojects { - dependencies { - api(rootProject.modules.http) + kotlin { + jvm { + configurations.all { + exclude("software.amazon.awssdk", "netty-nio-client") + } + } + + sourceSets { + val jvmMain by getting { + dependencies { + val modules = modules { project(it) } - api(rootProject.libs.aws.http.client.spi) - api(rootProject.libs.coroutines.reactive) + api(modules.http) + api(rootProject.libs.aws.http.client.spi) + api(rootProject.libs.coroutines.reactive) - if (project.name != "connector-aws-java-11-http-spi") { - api(rootProject.modules.awsHttp11Spi) + if (project.name != "connector-aws-java-11-http-spi") { + api(modules.awsHttp11Spi) + } + } + } } } } diff --git a/connectors/aws/dynamodb/build.gradle.kts b/connectors/aws/dynamodb/build.gradle.kts index 1c29e3e4..307eb128 100644 --- a/connectors/aws/dynamodb/build.gradle.kts +++ b/connectors/aws/dynamodb/build.gradle.kts @@ -1,3 +1,3 @@ -dependencies { +//dependencies { // implementation(libs.aws.dynamodb) -} +//} diff --git a/connectors/aws/java-11-http-spi/build.gradle.kts b/connectors/aws/java-11-http-spi/build.gradle.kts index e69de29b..5a8c952b 100644 --- a/connectors/aws/java-11-http-spi/build.gradle.kts +++ b/connectors/aws/java-11-http-spi/build.gradle.kts @@ -0,0 +1,7 @@ +kotlin { + sourceSets { + val jvmMain by getting { + + } + } +} diff --git a/connectors/aws/java-11-http-spi/src/main/kotlin/com/river/connector/aws/Java11HttpClient.kt b/connectors/aws/java-11-http-spi/src/jvmMain/kotlin/com/river/connector/aws/Java11HttpClient.kt similarity index 100% rename from connectors/aws/java-11-http-spi/src/main/kotlin/com/river/connector/aws/Java11HttpClient.kt rename to connectors/aws/java-11-http-spi/src/jvmMain/kotlin/com/river/connector/aws/Java11HttpClient.kt diff --git a/connectors/aws/java-11-http-spi/src/main/kotlin/com/river/connector/aws/Java11HttpClientBuilder.kt b/connectors/aws/java-11-http-spi/src/jvmMain/kotlin/com/river/connector/aws/Java11HttpClientBuilder.kt similarity index 100% rename from connectors/aws/java-11-http-spi/src/main/kotlin/com/river/connector/aws/Java11HttpClientBuilder.kt rename to connectors/aws/java-11-http-spi/src/jvmMain/kotlin/com/river/connector/aws/Java11HttpClientBuilder.kt diff --git a/connectors/aws/java-11-http-spi/src/main/kotlin/com/river/connector/aws/Java11HttpClientService.kt b/connectors/aws/java-11-http-spi/src/jvmMain/kotlin/com/river/connector/aws/Java11HttpClientService.kt similarity index 100% rename from connectors/aws/java-11-http-spi/src/main/kotlin/com/river/connector/aws/Java11HttpClientService.kt rename to connectors/aws/java-11-http-spi/src/jvmMain/kotlin/com/river/connector/aws/Java11HttpClientService.kt diff --git a/connectors/aws/java-11-http-spi/src/main/resources/META-INF/services/software.amazon.awssdk.http.async.SdkAsyncHttpService b/connectors/aws/java-11-http-spi/src/jvmMain/resources/META-INF/services/software.amazon.awssdk.http.async.SdkAsyncHttpService similarity index 100% rename from connectors/aws/java-11-http-spi/src/main/resources/META-INF/services/software.amazon.awssdk.http.async.SdkAsyncHttpService rename to connectors/aws/java-11-http-spi/src/jvmMain/resources/META-INF/services/software.amazon.awssdk.http.async.SdkAsyncHttpService diff --git a/connectors/aws/lambda/build.gradle.kts b/connectors/aws/lambda/build.gradle.kts index 491e58a9..104115cb 100644 --- a/connectors/aws/lambda/build.gradle.kts +++ b/connectors/aws/lambda/build.gradle.kts @@ -1,5 +1,9 @@ -dependencies { - api(libs.aws.lambda) { - exclude("software.amazon.awssdk", "netty-nio-client") +kotlin { + sourceSets { + val jvmMain by getting { + dependencies { + api(rootProject.libs.aws.lambda) + } + } } } diff --git a/connectors/aws/s3/build.gradle.kts b/connectors/aws/s3/build.gradle.kts index 24eec219..2063c3f2 100644 --- a/connectors/aws/s3/build.gradle.kts +++ b/connectors/aws/s3/build.gradle.kts @@ -1,5 +1,9 @@ -dependencies { - api(libs.aws.s3) { - exclude("software.amazon.awssdk", "netty-nio-client") +kotlin { + sourceSets { + val jvmMain by getting { + dependencies { + api(rootProject.libs.aws.s3) + } + } } } diff --git a/connectors/aws/s3/src/main/kotlin/com/river/connector/aws/s3/S3AsyncClientExt.kt b/connectors/aws/s3/src/jvmMain/kotlin/com/river/connector/aws/s3/S3AsyncClientExt.kt similarity index 100% rename from connectors/aws/s3/src/main/kotlin/com/river/connector/aws/s3/S3AsyncClientExt.kt rename to connectors/aws/s3/src/jvmMain/kotlin/com/river/connector/aws/s3/S3AsyncClientExt.kt diff --git a/connectors/aws/s3/src/test/kotlin/com/river/connector/aws/s3/S3AsyncClientExtTest.kt b/connectors/aws/s3/src/jvmTest/kotlin/com/river/connector/aws/s3/S3AsyncClientExtTest.kt similarity index 100% rename from connectors/aws/s3/src/test/kotlin/com/river/connector/aws/s3/S3AsyncClientExtTest.kt rename to connectors/aws/s3/src/jvmTest/kotlin/com/river/connector/aws/s3/S3AsyncClientExtTest.kt diff --git a/connectors/aws/ses/build.gradle.kts b/connectors/aws/ses/build.gradle.kts index 1701ef5b..a371c1e8 100644 --- a/connectors/aws/ses/build.gradle.kts +++ b/connectors/aws/ses/build.gradle.kts @@ -1,5 +1,9 @@ -dependencies { - api(libs.aws.ses) { - exclude("software.amazon.awssdk", "netty-nio-client") +kotlin { + sourceSets { + val jvmMain by getting { + dependencies { + api(rootProject.libs.aws.ses) + } + } } } diff --git a/connectors/aws/ses/src/main/kotlin/com/river/connector/aws/ses/SesExt.kt b/connectors/aws/ses/src/jvmMain/kotlin/com/river/connector/aws/ses/SesExt.kt similarity index 100% rename from connectors/aws/ses/src/main/kotlin/com/river/connector/aws/ses/SesExt.kt rename to connectors/aws/ses/src/jvmMain/kotlin/com/river/connector/aws/ses/SesExt.kt diff --git a/connectors/aws/ses/src/main/kotlin/com/river/connector/aws/ses/internal/Ext.kt b/connectors/aws/ses/src/jvmMain/kotlin/com/river/connector/aws/ses/internal/Ext.kt similarity index 100% rename from connectors/aws/ses/src/main/kotlin/com/river/connector/aws/ses/internal/Ext.kt rename to connectors/aws/ses/src/jvmMain/kotlin/com/river/connector/aws/ses/internal/Ext.kt diff --git a/connectors/aws/ses/src/main/kotlin/com/river/connector/aws/ses/model/SendEmailRequest.kt b/connectors/aws/ses/src/jvmMain/kotlin/com/river/connector/aws/ses/model/SendEmailRequest.kt similarity index 100% rename from connectors/aws/ses/src/main/kotlin/com/river/connector/aws/ses/model/SendEmailRequest.kt rename to connectors/aws/ses/src/jvmMain/kotlin/com/river/connector/aws/ses/model/SendEmailRequest.kt diff --git a/connectors/aws/ses/src/test/kotlin/com/river/connector/aws/sqs/SesFlowExtKtTest.kt b/connectors/aws/ses/src/jvmTest/kotlin/com/river/connector/aws/sqs/SesFlowExtKtTest.kt similarity index 100% rename from connectors/aws/ses/src/test/kotlin/com/river/connector/aws/sqs/SesFlowExtKtTest.kt rename to connectors/aws/ses/src/jvmTest/kotlin/com/river/connector/aws/sqs/SesFlowExtKtTest.kt diff --git a/connectors/aws/sns/build.gradle.kts b/connectors/aws/sns/build.gradle.kts index bac63b00..c4d84e47 100644 --- a/connectors/aws/sns/build.gradle.kts +++ b/connectors/aws/sns/build.gradle.kts @@ -1,5 +1,9 @@ -dependencies { - api(libs.aws.sns) { - exclude("software.amazon.awssdk", "netty-nio-client") +kotlin { + sourceSets { + val jvmMain by getting { + dependencies { + api(rootProject.libs.aws.sns) + } + } } } diff --git a/connectors/aws/sns/src/main/kotlin/com/river/connector/aws/sns/SnsAsyncClientExt.kt b/connectors/aws/sns/src/jvmMain/kotlin/com/river/connector/aws/sns/SnsAsyncClientExt.kt similarity index 100% rename from connectors/aws/sns/src/main/kotlin/com/river/connector/aws/sns/SnsAsyncClientExt.kt rename to connectors/aws/sns/src/jvmMain/kotlin/com/river/connector/aws/sns/SnsAsyncClientExt.kt diff --git a/connectors/aws/sns/src/main/kotlin/com/river/connector/aws/sns/model/PublishMessageRequest.kt b/connectors/aws/sns/src/jvmMain/kotlin/com/river/connector/aws/sns/model/PublishMessageRequest.kt similarity index 100% rename from connectors/aws/sns/src/main/kotlin/com/river/connector/aws/sns/model/PublishMessageRequest.kt rename to connectors/aws/sns/src/jvmMain/kotlin/com/river/connector/aws/sns/model/PublishMessageRequest.kt diff --git a/connectors/aws/sns/src/main/kotlin/com/river/connector/aws/sns/model/PublishMessageResponse.kt b/connectors/aws/sns/src/jvmMain/kotlin/com/river/connector/aws/sns/model/PublishMessageResponse.kt similarity index 100% rename from connectors/aws/sns/src/main/kotlin/com/river/connector/aws/sns/model/PublishMessageResponse.kt rename to connectors/aws/sns/src/jvmMain/kotlin/com/river/connector/aws/sns/model/PublishMessageResponse.kt diff --git a/connectors/aws/sns/src/test/kotlin/com/river/connector/aws/sns/SnsAsyncClientExtTest.kt b/connectors/aws/sns/src/jvmTest/kotlin/com/river/connector/aws/sns/SnsAsyncClientExtTest.kt similarity index 100% rename from connectors/aws/sns/src/test/kotlin/com/river/connector/aws/sns/SnsAsyncClientExtTest.kt rename to connectors/aws/sns/src/jvmTest/kotlin/com/river/connector/aws/sns/SnsAsyncClientExtTest.kt diff --git a/connectors/aws/sqs/build.gradle.kts b/connectors/aws/sqs/build.gradle.kts index c784cdff..0071c799 100644 --- a/connectors/aws/sqs/build.gradle.kts +++ b/connectors/aws/sqs/build.gradle.kts @@ -1,5 +1,9 @@ -dependencies { - api(libs.aws.sqs) { - exclude("software.amazon.awssdk", "netty-nio-client") +kotlin { + sourceSets { + val jvmMain by getting { + dependencies { + api(rootProject.libs.aws.sqs) + } + } } } diff --git a/connectors/aws/sqs/src/main/kotlin/com/river/connector/aws/sqs/SqsAsyncClientExt.kt b/connectors/aws/sqs/src/jvmMain/kotlin/com/river/connector/aws/sqs/SqsAsyncClientExt.kt similarity index 100% rename from connectors/aws/sqs/src/main/kotlin/com/river/connector/aws/sqs/SqsAsyncClientExt.kt rename to connectors/aws/sqs/src/jvmMain/kotlin/com/river/connector/aws/sqs/SqsAsyncClientExt.kt diff --git a/connectors/aws/sqs/src/main/kotlin/com/river/connector/aws/sqs/model/Acknowledgment.kt b/connectors/aws/sqs/src/jvmMain/kotlin/com/river/connector/aws/sqs/model/Acknowledgment.kt similarity index 100% rename from connectors/aws/sqs/src/main/kotlin/com/river/connector/aws/sqs/model/Acknowledgment.kt rename to connectors/aws/sqs/src/jvmMain/kotlin/com/river/connector/aws/sqs/model/Acknowledgment.kt diff --git a/connectors/aws/sqs/src/main/kotlin/com/river/connector/aws/sqs/model/AcknowledgmentResult.kt b/connectors/aws/sqs/src/jvmMain/kotlin/com/river/connector/aws/sqs/model/AcknowledgmentResult.kt similarity index 100% rename from connectors/aws/sqs/src/main/kotlin/com/river/connector/aws/sqs/model/AcknowledgmentResult.kt rename to connectors/aws/sqs/src/jvmMain/kotlin/com/river/connector/aws/sqs/model/AcknowledgmentResult.kt diff --git a/connectors/aws/sqs/src/main/kotlin/com/river/connector/aws/sqs/model/MessageAcknowledgment.kt b/connectors/aws/sqs/src/jvmMain/kotlin/com/river/connector/aws/sqs/model/MessageAcknowledgment.kt similarity index 100% rename from connectors/aws/sqs/src/main/kotlin/com/river/connector/aws/sqs/model/MessageAcknowledgment.kt rename to connectors/aws/sqs/src/jvmMain/kotlin/com/river/connector/aws/sqs/model/MessageAcknowledgment.kt diff --git a/connectors/aws/sqs/src/main/kotlin/com/river/connector/aws/sqs/model/OnError.kt b/connectors/aws/sqs/src/jvmMain/kotlin/com/river/connector/aws/sqs/model/OnError.kt similarity index 100% rename from connectors/aws/sqs/src/main/kotlin/com/river/connector/aws/sqs/model/OnError.kt rename to connectors/aws/sqs/src/jvmMain/kotlin/com/river/connector/aws/sqs/model/OnError.kt diff --git a/connectors/aws/sqs/src/main/kotlin/com/river/connector/aws/sqs/model/ReceiveConfiguration.kt b/connectors/aws/sqs/src/jvmMain/kotlin/com/river/connector/aws/sqs/model/ReceiveConfiguration.kt similarity index 100% rename from connectors/aws/sqs/src/main/kotlin/com/river/connector/aws/sqs/model/ReceiveConfiguration.kt rename to connectors/aws/sqs/src/jvmMain/kotlin/com/river/connector/aws/sqs/model/ReceiveConfiguration.kt diff --git a/connectors/aws/sqs/src/main/kotlin/com/river/connector/aws/sqs/model/ReceiveMessageRequestBuilder.kt b/connectors/aws/sqs/src/jvmMain/kotlin/com/river/connector/aws/sqs/model/ReceiveMessageRequestBuilder.kt similarity index 100% rename from connectors/aws/sqs/src/main/kotlin/com/river/connector/aws/sqs/model/ReceiveMessageRequestBuilder.kt rename to connectors/aws/sqs/src/jvmMain/kotlin/com/river/connector/aws/sqs/model/ReceiveMessageRequestBuilder.kt diff --git a/connectors/aws/sqs/src/main/kotlin/com/river/connector/aws/sqs/model/SendMessageRequest.kt b/connectors/aws/sqs/src/jvmMain/kotlin/com/river/connector/aws/sqs/model/SendMessageRequest.kt similarity index 100% rename from connectors/aws/sqs/src/main/kotlin/com/river/connector/aws/sqs/model/SendMessageRequest.kt rename to connectors/aws/sqs/src/jvmMain/kotlin/com/river/connector/aws/sqs/model/SendMessageRequest.kt diff --git a/connectors/aws/sqs/src/main/kotlin/com/river/connector/aws/sqs/model/SendMessageResponse.kt b/connectors/aws/sqs/src/jvmMain/kotlin/com/river/connector/aws/sqs/model/SendMessageResponse.kt similarity index 100% rename from connectors/aws/sqs/src/main/kotlin/com/river/connector/aws/sqs/model/SendMessageResponse.kt rename to connectors/aws/sqs/src/jvmMain/kotlin/com/river/connector/aws/sqs/model/SendMessageResponse.kt diff --git a/connectors/aws/sqs/src/test/kotlin/com/river/connector/aws/sqs/SqsAsyncClientExtTest.kt b/connectors/aws/sqs/src/jvmTest/kotlin/com/river/connector/aws/sqs/SqsAsyncClientExtTest.kt similarity index 100% rename from connectors/aws/sqs/src/test/kotlin/com/river/connector/aws/sqs/SqsAsyncClientExtTest.kt rename to connectors/aws/sqs/src/jvmTest/kotlin/com/river/connector/aws/sqs/SqsAsyncClientExtTest.kt diff --git a/connectors/azure/build.gradle.kts b/connectors/azure/build.gradle.kts index a5b83944..5e577862 100644 --- a/connectors/azure/build.gradle.kts +++ b/connectors/azure/build.gradle.kts @@ -1,5 +1,11 @@ subprojects { - dependencies { - api(rootProject.libs.coroutines.reactive) + kotlin { + sourceSets { + jvmMain { + dependencies { + api(rootProject.libs.coroutines.reactive) + } + } + } } } diff --git a/connectors/azure/queue-storage/build.gradle.kts b/connectors/azure/queue-storage/build.gradle.kts index 41764dd3..11b12c2e 100644 --- a/connectors/azure/queue-storage/build.gradle.kts +++ b/connectors/azure/queue-storage/build.gradle.kts @@ -1,3 +1,9 @@ -dependencies { - api(libs.azure.queue.storage) +kotlin { + sourceSets { + jvmMain { + dependencies { + api(libs.azure.queue.storage) + } + } + } } diff --git a/connectors/azure/queue-storage/src/main/kotlin/com/river/connector/azure/queue/storage/QueueStorageExt.kt b/connectors/azure/queue-storage/src/jvmMain/kotlin/com/river/connector/azure/queue/storage/QueueStorageExt.kt similarity index 100% rename from connectors/azure/queue-storage/src/main/kotlin/com/river/connector/azure/queue/storage/QueueStorageExt.kt rename to connectors/azure/queue-storage/src/jvmMain/kotlin/com/river/connector/azure/queue/storage/QueueStorageExt.kt diff --git a/connectors/azure/queue-storage/src/main/kotlin/com/river/connector/azure/queue/storage/model/SendMessageRequest.kt b/connectors/azure/queue-storage/src/jvmMain/kotlin/com/river/connector/azure/queue/storage/model/SendMessageRequest.kt similarity index 100% rename from connectors/azure/queue-storage/src/main/kotlin/com/river/connector/azure/queue/storage/model/SendMessageRequest.kt rename to connectors/azure/queue-storage/src/jvmMain/kotlin/com/river/connector/azure/queue/storage/model/SendMessageRequest.kt diff --git a/connectors/azure/queue-storage/src/test/kotlin/com/river/connector/azure/queue/storage/QueueStorageExtKtTest.kt b/connectors/azure/queue-storage/src/jvmTest/kotlin/com/river/connector/azure/queue/storage/QueueStorageExtKtTest.kt similarity index 100% rename from connectors/azure/queue-storage/src/test/kotlin/com/river/connector/azure/queue/storage/QueueStorageExtKtTest.kt rename to connectors/azure/queue-storage/src/jvmTest/kotlin/com/river/connector/azure/queue/storage/QueueStorageExtKtTest.kt diff --git a/connectors/build.gradle.kts b/connectors/build.gradle.kts index 3221aec8..94bb2f09 100644 --- a/connectors/build.gradle.kts +++ b/connectors/build.gradle.kts @@ -1,6 +1,12 @@ subprojects { - dependencies { - api(rootProject.modules.core) - api(rootProject.libs.slf4j) + kotlin { + sourceSets { + commonMain { + dependencies { + api(project(":core")) + api(rootProject.libs.slf4j) + } + } + } } } diff --git a/connectors/console/src/main/kotlin/com/river/connector/console/ConsoleExt.kt b/connectors/console/src/jvmMain/kotlin/com/river/connector/console/ConsoleExt.kt similarity index 100% rename from connectors/console/src/main/kotlin/com/river/connector/console/ConsoleExt.kt rename to connectors/console/src/jvmMain/kotlin/com/river/connector/console/ConsoleExt.kt diff --git a/connectors/console/src/test/kotlin/com/river/connector/console/ConsoleExtKtTest.kt b/connectors/console/src/jvmTest/kotlin/com/river/connector/console/ConsoleExtKtTest.kt similarity index 100% rename from connectors/console/src/test/kotlin/com/river/connector/console/ConsoleExtKtTest.kt rename to connectors/console/src/jvmTest/kotlin/com/river/connector/console/ConsoleExtKtTest.kt diff --git a/connectors/elasticsearch/build.gradle.kts b/connectors/elasticsearch/build.gradle.kts index c622f642..38d7082a 100644 --- a/connectors/elasticsearch/build.gradle.kts +++ b/connectors/elasticsearch/build.gradle.kts @@ -1,4 +1,10 @@ -dependencies { - api(libs.elasticsearch) - api(libs.jackson) +kotlin { + sourceSets { + jvmMain { + dependencies { + api(libs.elasticsearch) + api(libs.jackson) + } + } + } } diff --git a/connectors/elasticsearch/src/main/kotlin/com/river/connector/elasticsearch/Document.kt b/connectors/elasticsearch/src/jvmMain/kotlin/com/river/connector/elasticsearch/Document.kt similarity index 100% rename from connectors/elasticsearch/src/main/kotlin/com/river/connector/elasticsearch/Document.kt rename to connectors/elasticsearch/src/jvmMain/kotlin/com/river/connector/elasticsearch/Document.kt diff --git a/connectors/elasticsearch/src/main/kotlin/com/river/connector/elasticsearch/ElasticsearchAsyncClientExt.kt b/connectors/elasticsearch/src/jvmMain/kotlin/com/river/connector/elasticsearch/ElasticsearchAsyncClientExt.kt similarity index 100% rename from connectors/elasticsearch/src/main/kotlin/com/river/connector/elasticsearch/ElasticsearchAsyncClientExt.kt rename to connectors/elasticsearch/src/jvmMain/kotlin/com/river/connector/elasticsearch/ElasticsearchAsyncClientExt.kt diff --git a/connectors/elasticsearch/src/main/kotlin/com/river/connector/elasticsearch/PaginatedSearch.kt b/connectors/elasticsearch/src/jvmMain/kotlin/com/river/connector/elasticsearch/PaginatedSearch.kt similarity index 100% rename from connectors/elasticsearch/src/main/kotlin/com/river/connector/elasticsearch/PaginatedSearch.kt rename to connectors/elasticsearch/src/jvmMain/kotlin/com/river/connector/elasticsearch/PaginatedSearch.kt diff --git a/connectors/file/src/main/kotlin/com/river/connector/file/AsynchronousFileChannelExt.kt b/connectors/file/src/jvmMain/kotlin/com/river/connector/file/AsynchronousFileChannelExt.kt similarity index 100% rename from connectors/file/src/main/kotlin/com/river/connector/file/AsynchronousFileChannelExt.kt rename to connectors/file/src/jvmMain/kotlin/com/river/connector/file/AsynchronousFileChannelExt.kt diff --git a/connectors/file/src/main/kotlin/com/river/connector/file/FileExt.kt b/connectors/file/src/jvmMain/kotlin/com/river/connector/file/FileExt.kt similarity index 100% rename from connectors/file/src/main/kotlin/com/river/connector/file/FileExt.kt rename to connectors/file/src/jvmMain/kotlin/com/river/connector/file/FileExt.kt diff --git a/connectors/file/src/main/kotlin/com/river/connector/file/InputStreamExt.kt b/connectors/file/src/jvmMain/kotlin/com/river/connector/file/InputStreamExt.kt similarity index 100% rename from connectors/file/src/main/kotlin/com/river/connector/file/InputStreamExt.kt rename to connectors/file/src/jvmMain/kotlin/com/river/connector/file/InputStreamExt.kt diff --git a/connectors/file/src/main/kotlin/com/river/connector/file/PathExt.kt b/connectors/file/src/jvmMain/kotlin/com/river/connector/file/PathExt.kt similarity index 100% rename from connectors/file/src/main/kotlin/com/river/connector/file/PathExt.kt rename to connectors/file/src/jvmMain/kotlin/com/river/connector/file/PathExt.kt diff --git a/connectors/file/src/main/kotlin/com/river/connector/file/ZipExt.kt b/connectors/file/src/jvmMain/kotlin/com/river/connector/file/ZipExt.kt similarity index 100% rename from connectors/file/src/main/kotlin/com/river/connector/file/ZipExt.kt rename to connectors/file/src/jvmMain/kotlin/com/river/connector/file/ZipExt.kt diff --git a/connectors/file/src/main/kotlin/com/river/connector/file/model/ContentfulZipEntry.kt b/connectors/file/src/jvmMain/kotlin/com/river/connector/file/model/ContentfulZipEntry.kt similarity index 100% rename from connectors/file/src/main/kotlin/com/river/connector/file/model/ContentfulZipEntry.kt rename to connectors/file/src/jvmMain/kotlin/com/river/connector/file/model/ContentfulZipEntry.kt diff --git a/connectors/format/csv/build.gradle.kts b/connectors/format/csv/build.gradle.kts index 1ab0f241..72573556 100644 --- a/connectors/format/csv/build.gradle.kts +++ b/connectors/format/csv/build.gradle.kts @@ -1,3 +1,10 @@ -dependencies { - api(project.modules.file) +kotlin { + sourceSets { + jvmMain { + dependencies { + val modules = modules { project(it) } + api(modules.file) + } + } + } } diff --git a/connectors/format/csv/src/main/kotlin/com/river/connector/format/csv/CsvExt.kt b/connectors/format/csv/src/jvmMain/kotlin/com/river/connector/format/csv/CsvExt.kt similarity index 100% rename from connectors/format/csv/src/main/kotlin/com/river/connector/format/csv/CsvExt.kt rename to connectors/format/csv/src/jvmMain/kotlin/com/river/connector/format/csv/CsvExt.kt diff --git a/connectors/format/csv/src/test/kotlin/com/river/connector/format/csv/CsvExtKtTest.kt b/connectors/format/csv/src/jvmTest/kotlin/com/river/connector/format/csv/CsvExtKtTest.kt similarity index 100% rename from connectors/format/csv/src/test/kotlin/com/river/connector/format/csv/CsvExtKtTest.kt rename to connectors/format/csv/src/jvmTest/kotlin/com/river/connector/format/csv/CsvExtKtTest.kt diff --git a/connectors/format/json/build.gradle.kts b/connectors/format/json/build.gradle.kts index 6830c48d..09ac646c 100644 --- a/connectors/format/json/build.gradle.kts +++ b/connectors/format/json/build.gradle.kts @@ -1,3 +1,9 @@ -dependencies { - api(libs.jackson) +kotlin { + sourceSets { + jvmMain { + dependencies { + api(libs.jackson) + } + } + } } diff --git a/connectors/format/json/src/main/kotlin/com/river/connector/format/json/JsonExt.kt b/connectors/format/json/src/jvmMain/kotlin/com/river/connector/format/json/JsonExt.kt similarity index 100% rename from connectors/format/json/src/main/kotlin/com/river/connector/format/json/JsonExt.kt rename to connectors/format/json/src/jvmMain/kotlin/com/river/connector/format/json/JsonExt.kt diff --git a/connectors/format/json/src/test/kotlin/com/river/connector/format/json/JsonExtKtTest.kt b/connectors/format/json/src/jvmTest/kotlin/com/river/connector/format/json/JsonExtKtTest.kt similarity index 100% rename from connectors/format/json/src/test/kotlin/com/river/connector/format/json/JsonExtKtTest.kt rename to connectors/format/json/src/jvmTest/kotlin/com/river/connector/format/json/JsonExtKtTest.kt diff --git a/connectors/format/positional-flat-line/src/main/kotlin/com/river/connector/format/positional/flat/line/PositionalFlatLineExt.kt b/connectors/format/positional-flat-line/src/jvmMain/kotlin/com/river/connector/format/positional/flat/line/PositionalFlatLineExt.kt similarity index 100% rename from connectors/format/positional-flat-line/src/main/kotlin/com/river/connector/format/positional/flat/line/PositionalFlatLineExt.kt rename to connectors/format/positional-flat-line/src/jvmMain/kotlin/com/river/connector/format/positional/flat/line/PositionalFlatLineExt.kt diff --git a/connectors/ftp/build.gradle.kts b/connectors/ftp/build.gradle.kts index e274c739..b29f2e74 100644 --- a/connectors/ftp/build.gradle.kts +++ b/connectors/ftp/build.gradle.kts @@ -1,6 +1,18 @@ -dependencies { - api(project.modules.file) - api(libs.commons.net) +kotlin { + sourceSets { + val jvmMain by getting { + dependencies { + val modules = modules { project(it) } - testImplementation(libs.mock.ftpserver) + api(modules.file) + api(libs.commons.net) + } + } + + val jvmTest by getting { + dependencies { + api(libs.mock.ftpserver) + } + } + } } diff --git a/connectors/ftp/src/main/kotlin/com/river/connector/ftp/FTPClientExt.kt b/connectors/ftp/src/jvmMain/kotlin/com/river/connector/ftp/FTPClientExt.kt similarity index 100% rename from connectors/ftp/src/main/kotlin/com/river/connector/ftp/FTPClientExt.kt rename to connectors/ftp/src/jvmMain/kotlin/com/river/connector/ftp/FTPClientExt.kt diff --git a/connectors/ftp/src/main/kotlin/com/river/connector/ftp/model/FtpConfiguration.kt b/connectors/ftp/src/jvmMain/kotlin/com/river/connector/ftp/model/FtpConfiguration.kt similarity index 100% rename from connectors/ftp/src/main/kotlin/com/river/connector/ftp/model/FtpConfiguration.kt rename to connectors/ftp/src/jvmMain/kotlin/com/river/connector/ftp/model/FtpConfiguration.kt diff --git a/connectors/ftp/src/test/kotlin/com/river/connector/ftp/FTPClientExtKtTest.kt b/connectors/ftp/src/jvmTest/kotlin/com/river/connector/ftp/FTPClientExtKtTest.kt similarity index 100% rename from connectors/ftp/src/test/kotlin/com/river/connector/ftp/FTPClientExtKtTest.kt rename to connectors/ftp/src/jvmTest/kotlin/com/river/connector/ftp/FTPClientExtKtTest.kt diff --git a/connectors/ftp/src/test/kotlin/com/river/connector/ftp/FtpServerMockExt.kt b/connectors/ftp/src/jvmTest/kotlin/com/river/connector/ftp/FtpServerMockExt.kt similarity index 100% rename from connectors/ftp/src/test/kotlin/com/river/connector/ftp/FtpServerMockExt.kt rename to connectors/ftp/src/jvmTest/kotlin/com/river/connector/ftp/FtpServerMockExt.kt diff --git a/connectors/github/build.gradle.kts b/connectors/github/build.gradle.kts index b8b5c53c..fa45c487 100644 --- a/connectors/github/build.gradle.kts +++ b/connectors/github/build.gradle.kts @@ -1,10 +1,22 @@ -dependencies { - api(project.modules.http) - api(project.modules.json) - api(project.modules.file) +kotlin { + sourceSets { + jvmMain { + dependencies { + val modules = modules { project(it) } - api(libs.jackson) + api(modules.http) + api(modules.json) + api(modules.file) - testImplementation(libs.kotest.wiremock) - testImplementation(libs.kotlin.wiremock) + api(libs.jackson) + } + } + + jvmTest { + dependencies { + api(libs.kotlin.wiremock) + api(libs.kotest.wiremock) + } + } + } } diff --git a/connectors/github/src/main/kotlin/com/river/connector/github/GithubApi.kt b/connectors/github/src/jvmMain/kotlin/com/river/connector/github/GithubApi.kt similarity index 100% rename from connectors/github/src/main/kotlin/com/river/connector/github/GithubApi.kt rename to connectors/github/src/jvmMain/kotlin/com/river/connector/github/GithubApi.kt diff --git a/connectors/github/src/main/kotlin/com/river/connector/github/GithubApiExt.kt b/connectors/github/src/jvmMain/kotlin/com/river/connector/github/GithubApiExt.kt similarity index 100% rename from connectors/github/src/main/kotlin/com/river/connector/github/GithubApiExt.kt rename to connectors/github/src/jvmMain/kotlin/com/river/connector/github/GithubApiExt.kt diff --git a/connectors/github/src/main/kotlin/com/river/connector/github/internal/Ext.kt b/connectors/github/src/jvmMain/kotlin/com/river/connector/github/internal/Ext.kt similarity index 100% rename from connectors/github/src/main/kotlin/com/river/connector/github/internal/Ext.kt rename to connectors/github/src/jvmMain/kotlin/com/river/connector/github/internal/Ext.kt diff --git a/connectors/github/src/main/kotlin/com/river/connector/github/internal/InternalGithubApiExt.kt b/connectors/github/src/jvmMain/kotlin/com/river/connector/github/internal/InternalGithubApiExt.kt similarity index 100% rename from connectors/github/src/main/kotlin/com/river/connector/github/internal/InternalGithubApiExt.kt rename to connectors/github/src/jvmMain/kotlin/com/river/connector/github/internal/InternalGithubApiExt.kt diff --git a/connectors/github/src/main/kotlin/com/river/connector/github/model/BlobContent.kt b/connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/BlobContent.kt similarity index 100% rename from connectors/github/src/main/kotlin/com/river/connector/github/model/BlobContent.kt rename to connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/BlobContent.kt diff --git a/connectors/github/src/main/kotlin/com/river/connector/github/model/Commit.kt b/connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/Commit.kt similarity index 100% rename from connectors/github/src/main/kotlin/com/river/connector/github/model/Commit.kt rename to connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/Commit.kt diff --git a/connectors/github/src/main/kotlin/com/river/connector/github/model/Content.kt b/connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/Content.kt similarity index 100% rename from connectors/github/src/main/kotlin/com/river/connector/github/model/Content.kt rename to connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/Content.kt diff --git a/connectors/github/src/main/kotlin/com/river/connector/github/model/Enums.kt b/connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/Enums.kt similarity index 100% rename from connectors/github/src/main/kotlin/com/river/connector/github/model/Enums.kt rename to connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/Enums.kt diff --git a/connectors/github/src/main/kotlin/com/river/connector/github/model/FileContent.kt b/connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/FileContent.kt similarity index 100% rename from connectors/github/src/main/kotlin/com/river/connector/github/model/FileContent.kt rename to connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/FileContent.kt diff --git a/connectors/github/src/main/kotlin/com/river/connector/github/model/Issue.kt b/connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/Issue.kt similarity index 100% rename from connectors/github/src/main/kotlin/com/river/connector/github/model/Issue.kt rename to connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/Issue.kt diff --git a/connectors/github/src/main/kotlin/com/river/connector/github/model/PullRequest.kt b/connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/PullRequest.kt similarity index 100% rename from connectors/github/src/main/kotlin/com/river/connector/github/model/PullRequest.kt rename to connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/PullRequest.kt diff --git a/connectors/github/src/main/kotlin/com/river/connector/github/model/QueryParameters.kt b/connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/QueryParameters.kt similarity index 100% rename from connectors/github/src/main/kotlin/com/river/connector/github/model/QueryParameters.kt rename to connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/QueryParameters.kt diff --git a/connectors/github/src/main/kotlin/com/river/connector/github/model/Repository.kt b/connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/Repository.kt similarity index 100% rename from connectors/github/src/main/kotlin/com/river/connector/github/model/Repository.kt rename to connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/Repository.kt diff --git a/connectors/github/src/main/kotlin/com/river/connector/github/model/TreeRef.kt b/connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/TreeRef.kt similarity index 100% rename from connectors/github/src/main/kotlin/com/river/connector/github/model/TreeRef.kt rename to connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/TreeRef.kt diff --git a/connectors/github/src/main/kotlin/com/river/connector/github/model/query/CommitQuery.kt b/connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/query/CommitQuery.kt similarity index 100% rename from connectors/github/src/main/kotlin/com/river/connector/github/model/query/CommitQuery.kt rename to connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/query/CommitQuery.kt diff --git a/connectors/github/src/main/kotlin/com/river/connector/github/model/query/IssueQuery.kt b/connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/query/IssueQuery.kt similarity index 100% rename from connectors/github/src/main/kotlin/com/river/connector/github/model/query/IssueQuery.kt rename to connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/query/IssueQuery.kt diff --git a/connectors/github/src/main/kotlin/com/river/connector/github/model/query/PageableQuery.kt b/connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/query/PageableQuery.kt similarity index 100% rename from connectors/github/src/main/kotlin/com/river/connector/github/model/query/PageableQuery.kt rename to connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/query/PageableQuery.kt diff --git a/connectors/github/src/main/kotlin/com/river/connector/github/model/query/PullRequestQuery.kt b/connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/query/PullRequestQuery.kt similarity index 100% rename from connectors/github/src/main/kotlin/com/river/connector/github/model/query/PullRequestQuery.kt rename to connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/query/PullRequestQuery.kt diff --git a/connectors/github/src/main/kotlin/com/river/connector/github/model/query/RepositoryIssueQuery.kt b/connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/query/RepositoryIssueQuery.kt similarity index 100% rename from connectors/github/src/main/kotlin/com/river/connector/github/model/query/RepositoryIssueQuery.kt rename to connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/query/RepositoryIssueQuery.kt diff --git a/connectors/github/src/main/kotlin/com/river/connector/github/model/query/RepositoryQuery.kt b/connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/query/RepositoryQuery.kt similarity index 100% rename from connectors/github/src/main/kotlin/com/river/connector/github/model/query/RepositoryQuery.kt rename to connectors/github/src/jvmMain/kotlin/com/river/connector/github/model/query/RepositoryQuery.kt diff --git a/connectors/github/src/test/kotlin/com/river/connector/github/GithubApiExtKtTest.kt b/connectors/github/src/jvmTest/kotlin/com/river/connector/github/GithubApiExtKtTest.kt similarity index 100% rename from connectors/github/src/test/kotlin/com/river/connector/github/GithubApiExtKtTest.kt rename to connectors/github/src/jvmTest/kotlin/com/river/connector/github/GithubApiExtKtTest.kt diff --git a/connectors/github/src/test/resources/commits/page_1.json b/connectors/github/src/jvmTest/resources/commits/page_1.json similarity index 100% rename from connectors/github/src/test/resources/commits/page_1.json rename to connectors/github/src/jvmTest/resources/commits/page_1.json diff --git a/connectors/github/src/test/resources/commits/page_2.json b/connectors/github/src/jvmTest/resources/commits/page_2.json similarity index 100% rename from connectors/github/src/test/resources/commits/page_2.json rename to connectors/github/src/jvmTest/resources/commits/page_2.json diff --git a/connectors/github/src/test/resources/commits/page_3.json b/connectors/github/src/jvmTest/resources/commits/page_3.json similarity index 100% rename from connectors/github/src/test/resources/commits/page_3.json rename to connectors/github/src/jvmTest/resources/commits/page_3.json diff --git a/connectors/google/drive/build.gradle.kts b/connectors/google/drive/build.gradle.kts index a080d841..2558f2a1 100644 --- a/connectors/google/drive/build.gradle.kts +++ b/connectors/google/drive/build.gradle.kts @@ -1,8 +1,20 @@ -dependencies { - api(project.modules.http) - api(project.modules.json) - api(libs.jackson) - api(libs.java.jwt) +kotlin { + sourceSets { + jvmMain { + dependencies { + val modules = modules { project(it) } - testImplementation(libs.kotest.wiremock) + api(modules.http) + api(modules.json) + api(libs.jackson) + api(libs.java.jwt) + } + } + + jvmTest { + dependencies { + api(libs.kotest.wiremock) + } + } + } } diff --git a/connectors/google/drive/src/main/kotlin/com/river/connector/google/drive/FileList.kt b/connectors/google/drive/src/jvmMain/kotlin/com/river/connector/google/drive/FileList.kt similarity index 100% rename from connectors/google/drive/src/main/kotlin/com/river/connector/google/drive/FileList.kt rename to connectors/google/drive/src/jvmMain/kotlin/com/river/connector/google/drive/FileList.kt diff --git a/connectors/google/drive/src/main/kotlin/com/river/connector/google/drive/FilesListQuery.kt b/connectors/google/drive/src/jvmMain/kotlin/com/river/connector/google/drive/FilesListQuery.kt similarity index 100% rename from connectors/google/drive/src/main/kotlin/com/river/connector/google/drive/FilesListQuery.kt rename to connectors/google/drive/src/jvmMain/kotlin/com/river/connector/google/drive/FilesListQuery.kt diff --git a/connectors/google/drive/src/main/kotlin/com/river/connector/google/drive/GoogleDriveApi.kt b/connectors/google/drive/src/jvmMain/kotlin/com/river/connector/google/drive/GoogleDriveApi.kt similarity index 100% rename from connectors/google/drive/src/main/kotlin/com/river/connector/google/drive/GoogleDriveApi.kt rename to connectors/google/drive/src/jvmMain/kotlin/com/river/connector/google/drive/GoogleDriveApi.kt diff --git a/connectors/google/drive/src/main/kotlin/com/river/connector/google/drive/GoogleDriveApiExt.kt b/connectors/google/drive/src/jvmMain/kotlin/com/river/connector/google/drive/GoogleDriveApiExt.kt similarity index 100% rename from connectors/google/drive/src/main/kotlin/com/river/connector/google/drive/GoogleDriveApiExt.kt rename to connectors/google/drive/src/jvmMain/kotlin/com/river/connector/google/drive/GoogleDriveApiExt.kt diff --git a/connectors/google/drive/src/main/kotlin/com/river/connector/google/drive/internal/BearerTokenActor.kt b/connectors/google/drive/src/jvmMain/kotlin/com/river/connector/google/drive/internal/BearerTokenActor.kt similarity index 100% rename from connectors/google/drive/src/main/kotlin/com/river/connector/google/drive/internal/BearerTokenActor.kt rename to connectors/google/drive/src/jvmMain/kotlin/com/river/connector/google/drive/internal/BearerTokenActor.kt diff --git a/connectors/http/build.gradle.kts b/connectors/http/build.gradle.kts index f892eace..ff571810 100644 --- a/connectors/http/build.gradle.kts +++ b/connectors/http/build.gradle.kts @@ -1,3 +1,9 @@ -dependencies { - api(libs.coroutines.jdk9) +kotlin { + sourceSets { + jvmMain { + dependencies { + api(libs.coroutines.jdk9) + } + } + } } diff --git a/connectors/http/src/main/kotlin/com/river/connector/http/Authorization.kt b/connectors/http/src/jvmMain/kotlin/com/river/connector/http/Authorization.kt similarity index 100% rename from connectors/http/src/main/kotlin/com/river/connector/http/Authorization.kt rename to connectors/http/src/jvmMain/kotlin/com/river/connector/http/Authorization.kt diff --git a/connectors/http/src/main/kotlin/com/river/connector/http/BodyHandlerExt.kt b/connectors/http/src/jvmMain/kotlin/com/river/connector/http/BodyHandlerExt.kt similarity index 100% rename from connectors/http/src/main/kotlin/com/river/connector/http/BodyHandlerExt.kt rename to connectors/http/src/jvmMain/kotlin/com/river/connector/http/BodyHandlerExt.kt diff --git a/connectors/http/src/main/kotlin/com/river/connector/http/CustomHttpRequestBuilder.kt b/connectors/http/src/jvmMain/kotlin/com/river/connector/http/CustomHttpRequestBuilder.kt similarity index 100% rename from connectors/http/src/main/kotlin/com/river/connector/http/CustomHttpRequestBuilder.kt rename to connectors/http/src/jvmMain/kotlin/com/river/connector/http/CustomHttpRequestBuilder.kt diff --git a/connectors/http/src/main/kotlin/com/river/connector/http/HttpExt.kt b/connectors/http/src/jvmMain/kotlin/com/river/connector/http/HttpExt.kt similarity index 100% rename from connectors/http/src/main/kotlin/com/river/connector/http/HttpExt.kt rename to connectors/http/src/jvmMain/kotlin/com/river/connector/http/HttpExt.kt diff --git a/connectors/http/src/main/kotlin/com/river/connector/http/HttpMethod.kt b/connectors/http/src/jvmMain/kotlin/com/river/connector/http/HttpMethod.kt similarity index 100% rename from connectors/http/src/main/kotlin/com/river/connector/http/HttpMethod.kt rename to connectors/http/src/jvmMain/kotlin/com/river/connector/http/HttpMethod.kt diff --git a/connectors/http/src/main/kotlin/com/river/connector/http/HttpRequestExt.kt b/connectors/http/src/jvmMain/kotlin/com/river/connector/http/HttpRequestExt.kt similarity index 100% rename from connectors/http/src/main/kotlin/com/river/connector/http/HttpRequestExt.kt rename to connectors/http/src/jvmMain/kotlin/com/river/connector/http/HttpRequestExt.kt diff --git a/connectors/http/src/main/kotlin/com/river/connector/http/SSEExt.kt b/connectors/http/src/jvmMain/kotlin/com/river/connector/http/SSEExt.kt similarity index 100% rename from connectors/http/src/main/kotlin/com/river/connector/http/SSEExt.kt rename to connectors/http/src/jvmMain/kotlin/com/river/connector/http/SSEExt.kt diff --git a/connectors/http/src/main/kotlin/com/river/connector/http/ServerSentEvent.kt b/connectors/http/src/jvmMain/kotlin/com/river/connector/http/ServerSentEvent.kt similarity index 100% rename from connectors/http/src/main/kotlin/com/river/connector/http/ServerSentEvent.kt rename to connectors/http/src/jvmMain/kotlin/com/river/connector/http/ServerSentEvent.kt diff --git a/connectors/jms/build.gradle.kts b/connectors/jms/build.gradle.kts index 36e2cdc7..5ea12a4b 100644 --- a/connectors/jms/build.gradle.kts +++ b/connectors/jms/build.gradle.kts @@ -1,6 +1,16 @@ -dependencies { - api(libs.jms.api) +kotlin { + sourceSets { + val jvmMain by getting { + dependencies { + api(libs.jms.api) + } + } - testImplementation(libs.artemis.client) - testImplementation(libs.artemis.server) + val jvmTest by getting { + dependencies { + api(libs.artemis.client) + api(libs.artemis.server) + } + } + } } diff --git a/connectors/jms/src/main/kotlin/com/river/connector/jms/JmsExt.kt b/connectors/jms/src/jvmMain/kotlin/com/river/connector/jms/JmsExt.kt similarity index 100% rename from connectors/jms/src/main/kotlin/com/river/connector/jms/JmsExt.kt rename to connectors/jms/src/jvmMain/kotlin/com/river/connector/jms/JmsExt.kt diff --git a/connectors/jms/src/main/kotlin/com/river/connector/jms/model/CommitableJmsMessage.kt b/connectors/jms/src/jvmMain/kotlin/com/river/connector/jms/model/CommitableJmsMessage.kt similarity index 100% rename from connectors/jms/src/main/kotlin/com/river/connector/jms/model/CommitableJmsMessage.kt rename to connectors/jms/src/jvmMain/kotlin/com/river/connector/jms/model/CommitableJmsMessage.kt diff --git a/connectors/jms/src/main/kotlin/com/river/connector/jms/model/Credentials.kt b/connectors/jms/src/jvmMain/kotlin/com/river/connector/jms/model/Credentials.kt similarity index 100% rename from connectors/jms/src/main/kotlin/com/river/connector/jms/model/Credentials.kt rename to connectors/jms/src/jvmMain/kotlin/com/river/connector/jms/model/Credentials.kt diff --git a/connectors/jms/src/main/kotlin/com/river/connector/jms/model/DeliveryMode.kt b/connectors/jms/src/jvmMain/kotlin/com/river/connector/jms/model/DeliveryMode.kt similarity index 100% rename from connectors/jms/src/main/kotlin/com/river/connector/jms/model/DeliveryMode.kt rename to connectors/jms/src/jvmMain/kotlin/com/river/connector/jms/model/DeliveryMode.kt diff --git a/connectors/jms/src/main/kotlin/com/river/connector/jms/model/JmsDestination.kt b/connectors/jms/src/jvmMain/kotlin/com/river/connector/jms/model/JmsDestination.kt similarity index 100% rename from connectors/jms/src/main/kotlin/com/river/connector/jms/model/JmsDestination.kt rename to connectors/jms/src/jvmMain/kotlin/com/river/connector/jms/model/JmsDestination.kt diff --git a/connectors/jms/src/main/kotlin/com/river/connector/jms/model/JmsMessage.kt b/connectors/jms/src/jvmMain/kotlin/com/river/connector/jms/model/JmsMessage.kt similarity index 100% rename from connectors/jms/src/main/kotlin/com/river/connector/jms/model/JmsMessage.kt rename to connectors/jms/src/jvmMain/kotlin/com/river/connector/jms/model/JmsMessage.kt diff --git a/connectors/jms/src/main/kotlin/com/river/connector/jms/model/JmsPrimitive.kt b/connectors/jms/src/jvmMain/kotlin/com/river/connector/jms/model/JmsPrimitive.kt similarity index 100% rename from connectors/jms/src/main/kotlin/com/river/connector/jms/model/JmsPrimitive.kt rename to connectors/jms/src/jvmMain/kotlin/com/river/connector/jms/model/JmsPrimitive.kt diff --git a/connectors/jms/src/main/kotlin/com/river/connector/jms/model/SessionMode.kt b/connectors/jms/src/jvmMain/kotlin/com/river/connector/jms/model/SessionMode.kt similarity index 100% rename from connectors/jms/src/main/kotlin/com/river/connector/jms/model/SessionMode.kt rename to connectors/jms/src/jvmMain/kotlin/com/river/connector/jms/model/SessionMode.kt diff --git a/connectors/jms/src/main/kotlin/com/river/connector/jms/model/Types.kt b/connectors/jms/src/jvmMain/kotlin/com/river/connector/jms/model/Types.kt similarity index 100% rename from connectors/jms/src/main/kotlin/com/river/connector/jms/model/Types.kt rename to connectors/jms/src/jvmMain/kotlin/com/river/connector/jms/model/Types.kt diff --git a/connectors/jms/src/test/kotlin/com/river/connector/jms/JmsExtKtTest.kt b/connectors/jms/src/jvmTest/kotlin/com/river/connector/jms/JmsExtKtTest.kt similarity index 100% rename from connectors/jms/src/test/kotlin/com/river/connector/jms/JmsExtKtTest.kt rename to connectors/jms/src/jvmTest/kotlin/com/river/connector/jms/JmsExtKtTest.kt diff --git a/connectors/mongodb/build.gradle.kts b/connectors/mongodb/build.gradle.kts index b4984b46..8caa6fe4 100644 --- a/connectors/mongodb/build.gradle.kts +++ b/connectors/mongodb/build.gradle.kts @@ -1,5 +1,11 @@ -dependencies { - api(libs.coroutines.reactive) - api(libs.kotlin.reflect) - api(libs.mongodb) +kotlin { + sourceSets { + jvmMain { + dependencies { + api(libs.coroutines.reactive) + api(libs.kotlin.reflect) + api(libs.mongodb) + } + } + } } diff --git a/connectors/mongodb/src/main/kotlin/com/river/connector/mongodb/MongoCollectionExt.kt b/connectors/mongodb/src/jvmMain/kotlin/com/river/connector/mongodb/MongoCollectionExt.kt similarity index 100% rename from connectors/mongodb/src/main/kotlin/com/river/connector/mongodb/MongoCollectionExt.kt rename to connectors/mongodb/src/jvmMain/kotlin/com/river/connector/mongodb/MongoCollectionExt.kt diff --git a/connectors/mongodb/src/test/kotlin/com/river/connector/mongodb/MongoCollectionExtTest.kt b/connectors/mongodb/src/jvmTest/kotlin/com/river/connector/mongodb/MongoCollectionExtTest.kt similarity index 100% rename from connectors/mongodb/src/test/kotlin/com/river/connector/mongodb/MongoCollectionExtTest.kt rename to connectors/mongodb/src/jvmTest/kotlin/com/river/connector/mongodb/MongoCollectionExtTest.kt diff --git a/connectors/openai/build.gradle.kts b/connectors/openai/build.gradle.kts index 1f88710b..d9e6ee47 100644 --- a/connectors/openai/build.gradle.kts +++ b/connectors/openai/build.gradle.kts @@ -1,5 +1,13 @@ -dependencies { - api(project.modules.http) - api(project.modules.json) - api(libs.jackson) +kotlin { + sourceSets { + jvmMain { + dependencies { + val modules = modules { project(it) } + + api(modules.http) + api(modules.json) + api(libs.jackson) + } + } + } } diff --git a/connectors/rdbms/jdbc/build.gradle.kts b/connectors/rdbms/jdbc/build.gradle.kts index 8d373604..0270280e 100644 --- a/connectors/rdbms/jdbc/build.gradle.kts +++ b/connectors/rdbms/jdbc/build.gradle.kts @@ -1,4 +1,10 @@ -dependencies { - api(libs.kotlin.reflect) - api(libs.postgresql.jdbc) +kotlin { + sourceSets { + jvmMain { + dependencies { + api(libs.kotlin.reflect) + api(libs.postgresql.jdbc) + } + } + } } diff --git a/connectors/rdbms/jdbc/src/main/kotlin/com/river/connector/rdbms/jdbc/Jdbc.kt b/connectors/rdbms/jdbc/src/jvmMain/kotlin/com/river/connector/rdbms/jdbc/Jdbc.kt similarity index 100% rename from connectors/rdbms/jdbc/src/main/kotlin/com/river/connector/rdbms/jdbc/Jdbc.kt rename to connectors/rdbms/jdbc/src/jvmMain/kotlin/com/river/connector/rdbms/jdbc/Jdbc.kt diff --git a/connectors/rdbms/jdbc/src/main/kotlin/com/river/connector/rdbms/jdbc/JdbcExt.kt b/connectors/rdbms/jdbc/src/jvmMain/kotlin/com/river/connector/rdbms/jdbc/JdbcExt.kt similarity index 100% rename from connectors/rdbms/jdbc/src/main/kotlin/com/river/connector/rdbms/jdbc/JdbcExt.kt rename to connectors/rdbms/jdbc/src/jvmMain/kotlin/com/river/connector/rdbms/jdbc/JdbcExt.kt diff --git a/connectors/rdbms/jdbc/src/test/kotlin/com/river/connector/rdbms/jdbc/JdbcTest.kt b/connectors/rdbms/jdbc/src/jvmTest/kotlin/com/river/connector/rdbms/jdbc/JdbcTest.kt similarity index 100% rename from connectors/rdbms/jdbc/src/test/kotlin/com/river/connector/rdbms/jdbc/JdbcTest.kt rename to connectors/rdbms/jdbc/src/jvmTest/kotlin/com/river/connector/rdbms/jdbc/JdbcTest.kt diff --git a/connectors/rdbms/r2dbc/build.gradle.kts b/connectors/rdbms/r2dbc/build.gradle.kts index b801e9eb..3c56b12e 100644 --- a/connectors/rdbms/r2dbc/build.gradle.kts +++ b/connectors/rdbms/r2dbc/build.gradle.kts @@ -1,5 +1,16 @@ -dependencies { - api(libs.coroutines.reactive) - api(libs.r2dbc.spi) - testImplementation(libs.r2dbc.h2) +kotlin { + sourceSets { + jvmMain { + dependencies { + api(libs.coroutines.reactive) + api(libs.r2dbc.spi) + } + } + + jvmTest { + dependencies { + api(libs.r2dbc.h2) + } + } + } } diff --git a/connectors/rdbms/r2dbc/src/main/kotlin/com/river/connector/rdbms/r2dbc/R2dbcFlowExt.kt b/connectors/rdbms/r2dbc/src/jvmMain/kotlin/com/river/connector/rdbms/r2dbc/R2dbcFlowExt.kt similarity index 100% rename from connectors/rdbms/r2dbc/src/main/kotlin/com/river/connector/rdbms/r2dbc/R2dbcFlowExt.kt rename to connectors/rdbms/r2dbc/src/jvmMain/kotlin/com/river/connector/rdbms/r2dbc/R2dbcFlowExt.kt diff --git a/connectors/rdbms/r2dbc/src/main/kotlin/com/river/connector/rdbms/r2dbc/model/Returning.kt b/connectors/rdbms/r2dbc/src/jvmMain/kotlin/com/river/connector/rdbms/r2dbc/model/Returning.kt similarity index 100% rename from connectors/rdbms/r2dbc/src/main/kotlin/com/river/connector/rdbms/r2dbc/model/Returning.kt rename to connectors/rdbms/r2dbc/src/jvmMain/kotlin/com/river/connector/rdbms/r2dbc/model/Returning.kt diff --git a/connectors/rdbms/r2dbc/src/test/kotlin/com/river/connector/rdbms/r2dbc/R2dbcFlowExtTest.kt b/connectors/rdbms/r2dbc/src/jvmTest/kotlin/com/river/connector/rdbms/r2dbc/R2dbcFlowExtTest.kt similarity index 100% rename from connectors/rdbms/r2dbc/src/test/kotlin/com/river/connector/rdbms/r2dbc/R2dbcFlowExtTest.kt rename to connectors/rdbms/r2dbc/src/jvmTest/kotlin/com/river/connector/rdbms/r2dbc/R2dbcFlowExtTest.kt diff --git a/connectors/rdbms/r2dbc/src/test/resources/h2.sql b/connectors/rdbms/r2dbc/src/jvmTest/resources/h2.sql similarity index 100% rename from connectors/rdbms/r2dbc/src/test/resources/h2.sql rename to connectors/rdbms/r2dbc/src/jvmTest/resources/h2.sql diff --git a/connectors/red-hat/debezium/build.gradle.kts b/connectors/red-hat/debezium/build.gradle.kts index c67bf2be..508a3bc4 100644 --- a/connectors/red-hat/debezium/build.gradle.kts +++ b/connectors/red-hat/debezium/build.gradle.kts @@ -1,9 +1,20 @@ -dependencies { - api(libs.debezium.api) - api(libs.debezium.embedded) +kotlin { + sourceSets { + jvmMain { + dependencies { + api(libs.debezium.api) + api(libs.debezium.embedded) + } + } - testImplementation(libs.debezium.mysql) - testImplementation(libs.mysql.jdbc) + jvmTest { + dependencies { + val modules = modules { project(it) } - testImplementation(project.modules.jdbc) + api(libs.debezium.mysql) + api(libs.mysql.jdbc) + api(modules.jdbc) + } + } + } } diff --git a/connectors/red-hat/debezium/src/main/kotlin/com/river/connector/red/hat/debezium/DebeziumExt.kt b/connectors/red-hat/debezium/src/jvmMain/kotlin/com/river/connector/red/hat/debezium/DebeziumExt.kt similarity index 100% rename from connectors/red-hat/debezium/src/main/kotlin/com/river/connector/red/hat/debezium/DebeziumExt.kt rename to connectors/red-hat/debezium/src/jvmMain/kotlin/com/river/connector/red/hat/debezium/DebeziumExt.kt diff --git a/connectors/red-hat/debezium/src/main/kotlin/com/river/connector/red/hat/debezium/internal/DebeziumChannelNotifier.kt b/connectors/red-hat/debezium/src/jvmMain/kotlin/com/river/connector/red/hat/debezium/internal/DebeziumChannelNotifier.kt similarity index 100% rename from connectors/red-hat/debezium/src/main/kotlin/com/river/connector/red/hat/debezium/internal/DebeziumChannelNotifier.kt rename to connectors/red-hat/debezium/src/jvmMain/kotlin/com/river/connector/red/hat/debezium/internal/DebeziumChannelNotifier.kt diff --git a/connectors/red-hat/debezium/src/main/kotlin/com/river/connector/red/hat/debezium/model/CommittableOffset.kt b/connectors/red-hat/debezium/src/jvmMain/kotlin/com/river/connector/red/hat/debezium/model/CommittableOffset.kt similarity index 100% rename from connectors/red-hat/debezium/src/main/kotlin/com/river/connector/red/hat/debezium/model/CommittableOffset.kt rename to connectors/red-hat/debezium/src/jvmMain/kotlin/com/river/connector/red/hat/debezium/model/CommittableOffset.kt diff --git a/connectors/red-hat/debezium/src/main/kotlin/com/river/connector/red/hat/debezium/model/CommittableRecord.kt b/connectors/red-hat/debezium/src/jvmMain/kotlin/com/river/connector/red/hat/debezium/model/CommittableRecord.kt similarity index 100% rename from connectors/red-hat/debezium/src/main/kotlin/com/river/connector/red/hat/debezium/model/CommittableRecord.kt rename to connectors/red-hat/debezium/src/jvmMain/kotlin/com/river/connector/red/hat/debezium/model/CommittableRecord.kt diff --git a/connectors/red-hat/debezium/src/test/kotlin/com/river/connector/red/hat/debezium/DebeziumExtKtTest.kt b/connectors/red-hat/debezium/src/jvmTest/kotlin/com/river/connector/red/hat/debezium/DebeziumExtKtTest.kt similarity index 100% rename from connectors/red-hat/debezium/src/test/kotlin/com/river/connector/red/hat/debezium/DebeziumExtKtTest.kt rename to connectors/red-hat/debezium/src/jvmTest/kotlin/com/river/connector/red/hat/debezium/DebeziumExtKtTest.kt diff --git a/connectors/redis/build.gradle.kts b/connectors/redis/build.gradle.kts index e04f7a92..fe3ba637 100644 --- a/connectors/redis/build.gradle.kts +++ b/connectors/redis/build.gradle.kts @@ -1,3 +1,9 @@ -dependencies { - api(libs.redisson) +kotlin { + sourceSets { + commonMain { + dependencies { + api(libs.redisson) + } + } + } } diff --git a/connectors/redis/src/main/kotlin/com/river/connector/redis/RedissonClientExt.kt b/connectors/redis/src/jvmMain/kotlin/com/river/connector/redis/RedissonClientExt.kt similarity index 100% rename from connectors/redis/src/main/kotlin/com/river/connector/redis/RedissonClientExt.kt rename to connectors/redis/src/jvmMain/kotlin/com/river/connector/redis/RedissonClientExt.kt diff --git a/connectors/redis/src/main/kotlin/com/river/connector/redis/internal/RedisAsyncSemaphore.kt b/connectors/redis/src/jvmMain/kotlin/com/river/connector/redis/internal/RedisAsyncSemaphore.kt similarity index 100% rename from connectors/redis/src/main/kotlin/com/river/connector/redis/internal/RedisAsyncSemaphore.kt rename to connectors/redis/src/jvmMain/kotlin/com/river/connector/redis/internal/RedisAsyncSemaphore.kt diff --git a/connectors/redis/src/test/kotlin/com/river/connector/redis/RedissonClientExtKtTest.kt b/connectors/redis/src/jvmTest/kotlin/com/river/connector/redis/RedissonClientExtKtTest.kt similarity index 100% rename from connectors/redis/src/test/kotlin/com/river/connector/redis/RedissonClientExtKtTest.kt rename to connectors/redis/src/jvmTest/kotlin/com/river/connector/redis/RedissonClientExtKtTest.kt diff --git a/core/build.gradle.kts b/core/build.gradle.kts index e69de29b..8e3357b1 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -0,0 +1,21 @@ +plugins { + alias(libs.plugins.android) +} + +kotlin { + linuxX64() + macosArm64() + macosX64() + + js(IR) { + browser() + nodejs() + } + + androidTarget() +// publishLibraryVariants("release", "debug") + + iosX64() + iosArm64() +} + diff --git a/core/src/main/kotlin/com/river/core/AsyncSemaphore.kt b/core/src/commonMain/kotlin/com/river/core/AsyncSemaphore.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/AsyncSemaphore.kt rename to core/src/commonMain/kotlin/com/river/core/AsyncSemaphore.kt diff --git a/core/src/main/kotlin/com/river/core/ChannelExt.kt b/core/src/commonMain/kotlin/com/river/core/ChannelExt.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/ChannelExt.kt rename to core/src/commonMain/kotlin/com/river/core/ChannelExt.kt diff --git a/core/src/main/kotlin/com/river/core/ChannelReceiverContext.kt b/core/src/commonMain/kotlin/com/river/core/ChannelReceiverContext.kt similarity index 88% rename from core/src/main/kotlin/com/river/core/ChannelReceiverContext.kt rename to core/src/commonMain/kotlin/com/river/core/ChannelReceiverContext.kt index 8f260b9e..b1914a3c 100644 --- a/core/src/main/kotlin/com/river/core/ChannelReceiverContext.kt +++ b/core/src/commonMain/kotlin/com/river/core/ChannelReceiverContext.kt @@ -3,6 +3,7 @@ package com.river.core import com.river.core.internal.InternalChannelReceiverContext import kotlinx.coroutines.channels.Channel +import kotlinx.coroutines.withTimeoutOrNull import kotlin.time.Duration /** @@ -36,6 +37,14 @@ interface ChannelReceiverContext { */ suspend fun next(): E + /** + * Awaits for the next item from the channel, or null if the timeout is reached. + * + * @return The next item from the channel, or null. + */ + suspend fun next(timeout: Duration): E? = + withTimeoutOrNull(timeout) { next() } + /** * Awaits for the next N items from the channel. This method will suspend indefinitely until N items are received. * diff --git a/core/src/main/kotlin/com/river/core/ConcurrencyInfo.kt b/core/src/commonMain/kotlin/com/river/core/ConcurrencyInfo.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/ConcurrencyInfo.kt rename to core/src/commonMain/kotlin/com/river/core/ConcurrencyInfo.kt diff --git a/core/src/main/kotlin/com/river/core/ExperimentalRiverApi.kt b/core/src/commonMain/kotlin/com/river/core/ExperimentalRiverApi.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/ExperimentalRiverApi.kt rename to core/src/commonMain/kotlin/com/river/core/ExperimentalRiverApi.kt diff --git a/core/src/main/kotlin/com/river/core/FlowAsyncExt.kt b/core/src/commonMain/kotlin/com/river/core/FlowAsyncExt.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/FlowAsyncExt.kt rename to core/src/commonMain/kotlin/com/river/core/FlowAsyncExt.kt diff --git a/core/src/main/kotlin/com/river/core/FlowByteArrayExt.kt b/core/src/commonMain/kotlin/com/river/core/FlowByteArrayExt.kt similarity index 81% rename from core/src/main/kotlin/com/river/core/FlowByteArrayExt.kt rename to core/src/commonMain/kotlin/com/river/core/FlowByteArrayExt.kt index e3d83069..5422aeee 100644 --- a/core/src/main/kotlin/com/river/core/FlowByteArrayExt.kt +++ b/core/src/commonMain/kotlin/com/river/core/FlowByteArrayExt.kt @@ -3,14 +3,14 @@ package com.river.core import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map -import java.nio.ByteBuffer +//import java.nio.ByteBuffer /** * Converts the [Flow] of [ByteArray] to a [Flow] of [ByteBuffer]. * * @return A new [Flow] of [ByteBuffer] converted from the original [Flow] of [ByteArray]. */ -fun Flow.asByteBuffer(): Flow = map { ByteBuffer.wrap(it) } +//fun Flow.asByteBuffer(): Flow = map { ByteBuffer.wrap(it) } /** * Converts the [Flow] of [ByteArray] to a [Flow] of [String]. diff --git a/core/src/commonMain/kotlin/com/river/core/FlowByteBufferExt.kt b/core/src/commonMain/kotlin/com/river/core/FlowByteBufferExt.kt new file mode 100644 index 00000000..363f6f37 --- /dev/null +++ b/core/src/commonMain/kotlin/com/river/core/FlowByteBufferExt.kt @@ -0,0 +1,19 @@ +package com.river.core + +//import java.nio.ByteBuffer +// +///** +// * Converts the [Flow] of [ByteBuffer] to a [Flow] of [ByteArray]. +// * +// * @return A new [Flow] of [ByteArray] converted from the original [Flow] of [ByteBuffer]. +// */ +//fun Flow.asByteArray(): Flow = +// map { bb -> ByteArray(bb.remaining()).also { bb.get(it) } } +// +///** +// * Flattens a [Flow] of [List] of [ByteBuffer] and converts it to a [Flow] of [ByteArray]. +// * +// * @return A new [Flow] of [ByteArray] converted and flattened from the original [Flow] of [List] of [ByteBuffer]. +// */ +//fun Flow>.flattenAsByteArray(): Flow = +// flattenIterable().asByteArray() diff --git a/core/src/main/kotlin/com/river/core/FlowByteExt.kt b/core/src/commonMain/kotlin/com/river/core/FlowByteExt.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/FlowByteExt.kt rename to core/src/commonMain/kotlin/com/river/core/FlowByteExt.kt diff --git a/core/src/main/kotlin/com/river/core/FlowDoubleExt.kt b/core/src/commonMain/kotlin/com/river/core/FlowDoubleExt.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/FlowDoubleExt.kt rename to core/src/commonMain/kotlin/com/river/core/FlowDoubleExt.kt diff --git a/core/src/main/kotlin/com/river/core/FlowExt.kt b/core/src/commonMain/kotlin/com/river/core/FlowExt.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/FlowExt.kt rename to core/src/commonMain/kotlin/com/river/core/FlowExt.kt diff --git a/core/src/main/kotlin/com/river/core/FlowFloatExt.kt b/core/src/commonMain/kotlin/com/river/core/FlowFloatExt.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/FlowFloatExt.kt rename to core/src/commonMain/kotlin/com/river/core/FlowFloatExt.kt diff --git a/core/src/main/kotlin/com/river/core/FlowIntExt.kt b/core/src/commonMain/kotlin/com/river/core/FlowIntExt.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/FlowIntExt.kt rename to core/src/commonMain/kotlin/com/river/core/FlowIntExt.kt diff --git a/core/src/main/kotlin/com/river/core/FlowLongExt.kt b/core/src/commonMain/kotlin/com/river/core/FlowLongExt.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/FlowLongExt.kt rename to core/src/commonMain/kotlin/com/river/core/FlowLongExt.kt diff --git a/core/src/main/kotlin/com/river/core/FlowShortExt.kt b/core/src/commonMain/kotlin/com/river/core/FlowShortExt.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/FlowShortExt.kt rename to core/src/commonMain/kotlin/com/river/core/FlowShortExt.kt diff --git a/core/src/main/kotlin/com/river/core/FlowStringExt.kt b/core/src/commonMain/kotlin/com/river/core/FlowStringExt.kt similarity index 60% rename from core/src/main/kotlin/com/river/core/FlowStringExt.kt rename to core/src/commonMain/kotlin/com/river/core/FlowStringExt.kt index 317dda15..ac66c639 100644 --- a/core/src/main/kotlin/com/river/core/FlowStringExt.kt +++ b/core/src/commonMain/kotlin/com/river/core/FlowStringExt.kt @@ -2,10 +2,10 @@ package com.river.core import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow -import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.onCompletion -import java.nio.ByteBuffer -import java.nio.charset.Charset + +//import java.nio.ByteBuffer +//import java.nio.charset.Charset /** * Splits and buffers the [Flow] of [String] based on the provided delimiter, emitting each piece as a separate element in the resulting [Flow]. @@ -78,38 +78,38 @@ fun Flow.splitEvery( * ``` */ fun Flow.lines() = splitEvery("\n") - -/** - * Converts the [Flow] of [String] to a [Flow] of [Byte] using the specified [charset]. - * - * @param charset The [Charset] to use for converting the strings to bytes. Defaults to the system's default charset. - * - * @return A new [Flow] of [Byte] converted from the original [Flow] of [String]. - */ -fun Flow.asBytes( - charset: Charset = Charset.defaultCharset() -) = asByteArray(charset) - .map { it.toList() } - .flattenIterable() - -/** - * Converts the [Flow] of [String] to a [Flow] of [ByteArray] using the specified [charset]. - * - * @param charset The [Charset] to use for converting the strings to byte arrays. Defaults to the system's default charset. - * - * @return A new [Flow] of [ByteArray] converted from the original [Flow] of [String]. - */ -fun Flow.asByteArray( - charset: Charset = Charset.defaultCharset() -): Flow = map { it.toByteArray(charset) } - -/** - * Converts the [Flow] of [String] to a [Flow] of [ByteBuffer] using the specified [charset]. - * - * @param charset The [Charset] to use for converting the strings to byte buffers. Defaults to the system's default charset. - * - * @return A new [Flow] of [ByteBuffer] converted from the original [Flow] of [String]. - */ -fun Flow.asByteBuffer( - charset: Charset = Charset.defaultCharset() -): Flow = map { ByteBuffer.wrap(it.toByteArray(charset)) } +// +///** +// * Converts the [Flow] of [String] to a [Flow] of [Byte] using the specified [charset]. +// * +// * @param charset The [Charset] to use for converting the strings to bytes. Defaults to the system's default charset. +// * +// * @return A new [Flow] of [Byte] converted from the original [Flow] of [String]. +// */ +//fun Flow.asBytes( +// charset: Charset = Charset.defaultCharset() +//) = asByteArray(charset) +// .map { it.toList() } +// .flattenIterable() +// +///** +// * Converts the [Flow] of [String] to a [Flow] of [ByteArray] using the specified [charset]. +// * +// * @param charset The [Charset] to use for converting the strings to byte arrays. Defaults to the system's default charset. +// * +// * @return A new [Flow] of [ByteArray] converted from the original [Flow] of [String]. +// */ +//fun Flow.asByteArray( +// charset: Charset = Charset.defaultCharset() +//): Flow = map { it.toByteArray(charset) } +// +///** +// * Converts the [Flow] of [String] to a [Flow] of [ByteBuffer] using the specified [charset]. +// * +// * @param charset The [Charset] to use for converting the strings to byte buffers. Defaults to the system's default charset. +// * +// * @return A new [Flow] of [ByteBuffer] converted from the original [Flow] of [String]. +// */ +//fun Flow.asByteBuffer( +// charset: Charset = Charset.defaultCharset() +//): Flow = map { ByteBuffer.wrap(it.toByteArray(charset)) } diff --git a/core/src/main/kotlin/com/river/core/GroupExt.kt b/core/src/commonMain/kotlin/com/river/core/GroupExt.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/GroupExt.kt rename to core/src/commonMain/kotlin/com/river/core/GroupExt.kt diff --git a/core/src/main/kotlin/com/river/core/GroupStrategy.kt b/core/src/commonMain/kotlin/com/river/core/GroupStrategy.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/GroupStrategy.kt rename to core/src/commonMain/kotlin/com/river/core/GroupStrategy.kt diff --git a/core/src/main/kotlin/com/river/core/IntersperseExt.kt b/core/src/commonMain/kotlin/com/river/core/IntersperseExt.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/IntersperseExt.kt rename to core/src/commonMain/kotlin/com/river/core/IntersperseExt.kt diff --git a/core/src/main/kotlin/com/river/core/IterableAsyncExt.kt b/core/src/commonMain/kotlin/com/river/core/IterableAsyncExt.kt similarity index 98% rename from core/src/main/kotlin/com/river/core/IterableAsyncExt.kt rename to core/src/commonMain/kotlin/com/river/core/IterableAsyncExt.kt index eab9eec8..da0410b8 100644 --- a/core/src/main/kotlin/com/river/core/IterableAsyncExt.kt +++ b/core/src/commonMain/kotlin/com/river/core/IterableAsyncExt.kt @@ -18,7 +18,7 @@ import kotlinx.coroutines.flow.toList */ @ExperimentalRiverApi infix fun List>.completeAll(values: List): Boolean = - assert(size == values.size) { "Promises & values sizes must match" } + check(size == values.size) { "Promises & values sizes must match" } .let { (this zip values) .map { (promise, value) -> promise.complete(value) } diff --git a/core/src/main/kotlin/com/river/core/ObjectPool.kt b/core/src/commonMain/kotlin/com/river/core/ObjectPool.kt similarity index 86% rename from core/src/main/kotlin/com/river/core/ObjectPool.kt rename to core/src/commonMain/kotlin/com/river/core/ObjectPool.kt index dea7f6c6..691569c5 100644 --- a/core/src/main/kotlin/com/river/core/ObjectPool.kt +++ b/core/src/commonMain/kotlin/com/river/core/ObjectPool.kt @@ -1,19 +1,20 @@ package com.river.core import com.river.core.internal.DefaultObjectPool -import java.time.ZonedDateTime + +import kotlinx.datetime.Clock +import kotlinx.datetime.Instant import kotlin.time.Duration import kotlin.time.Duration.Companion.minutes -import kotlin.time.toJavaDuration interface ObjectPool { class ObjectHolder( val instance: T, val maxDuration: Duration, - val createdAt: ZonedDateTime + val createdAt: Instant = Clock.System.now() ) { fun shouldBeClosed(): Boolean = - ZonedDateTime.now() >= createdAt.plus(maxDuration.toJavaDuration()) + Clock.System.now() >= (createdAt + maxDuration) } suspend fun borrow(): ObjectHolder diff --git a/core/src/main/kotlin/com/river/core/ParallelismIncreaseStrategy.kt b/core/src/commonMain/kotlin/com/river/core/ParallelismIncreaseStrategy.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/ParallelismIncreaseStrategy.kt rename to core/src/commonMain/kotlin/com/river/core/ParallelismIncreaseStrategy.kt diff --git a/core/src/main/kotlin/com/river/core/PollExt.kt b/core/src/commonMain/kotlin/com/river/core/PollExt.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/PollExt.kt rename to core/src/commonMain/kotlin/com/river/core/PollExt.kt diff --git a/core/src/main/kotlin/com/river/core/PromiseExt.kt b/core/src/commonMain/kotlin/com/river/core/PromiseExt.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/PromiseExt.kt rename to core/src/commonMain/kotlin/com/river/core/PromiseExt.kt diff --git a/core/src/main/kotlin/com/river/core/RiverPreview.kt b/core/src/commonMain/kotlin/com/river/core/RiverPreview.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/RiverPreview.kt rename to core/src/commonMain/kotlin/com/river/core/RiverPreview.kt diff --git a/core/src/main/kotlin/com/river/core/SchedulerExt.kt b/core/src/commonMain/kotlin/com/river/core/SchedulerExt.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/SchedulerExt.kt rename to core/src/commonMain/kotlin/com/river/core/SchedulerExt.kt diff --git a/core/src/main/kotlin/com/river/core/StoppableFlowCollector.kt b/core/src/commonMain/kotlin/com/river/core/StoppableFlowCollector.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/StoppableFlowCollector.kt rename to core/src/commonMain/kotlin/com/river/core/StoppableFlowCollector.kt diff --git a/core/src/main/kotlin/com/river/core/StoppableFlowExt.kt b/core/src/commonMain/kotlin/com/river/core/StoppableFlowExt.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/StoppableFlowExt.kt rename to core/src/commonMain/kotlin/com/river/core/StoppableFlowExt.kt diff --git a/core/src/main/kotlin/com/river/core/SuspendExt.kt b/core/src/commonMain/kotlin/com/river/core/SuspendExt.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/SuspendExt.kt rename to core/src/commonMain/kotlin/com/river/core/SuspendExt.kt diff --git a/core/src/main/kotlin/com/river/core/ThrottleExt.kt b/core/src/commonMain/kotlin/com/river/core/ThrottleExt.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/ThrottleExt.kt rename to core/src/commonMain/kotlin/com/river/core/ThrottleExt.kt diff --git a/core/src/main/kotlin/com/river/core/ThrottleStrategy.kt b/core/src/commonMain/kotlin/com/river/core/ThrottleStrategy.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/ThrottleStrategy.kt rename to core/src/commonMain/kotlin/com/river/core/ThrottleStrategy.kt diff --git a/core/src/commonMain/kotlin/com/river/core/internal/DefaultAsyncSemaphore.kt b/core/src/commonMain/kotlin/com/river/core/internal/DefaultAsyncSemaphore.kt new file mode 100644 index 00000000..612ecc2f --- /dev/null +++ b/core/src/commonMain/kotlin/com/river/core/internal/DefaultAsyncSemaphore.kt @@ -0,0 +1,87 @@ +package com.river.core.internal + +import com.river.core.AsyncSemaphore +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Job +import kotlinx.coroutines.delay +import kotlinx.coroutines.launch +import kotlinx.coroutines.sync.Mutex +import kotlinx.coroutines.sync.Semaphore +import kotlinx.coroutines.sync.withLock +import kotlin.time.Duration + +/** + * The default implementation of the [AsyncSemaphore] interface. + * This class uses the [Semaphore] from kotlinx.coroutines.sync package to manage the permits. + */ +internal class DefaultAsyncSemaphore( + private val scope: CoroutineScope, + override val totalPermits: Int, + private val leaseTime: Duration? = null, +) : AsyncSemaphore { + private val mutex = Mutex() + private val internal = Semaphore(totalPermits) + + private val availablePermits: ArrayDeque = + ArrayDeque((0 until totalPermits).toList()) + + private val permits: Array = + (0 until totalPermits) + .map { PermitState.Available } + .toTypedArray() + + sealed interface PermitState { + class Acquired(val timeout: Job?) : PermitState + data object Available : PermitState + } + + override suspend fun available(): Int = + internal.availablePermits + + override suspend fun acquire(): Int { + internal.acquire() + return internalAcquire() + } + + override suspend fun tryAcquire(): Int? { + if (!internal.tryAcquire()) { + return null + } + + return internalAcquire() + } + + override suspend fun release(permit: Int) { + when (val state = permits[permit]) { + is PermitState.Acquired -> { + state.timeout?.cancel() + + mutex.withLock { + permits[permit] = PermitState.Available + availablePermits.addLast(permit) + } + + internal.release() + } + + PermitState.Available -> { + } + } + } + + override suspend fun releaseAll() = + permits.forEachIndexed { index, _ -> release(index) } + + private suspend fun internalAcquire(): Int { + val permit = mutex.withLock { availablePermits.removeFirst() } + + permits[permit] = PermitState.Acquired(leaseTime?.let { + scope.launch { + delay(leaseTime) + release(permit) + } + }) + + return permit + } +} diff --git a/core/src/main/kotlin/com/river/core/internal/DefaultObjectPool.kt b/core/src/commonMain/kotlin/com/river/core/internal/DefaultObjectPool.kt similarity index 93% rename from core/src/main/kotlin/com/river/core/internal/DefaultObjectPool.kt rename to core/src/commonMain/kotlin/com/river/core/internal/DefaultObjectPool.kt index b3e4bcbf..aa5080a2 100644 --- a/core/src/main/kotlin/com/river/core/internal/DefaultObjectPool.kt +++ b/core/src/commonMain/kotlin/com/river/core/internal/DefaultObjectPool.kt @@ -4,7 +4,6 @@ import com.river.core.ObjectPool import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock -import java.time.ZonedDateTime.now import kotlin.time.Duration internal class DefaultObjectPool( @@ -20,7 +19,7 @@ internal class DefaultObjectPool( private val channel = Channel>(size) init { - initial.forEach { channel.trySend(ObjectPool.ObjectHolder(it, maxDuration, now())) } + initial.forEach { channel.trySend(ObjectPool.ObjectHolder(it, maxDuration)) } created = initial.size } @@ -68,5 +67,5 @@ internal class DefaultObjectPool( } private suspend fun new(): ObjectPool.ObjectHolder = - ObjectPool.ObjectHolder(factory(), maxDuration, now()) + ObjectPool.ObjectHolder(factory(), maxDuration) } diff --git a/core/src/main/kotlin/com/river/core/internal/InternalChannelReceiverContext.kt b/core/src/commonMain/kotlin/com/river/core/internal/InternalChannelReceiverContext.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/internal/InternalChannelReceiverContext.kt rename to core/src/commonMain/kotlin/com/river/core/internal/InternalChannelReceiverContext.kt diff --git a/core/src/main/kotlin/com/river/core/internal/MapAsyncFlow.kt b/core/src/commonMain/kotlin/com/river/core/internal/MapAsyncFlow.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/internal/MapAsyncFlow.kt rename to core/src/commonMain/kotlin/com/river/core/internal/MapAsyncFlow.kt diff --git a/core/src/main/kotlin/com/river/core/internal/MutexBasedWindowedChunk.kt b/core/src/commonMain/kotlin/com/river/core/internal/MutexBasedWindowedChunk.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/internal/MutexBasedWindowedChunk.kt rename to core/src/commonMain/kotlin/com/river/core/internal/MutexBasedWindowedChunk.kt diff --git a/core/src/main/kotlin/com/river/core/internal/PollingFlow.kt b/core/src/commonMain/kotlin/com/river/core/internal/PollingFlow.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/internal/PollingFlow.kt rename to core/src/commonMain/kotlin/com/river/core/internal/PollingFlow.kt diff --git a/core/src/main/kotlin/com/river/core/internal/SplitFlow.kt b/core/src/commonMain/kotlin/com/river/core/internal/SplitFlow.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/internal/SplitFlow.kt rename to core/src/commonMain/kotlin/com/river/core/internal/SplitFlow.kt diff --git a/core/src/main/kotlin/com/river/core/internal/StopableFlow.kt b/core/src/commonMain/kotlin/com/river/core/internal/StopableFlow.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/internal/StopableFlow.kt rename to core/src/commonMain/kotlin/com/river/core/internal/StopableFlow.kt diff --git a/core/src/main/kotlin/com/river/core/internal/ThrottleFlow.kt b/core/src/commonMain/kotlin/com/river/core/internal/ThrottleFlow.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/internal/ThrottleFlow.kt rename to core/src/commonMain/kotlin/com/river/core/internal/ThrottleFlow.kt diff --git a/core/src/main/kotlin/com/river/core/internal/UnorderedMapAsyncFlow.kt b/core/src/commonMain/kotlin/com/river/core/internal/UnorderedMapAsyncFlow.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/internal/UnorderedMapAsyncFlow.kt rename to core/src/commonMain/kotlin/com/river/core/internal/UnorderedMapAsyncFlow.kt diff --git a/core/src/test/kotlin/com/river/core/FlowAsyncExtKtTest.kt b/core/src/commonTest/kotlin/com/river/core/FlowAsyncExtKtTest.kt similarity index 71% rename from core/src/test/kotlin/com/river/core/FlowAsyncExtKtTest.kt rename to core/src/commonTest/kotlin/com/river/core/FlowAsyncExtKtTest.kt index 6e35ddfc..27849cca 100644 --- a/core/src/test/kotlin/com/river/core/FlowAsyncExtKtTest.kt +++ b/core/src/commonTest/kotlin/com/river/core/FlowAsyncExtKtTest.kt @@ -1,17 +1,22 @@ package com.river.core import app.cash.turbine.test +import io.kotest.assertions.assertSoftly +import io.kotest.assertions.retry import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.collections.shouldContainInOrder +import io.kotest.matchers.comparables.shouldBeGreaterThan import io.kotest.matchers.comparables.shouldBeLessThanOrEqualTo import io.kotest.matchers.comparables.shouldNotBeGreaterThan import io.kotest.matchers.shouldBe +import io.kotest.mpp.atomics.AtomicReference import kotlinx.coroutines.delay import kotlinx.coroutines.flow.asFlow import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.toList import kotlin.time.Duration import kotlin.time.Duration.Companion.milliseconds +import kotlin.time.Duration.Companion.seconds import kotlin.time.measureTime import kotlin.time.measureTimedValue @@ -32,36 +37,47 @@ class FlowAsyncExtKtTest : FunSpec({ } test("mapAsync should respect order & concurrency limit") { - val sourceFlow = (1..100).asFlow() + val sourceFlow = + (1..100) + .asFlow() + .mapAsync(10) { + delay(500) + it * 2 + } - var counter = 0 + retry(5, 20.seconds) { + val counter = AtomicReference(0) - sourceFlow - .mapAsync(2) { - delay(100) - it * 2 - } - .test { - (1..50) - .forEach { _ -> - suspend fun ensureNext(): Duration { - counter++ - val (item, duration) = measureTimedValue { awaitItem() } - item shouldBe counter * 2 - return duration + sourceFlow + .test { + (1..10) + .forEach { _ -> + suspend fun ensureNext(): Duration { + counter.increment() + val (item, duration) = measureTimedValue { awaitItem() } + item shouldBe counter.value * 2 + return duration + } + + // Measure the time taken to receive two items + measureTime { + // First item should be received in >= 500 ms & <= 520 ms + assertSoftly(ensureNext()) { duration -> + duration shouldBeGreaterThan 480.milliseconds + duration shouldBeLessThanOrEqualTo 520.milliseconds + } + + repeat(9) { + // The other 9 items should be almost immediate + ensureNext() shouldNotBeGreaterThan 6.milliseconds + } + + } shouldBeLessThanOrEqualTo 550.milliseconds } - // Measure the time taken to receive two items - measureTime { - // First item should be received in <= 120 ms - ensureNext() shouldBeLessThanOrEqualTo 120.milliseconds - // Second item should be almost immediate - ensureNext() shouldNotBeGreaterThan 10.milliseconds - } shouldBeLessThanOrEqualTo 130.milliseconds // Total time for both items should be <= 130 ms - } - - awaitComplete() - } + awaitComplete() + } + } } test("unorderedMapAsync should correctly transform each element") { @@ -95,10 +111,8 @@ class FlowAsyncExtKtTest : FunSpec({ } test("flatMapIterableAsync should correctly transform and flatten each element") { - // Create a flow of integers val sourceFlow = flowOf(1, 2, 3) - // Apply the flatMapIterableAsync extension function with a concurrency limit val result = sourceFlow .flatMapIterableAsync(2) { value -> delay(50 * value.toLong()) // Delay to simulate asynchronous processing @@ -108,7 +122,6 @@ class FlowAsyncExtKtTest : FunSpec({ // The expected result is a flattened list of transformed items // Since the flow is ordered, despite the concurrency, the order of elements is maintained - // Output should be: [1, 2, 2, 3, 3, 4] result shouldContainInOrder listOf(1, 2, 2, 3, 3, 4) } diff --git a/core/src/commonTest/kotlin/com/river/core/FlowExtKtTest.kt b/core/src/commonTest/kotlin/com/river/core/FlowExtKtTest.kt new file mode 100644 index 00000000..5eb63963 --- /dev/null +++ b/core/src/commonTest/kotlin/com/river/core/FlowExtKtTest.kt @@ -0,0 +1,132 @@ +@file:OptIn(ExperimentalTime::class, ExperimentalCoroutinesApi::class, ExperimentalRiverApi::class) + +package com.river.core + +import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.collections.shouldContainInOrder +import io.kotest.matchers.collections.shouldNotContainAll +import io.kotest.matchers.result.shouldBeFailure +import io.kotest.matchers.shouldBe +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.delay +import kotlinx.coroutines.flow.* +import kotlin.time.Duration.Companion.milliseconds +import kotlin.time.Duration.Companion.seconds +import kotlin.time.ExperimentalTime +import kotlin.time.measureTimedValue + +class FlowExtKtTest : FunSpec({ + val infiniteFlow = poll { listOf("hello!") } + + test("Assert that using cancel() is working properly and the flow no longer emits new values") { + val stoppableFlow = + stoppableFlow { + var counter = 0 + + infiniteFlow + .collect { + emit(++counter) + if (counter == 1000) halt("counter reached the maximum count") + } + } + + stoppableFlow.count() shouldBe 1000 + } + + test("Assert that using other exceptions will make any collecting throw the error") { + val stoppableFlow = + stoppableFlow { + var counter = 0 + + infiniteFlow + .collect { + emit(++counter) + if (counter == 1000) error("ups, you should use `cancel` instead") + } + } + + runCatching { stoppableFlow.collect() } shouldBeFailure { + it.message shouldBe "ups, you should use `cancel` instead" + } + } + + test("should transform the flow into a stoppable & complete it after the predicate returns true") { + val maybePrimes = flowOf(2, 4, 6, 8, 10, 12, 13, 14, 16) + + maybePrimes + .earlyCompleteIf { it % 2 != 0 } + .toList() + .toList() shouldBe listOf(2, 4, 6, 8, 10, 12) + } + + test("should transform the flow into a list") { + flowOf(2, 4, 6, 8, 10, 12, 14, 16) + .toList() shouldBe listOf(2, 4, 6, 8, 10, 12, 14, 16) + } + + test("should transform the flow into a list based on the count") { + flowOf(2, 4, 6, 8, 10, 12, 14, 16) + .toList(3) shouldBe listOf(2, 4, 6) + } + + test("should transform the flow into a list based on the time window") { + flowOf(2, 4, 6, 8, 10, 12, 14, 16) + .onEach { delay(190) } + .toList(10, 600.milliseconds) shouldBe listOf(2, 4, 6) + } + + test("should chunk the items based on the count") { + flowOf(2, 4, 6, 8, 10, 12, 14, 16, 18, 20) + .chunked(10) + .toList() shouldBe listOf(listOf(2, 4, 6, 8, 10, 12, 14, 16, 18, 20)) + } + + test("should chunk the items based on the time window") { + flowOf(2, 4, 6, 8, 10, 12, 14, 16, 18, 20) + .onEach { delay(250.milliseconds) } + .chunked(10, 400.milliseconds) + .toList() shouldBe listOf(listOf(2, 4), listOf(6, 8), listOf(10, 12), listOf(14, 16), listOf(18, 20)) + } + + test("Should transform the Flow> into a Flow") { + val flowOfList = flowOf(listOf(2, 4), listOf(6, 8), listOf(10, 12), listOf(14, 16), listOf(18, 20)) + val flattenedFlow = flowOfList.flattenIterable() + flattenedFlow.toList() shouldBe listOf(2, 4, 6, 8, 10, 12, 14, 16, 18, 20) + } + + test("Should allow a concurrency for item processing within the flow") { + val (_, duration) = measureTimedValue { + flowOf(2, 4, 6, 8, 10, 12, 14, 16, 18, 20) + .mapAsync(5) { delay(500.milliseconds) } + .collect() + } + + duration.inWholeSeconds shouldBe 1 + } + + val flow = + (1..20) + .asFlow() + + test("Should suspend after the defined number of elements per time window is reached") { + val (result, duration) = measureTimedValue { flow.throttle(10, 2.seconds).toList() } + + duration.inWholeSeconds shouldBe 4 + result shouldContainInOrder (1..20).toList() + } + + test("Should drop if specified after the defined number of elements per time window is reached") { + val (result, duration) = measureTimedValue { + flow + .throttle( + elementsPerInterval = 10, + interval = 2.seconds, + strategy = ThrottleStrategy.Drop + ) + .toList() + } + + duration.inWholeSeconds shouldBe 2 + result shouldNotContainAll (0..20).toList() + } +}) diff --git a/core/src/commonTest/kotlin/com/river/core/FlowNumberExtKtTest.kt b/core/src/commonTest/kotlin/com/river/core/FlowNumberExtKtTest.kt new file mode 100644 index 00000000..fde468e1 --- /dev/null +++ b/core/src/commonTest/kotlin/com/river/core/FlowNumberExtKtTest.kt @@ -0,0 +1,21 @@ +package com.river.core + +import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.shouldBe +import kotlinx.coroutines.flow.asFlow +import kotlinx.coroutines.flow.map + +class FlowNumberExtKtTest : FunSpec({ + val oneMillionFlow = (1..1000000).asFlow() + + test("Flow.sum()") { + oneMillionFlow + .sum() shouldBe 500000500000 + } + + test("Flow.sum()") { + oneMillionFlow + .map { it.toLong() } + .sum() shouldBe 500000500000 + } +}) diff --git a/core/src/commonTest/kotlin/com/river/core/PollExtTest.kt b/core/src/commonTest/kotlin/com/river/core/PollExtTest.kt new file mode 100644 index 00000000..32a0923a --- /dev/null +++ b/core/src/commonTest/kotlin/com/river/core/PollExtTest.kt @@ -0,0 +1,100 @@ +@file:OptIn(ExperimentalCoroutinesApi::class, ExperimentalRiverApi::class) + +package com.river.core + +import com.river.core.ConcurrencyStrategy.Companion.increaseByOne +import com.river.core.ConcurrencyStrategy.Companion.maximumAllowedAfterFirstIteration +import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.collections.shouldContainInOrder +import io.kotest.matchers.shouldBe +import io.kotest.mpp.atomics.AtomicReference +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.take +import kotlinx.coroutines.flow.toList + +class PollExtTest : FunSpec({ + test("building a simple non-stopping flow") { + val counter = AtomicReference(0) + val count = 100 + + val flow = counterBasedFlow(counter) + val list = flow.take(count).toList() + + list shouldContainInOrder (1..count).toList() + counter.value shouldBe count + } + + test("building a parallelized non-stopping flow") { + val count = 1000 + val counter = AtomicReference(0) + + val flow = poll(increaseByOne(5)) { listOf(counter.increment()) } + val list = flow.take(count).toList() + + list shouldContainInOrder (1..count).toList() + counter.value shouldBe count + } + + test("building a parallelized repeat flow that stops on empty lists") { + val count = 1000 + val counter = AtomicReference(0) + + val flow = poll(increaseByOne(5), stopOnEmptyList = true) { + if (counter.value == count) emptyList() + else listOf(counter.increment()) + } + + val list = flow.toList() + + list shouldContainInOrder (1..count).toList() + counter.value shouldBe count + } + + test("asserting the increase strategy is working properly") { + val counter = AtomicReference(0) + val maxConcurrency = 10 + + val gap = ((100..120) + (250..270) + (850..980)) + val changedConcurrency = AtomicReference(1 to 0) + + val flow = + poll(maximumAllowedAfterFirstIteration(maxConcurrency)) { + val c = counter.increment() + + val (last, count) = changedConcurrency.value + + if (last != current) { + changedConcurrency.value = current to count + 1 + } + + if (c in gap) emptyList() + else listOf(c) + } + + val list = flow.earlyCompleteIf { it > 1000 }.toList() + + val expected = ((1..1000) - gap).toList() + list shouldBe expected + changedConcurrency.value shouldBe (10 to 7) + } + + test("building an arithmetic series flow") { + val count = 100 + + val flow = pollWithState(1, { it > count }) { state -> + (state + 1) to (0..state).toList() + } + + flow.sum() shouldBe 171700 + } +}) + +fun AtomicReference.increment(): Int { + val new = value + 1 + check(compareAndSet(value, new)) + return value +} + +fun counterBasedFlow(counter: AtomicReference): Flow = + poll { listOf(counter.increment()) } \ No newline at end of file diff --git a/core/src/main/kotlin/com/river/core/FlowByteBufferExt.kt b/core/src/jvmMain/kotlin/com/river/core/FlowByteBufferExt.kt similarity index 100% rename from core/src/main/kotlin/com/river/core/FlowByteBufferExt.kt rename to core/src/jvmMain/kotlin/com/river/core/FlowByteBufferExt.kt diff --git a/core/src/jvmMain/kotlin/com/river/core/FlowStringJvmExt.kt b/core/src/jvmMain/kotlin/com/river/core/FlowStringJvmExt.kt new file mode 100644 index 00000000..39219702 --- /dev/null +++ b/core/src/jvmMain/kotlin/com/river/core/FlowStringJvmExt.kt @@ -0,0 +1,42 @@ +package com.river.core + +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.map + +import java.nio.ByteBuffer +import java.nio.charset.Charset + +/** + * Converts the [Flow] of [String] to a [Flow] of [Byte] using the specified [charset]. + * + * @param charset The [Charset] to use for converting the strings to bytes. Defaults to the system's default charset. + * + * @return A new [Flow] of [Byte] converted from the original [Flow] of [String]. + */ +fun Flow.asBytes( + charset: Charset = Charset.defaultCharset() +) = asByteArray(charset) + .map { it.toList() } + .flattenIterable() + +/** + * Converts the [Flow] of [String] to a [Flow] of [ByteArray] using the specified [charset]. + * + * @param charset The [Charset] to use for converting the strings to byte arrays. Defaults to the system's default charset. + * + * @return A new [Flow] of [ByteArray] converted from the original [Flow] of [String]. + */ +fun Flow.asByteArray( + charset: Charset = Charset.defaultCharset() +): Flow = map { it.toByteArray(charset) } + +/** + * Converts the [Flow] of [String] to a [Flow] of [ByteBuffer] using the specified [charset]. + * + * @param charset The [Charset] to use for converting the strings to byte buffers. Defaults to the system's default charset. + * + * @return A new [Flow] of [ByteBuffer] converted from the original [Flow] of [String]. + */ +fun Flow.asByteBuffer( + charset: Charset = Charset.defaultCharset() +): Flow = map { ByteBuffer.wrap(it.toByteArray(charset)) } diff --git a/core/src/main/kotlin/com/river/core/FlowBigDecimalExt.kt b/core/src/main/kotlin/com/river/core/FlowBigDecimalExt.kt deleted file mode 100644 index deb6cab4..00000000 --- a/core/src/main/kotlin/com/river/core/FlowBigDecimalExt.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.river.core - -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.fold -import java.math.BigDecimal - -/** - * Sums the elements of this [Flow] of [BigDecimal] and returns the result. - * - * @return The sum of all elements emitted by the source Flow. - * - * Example usage: - * ``` - * val flow = flowOf(1L, 2L, 3L, 4L, 5L).map(::BigDecimal.valueOf) - * val sum = runBlocking { flow.sum() } - * println(sum) // prints: 15 - * ``` - */ -suspend fun Flow.sum(): BigDecimal = - fold(BigDecimal.ZERO) { acc, i -> acc + i } diff --git a/core/src/main/kotlin/com/river/core/internal/DefaultAsyncSemaphore.kt b/core/src/main/kotlin/com/river/core/internal/DefaultAsyncSemaphore.kt deleted file mode 100644 index c438e9ed..00000000 --- a/core/src/main/kotlin/com/river/core/internal/DefaultAsyncSemaphore.kt +++ /dev/null @@ -1,103 +0,0 @@ -package com.river.core.internal - -import com.river.core.AsyncSemaphore -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Job -import kotlinx.coroutines.delay -import kotlinx.coroutines.launch -import kotlinx.coroutines.sync.Mutex -import kotlinx.coroutines.sync.Semaphore -import kotlinx.coroutines.sync.withLock -import kotlin.time.Duration - -/** - * The default implementation of the [AsyncSemaphore] interface. - * This class uses the [Semaphore] from kotlinx.coroutines.sync package to manage the permits. - */ -internal class DefaultAsyncSemaphore( - private val scope: CoroutineScope, - override val totalPermits: Int, - private val leaseTime: Duration? = null, -) : AsyncSemaphore { - private val mutex = Mutex() - private val internal = Semaphore(totalPermits) - - private val permits: Array = - (0 until totalPermits) - .map { SimplePermit(it, SimplePermit.State.Available) } - .toTypedArray() - - private val available - get() = permits.filter { it.state is SimplePermit.State.Available } - - private val nextAvailable - get() = available.first() - - class SimplePermit( - val id: Int, - var state: State - ) { - sealed interface State { - class Acquired(val timeout: Job?): State - object Available : State - } - } - - override suspend fun available(): Int = - internal.availablePermits - - override suspend fun acquire(): Int { - internal.acquire() - val permit = nextAvailable - - permit.state = SimplePermit.State.Acquired(leaseTime?.let { - mutex.withLock { - scope.launch { - delay(leaseTime) - release(permit.id) - } - } - }) - - return permit.id - } - - override suspend fun tryAcquire(): Int? { - if (!internal.tryAcquire()) { - return null - } - - val permit = nextAvailable - - permit.state = SimplePermit.State.Acquired(leaseTime?.let { - mutex.withLock { - scope.launch { - delay(leaseTime) - release(permit.id) - } - } - }) - - return permit.id - } - - override suspend fun release(permit: Int) { - mutex.withLock { - val p = permits[permit] - - when (val state = p.state) { - is SimplePermit.State.Acquired -> { - state.timeout?.cancel() - permits[permit].state = SimplePermit.State.Available - internal.release() - } - - SimplePermit.State.Available -> { - } - } - } - } - - override suspend fun releaseAll() = - permits.forEach { release(it.id) } -} diff --git a/core/src/test/kotlin/com/river/core/FlowExtKtTest.kt b/core/src/test/kotlin/com/river/core/FlowExtKtTest.kt deleted file mode 100644 index e6c0cc3a..00000000 --- a/core/src/test/kotlin/com/river/core/FlowExtKtTest.kt +++ /dev/null @@ -1,143 +0,0 @@ -@file:OptIn(ExperimentalTime::class) - -package com.river.core - -import io.kotest.core.spec.style.FeatureSpec -import io.kotest.matchers.collections.shouldContainInOrder -import io.kotest.matchers.collections.shouldNotContainAll -import io.kotest.matchers.shouldBe -import kotlinx.coroutines.delay -import kotlinx.coroutines.flow.* -import org.junit.jupiter.api.assertThrows -import kotlin.time.Duration.Companion.milliseconds -import kotlin.time.Duration.Companion.seconds -import kotlin.time.ExperimentalTime -import kotlin.time.measureTimedValue - -class FlowExtKtTest : FeatureSpec({ - feature("stoppableFlow") { - val infiniteFlow = poll { listOf("hello!") } - - scenario("Assert that using cancel() is working properly and the flow no longer emits new values") { - val stoppableFlow = - stoppableFlow { - var counter = 0 - - infiniteFlow - .collect { - emit(++counter) - if (counter == 1000) halt("counter reached the maximum count") - } - } - - stoppableFlow.count() shouldBe 1000 - } - - scenario("Assert that using other exceptions will make any collecting throw the error") { - val stoppableFlow = - stoppableFlow { - var counter = 0 - - infiniteFlow - .collect { - emit(++counter) - if (counter == 1000) error("ups, you should use `cancel` instead") - } - } - - assertThrows { stoppableFlow.collect() } - } - } - - feature("Flow.earlyCompleteIf") { - scenario("should transform the flow into a stoppable & complete it after the predicate returns true") { - val maybePrimes = flowOf(2, 4, 6, 8, 10, 12, 13, 14, 16) - - maybePrimes - .earlyCompleteIf { it % 2 != 0 } - .toList() - .toList() shouldBe listOf(2, 4, 6, 8, 10, 12) - } - } - - feature("Flow.asList") { - scenario("should transform the flow into a list") { - flowOf(2, 4, 6, 8, 10, 12, 14, 16) - .toList() shouldBe listOf(2, 4, 6, 8, 10, 12, 14, 16) - } - - scenario("should transform the flow into a list based on the count") { - flowOf(2, 4, 6, 8, 10, 12, 14, 16) - .toList(3) shouldBe listOf(2, 4, 6) - } - - scenario("should transform the flow into a list based on the time window") { - flowOf(2, 4, 6, 8, 10, 12, 14, 16) - .onEach { delay(190) } - .toList(10, 600.milliseconds) shouldBe listOf(2, 4, 6) - } - } - - feature("Flow.chunked") { - scenario("should chunk the items based on the count") { - flowOf(2, 4, 6, 8, 10, 12, 14, 16, 18, 20) - .chunked(10) - .toList() shouldBe listOf(listOf(2, 4, 6, 8, 10, 12, 14, 16, 18, 20)) - } - - scenario("should chunk the items based on the time window") { - flowOf(2, 4, 6, 8, 10, 12, 14, 16, 18, 20) - .onEach { delay(250.milliseconds) } - .chunked(10, 400.milliseconds) - .toList() shouldBe listOf(listOf(2, 4), listOf(6, 8), listOf(10, 12), listOf(14, 16), listOf(18, 20)) - } - } - - feature("Flow>.flatten") { - scenario("Should transform the Flow> into a Flow") { - val flowOfList = flowOf(listOf(2, 4), listOf(6, 8), listOf(10, 12), listOf(14, 16), listOf(18, 20)) - val flattenedFlow = flowOfList.flattenIterable() - flattenedFlow.toList() shouldBe listOf(2, 4, 6, 8, 10, 12, 14, 16, 18, 20) - } - } - - feature("Flow.mapAsync") { - scenario("Should allow a concurrency for item processing within the flow") { - val (_, duration) = measureTimedValue { - flowOf(2, 4, 6, 8, 10, 12, 14, 16, 18, 20) - .mapAsync(5) { delay(500.milliseconds) } - .collect() - } - - duration.inWholeSeconds shouldBe 1 - } - } - - feature("Flow.throttle") { - val flow = - (1..20) - .asFlow() - - scenario("Should suspend after the defined number of elements per time window is reached") { - val (result, duration) = measureTimedValue { flow.throttle(10, 2.seconds).toList() } - - duration.inWholeSeconds shouldBe 4 - result shouldContainInOrder (1..20).toList() - } - - scenario("Should drop if specified after the defined number of elements per time window is reached") { - val (result, duration) = measureTimedValue { - flow - .throttle( - elementsPerInterval = 10, - interval = 2.seconds, - strategy = ThrottleStrategy.Drop - ) - .toList() - } - - duration.inWholeSeconds shouldBe 2 - result shouldNotContainAll (0..20).toList() - } - } -}) diff --git a/core/src/test/kotlin/com/river/core/FlowNumberExtKtTest.kt b/core/src/test/kotlin/com/river/core/FlowNumberExtKtTest.kt deleted file mode 100644 index 82dead3e..00000000 --- a/core/src/test/kotlin/com/river/core/FlowNumberExtKtTest.kt +++ /dev/null @@ -1,34 +0,0 @@ -package com.river.core - -import io.kotest.core.spec.style.FeatureSpec -import io.kotest.matchers.shouldBe -import kotlinx.coroutines.flow.asFlow -import kotlinx.coroutines.flow.map -import java.math.BigDecimal - -class FlowNumberExtKtTest : FeatureSpec({ - val oneMillionFlow = (1..1000000).asFlow() - - feature("Flow extensions") { - scenario("Sum") { - oneMillionFlow - .sum() shouldBe 500000500000 - } - } - - feature("Flow extensions") { - scenario("Sum") { - oneMillionFlow - .map { it.toLong() } - .sum() shouldBe 500000500000 - } - } - - feature("Flow extensions") { - scenario("Sum") { - oneMillionFlow - .map { BigDecimal(it) } - .sum() shouldBe BigDecimal(500000500000) - } - } -}) diff --git a/core/src/test/kotlin/com/river/core/PollExtTest.kt b/core/src/test/kotlin/com/river/core/PollExtTest.kt deleted file mode 100644 index c06e108f..00000000 --- a/core/src/test/kotlin/com/river/core/PollExtTest.kt +++ /dev/null @@ -1,98 +0,0 @@ -package com.river.core - -import com.river.core.ConcurrencyStrategy.Companion.increaseByOne -import com.river.core.ConcurrencyStrategy.Companion.maximumAllowedAfterFirstIteration -import io.kotest.core.spec.style.FeatureSpec -import io.kotest.matchers.collections.shouldContainInOrder -import io.kotest.matchers.shouldBe -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.take -import kotlinx.coroutines.flow.toList -import java.util.concurrent.atomic.AtomicInteger -import java.util.concurrent.atomic.AtomicReference - -class PollExtTest : FeatureSpec({ - this as PollExtTest - - feature("poll: Flow") { - scenario("building a simple non-stopping flow") { - val count = 100 - val counter = AtomicInteger() - - val flow = counterBasedFlow(counter) - val list = flow.take(count).toList() - - list shouldContainInOrder (1..count).toList() - counter.get() shouldBe count - } - - scenario("building a parallelized non-stopping flow") { - val count = 1000 - val counter = AtomicInteger() - - val flow = poll(increaseByOne(5)) { listOf(counter.incrementAndGet()) } - val list = flow.take(count).toList() - - list shouldContainInOrder (1..count).toList() - counter.get() shouldBe count - } - - scenario("building a parallelized repeat flow that stops on empty lists") { - val count = 1000 - val counter = AtomicInteger() - - val flow = poll(increaseByOne(5), stopOnEmptyList = true) { - if (counter.get() == count) emptyList() - else listOf(counter.incrementAndGet()) - } - - val list = flow.toList() - - list shouldContainInOrder (1..count).toList() - counter.get() shouldBe count - } - - scenario("asserting the increase strategy is working properly") { - val counter = AtomicInteger() - val maxConcurrency = 10 - - val gap = ((100..120) + (250..270) + (850..980)) - val changedConcurrency = AtomicReference(1 to 0) - - val flow = - poll(maximumAllowedAfterFirstIteration(maxConcurrency)) { - val c = counter.incrementAndGet() - - val (last, count) = changedConcurrency.get() - - if (last != current) { - changedConcurrency.set(current to count + 1) - } - - if (c in gap) emptyList() - else listOf(c) - } - - val list = flow.earlyCompleteIf { it > 1000 }.toList() - - val expected = ((1..1000) - gap).toList() - list shouldBe expected - changedConcurrency.get() shouldBe (10 to 7) - } - } - - feature("pollWithState: Flow") { - scenario("building an arithmetic series flow") { - val count = 100 - - val flow = pollWithState(1, { it > count }) { state -> - (state + 1) to (0..state).toList() - } - - flow.sum() shouldBe 171700 - } - } -}) { - fun counterBasedFlow(counter: AtomicInteger): Flow = - poll { listOf(counter.incrementAndGet()) } -} diff --git a/examples/debezium-csv-s3/build.gradle.kts b/examples/debezium-csv-s3/build.gradle.kts index d5b2f583..d10ef44c 100644 --- a/examples/debezium-csv-s3/build.gradle.kts +++ b/examples/debezium-csv-s3/build.gradle.kts @@ -1,11 +1,18 @@ -dependencies { - // core is inherited +kotlin { + sourceSets { + jvmMain { + dependencies { + // core is inherited + val modules = modules { project(it) } - implementation(project.modules.debezium) - implementation(project.modules.csv) - implementation(project.modules.json) - implementation(project.modules.s3) + implementation(modules.debezium) + implementation(modules.csv) + implementation(modules.json) + implementation(modules.s3) - implementation(libs.debezium.postgres) - implementation(libs.postgresql.jdbc) + implementation(libs.debezium.postgres) + implementation(libs.postgresql.jdbc) + } + } + } } diff --git a/examples/debezium-csv-s3/src/main/kotlin/Sample.kt b/examples/debezium-csv-s3/src/jvmMain/kotlin/Sample.kt similarity index 100% rename from examples/debezium-csv-s3/src/main/kotlin/Sample.kt rename to examples/debezium-csv-s3/src/jvmMain/kotlin/Sample.kt diff --git a/examples/ktor-server-json-streaming/build.gradle.kts b/examples/ktor-server-json-streaming/build.gradle.kts index 2ca245fc..072a39b5 100644 --- a/examples/ktor-server-json-streaming/build.gradle.kts +++ b/examples/ktor-server-json-streaming/build.gradle.kts @@ -1,11 +1,18 @@ -dependencies { - // core is inherited +kotlin { + sourceSets { + jvmMain { + dependencies { + // core is inherited + val modules = modules { project(it) } - implementation(project.modules.http) - implementation(project.modules.json) + implementation(modules.http) + implementation(modules.json) - implementation(libs.ktor.server.core) - implementation(libs.ktor.server.netty) - implementation(libs.ktor.content.renegotiation) - implementation(libs.ktor.jackson) + implementation(libs.ktor.server.core) + implementation(libs.ktor.server.netty) + implementation(libs.ktor.content.renegotiation) + implementation(libs.ktor.jackson) + } + } + } } diff --git a/examples/ktor-server-json-streaming/src/main/kotlin/Sample.kt b/examples/ktor-server-json-streaming/src/jvmMain/kotlin/Sample.kt similarity index 100% rename from examples/ktor-server-json-streaming/src/main/kotlin/Sample.kt rename to examples/ktor-server-json-streaming/src/jvmMain/kotlin/Sample.kt diff --git a/examples/s3-csv-jdbc/build.gradle.kts b/examples/s3-csv-jdbc/build.gradle.kts index 33a7b7a7..a3bd4d07 100644 --- a/examples/s3-csv-jdbc/build.gradle.kts +++ b/examples/s3-csv-jdbc/build.gradle.kts @@ -1,8 +1,16 @@ -dependencies { - // core is inherited +kotlin { + sourceSets { + jvmMain { + dependencies { + // core is inherited + val modules = modules { project(it) } - implementation(project.modules.csv) - implementation(project.modules.s3) - implementation(project.modules.jdbc) - implementation(libs.postgresql.jdbc) + implementation(modules.csv) + implementation(modules.s3) + implementation(modules.jdbc) + + implementation(libs.postgresql.jdbc) + } + } + } } diff --git a/examples/s3-csv-jdbc/src/main/kotlin/Sample.kt b/examples/s3-csv-jdbc/src/jvmMain/kotlin/Sample.kt similarity index 100% rename from examples/s3-csv-jdbc/src/main/kotlin/Sample.kt rename to examples/s3-csv-jdbc/src/jvmMain/kotlin/Sample.kt diff --git a/examples/s3-csv-jdbc/src/main/kotlin/Setup.kt b/examples/s3-csv-jdbc/src/jvmMain/kotlin/Setup.kt similarity index 100% rename from examples/s3-csv-jdbc/src/main/kotlin/Setup.kt rename to examples/s3-csv-jdbc/src/jvmMain/kotlin/Setup.kt diff --git a/examples/sqs-to-http/build.gradle.kts b/examples/sqs-to-http/build.gradle.kts index bdc66709..1cb07f05 100644 --- a/examples/sqs-to-http/build.gradle.kts +++ b/examples/sqs-to-http/build.gradle.kts @@ -1,9 +1,16 @@ -dependencies { - // core is inherited +kotlin { + sourceSets { + jvmMain { + dependencies { + // core is inherited + val modules = modules { project(it) } - implementation(project.modules.http) - implementation(project.modules.sqs) + implementation(modules.http) + implementation(modules.sqs) - implementation(libs.wiremock) - implementation(libs.kotlin.wiremock) + implementation(libs.wiremock) + implementation(libs.kotlin.wiremock) + } + } + } } diff --git a/examples/sqs-to-http/src/main/kotlin/Sample.kt b/examples/sqs-to-http/src/jvmMain/kotlin/Sample.kt similarity index 100% rename from examples/sqs-to-http/src/main/kotlin/Sample.kt rename to examples/sqs-to-http/src/jvmMain/kotlin/Sample.kt diff --git a/examples/sqs-to-http/src/main/kotlin/Setup.kt b/examples/sqs-to-http/src/jvmMain/kotlin/Setup.kt similarity index 100% rename from examples/sqs-to-http/src/main/kotlin/Setup.kt rename to examples/sqs-to-http/src/jvmMain/kotlin/Setup.kt diff --git a/gradle.properties b/gradle.properties index 4a9594ae..ef899648 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1,2 @@ -org.gradle.jvmargs=-Xmx2048M \ No newline at end of file +org.gradle.jvmargs=-Xmx4096M +kotlin.mpp.androidSourceSetLayoutVersion=2 diff --git a/libs.versions.toml b/libs.versions.toml index c27c877c..a405f991 100644 --- a/libs.versions.toml +++ b/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -kotlin = "1.9.21" +kotlin = "1.9.22" dokka = "1.8.20" aws-sdk = "2.23.2" coroutines = "1.7.3" @@ -18,7 +18,7 @@ debezium = "2.3.2.Final" mongodb = "4.9.1" apache-ftpserver = "1.2.0" mock-ftpserver = "2.7.1" -kotest = "5.6.2" +kotest = "5.8.0" wiremock = "2.27.2" kotlin-wiremock = "2.0.2" kotest-wiremock = "2.0.0" @@ -29,10 +29,21 @@ reactor-kafka = "1.3.19" reactor-kotlin = "1.2.2" logback = "1.4.8" turbine = "1.0.0" +kotlinx-datetime = "0.5.0" +android = "8.1.4" +setup-android-sdk = "3.1.0" [plugins] kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } + +kotest-multiplatform = { id = "io.kotest.multiplatform", version.ref = "kotest" } + +android = { id = "com.android.library", version.ref = "android" } +kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } + +setup-android-sdk = { id = "com.quittle.setup-android-sdk", version.ref = "setup-android-sdk" } + dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } nexus-publish = { id = "io.github.gradle-nexus.publish-plugin", version = "1.3.0" } @@ -45,6 +56,8 @@ coroutines-jdk9 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-jdk9", ve kotlin = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" } kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" } +kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx-datetime" } + # aws aws-http-client-spi = { module = "software.amazon.awssdk:http-client-spi", version.ref = "aws-sdk" } aws-sqs = { module = "software.amazon.awssdk:sqs", version.ref = "aws-sdk" } @@ -54,6 +67,8 @@ aws-ses = { module = "software.amazon.awssdk:ses", version.ref = "aws-sdk" } aws-lambda = { module = "software.amazon.awssdk:lambda", version.ref = "aws-sdk" } # testing +kotest-assertions-core = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest" } +kotest-engine = { module = "io.kotest:kotest-framework-engine", version.ref = "kotest" } kotest-junit5 = { module = "io.kotest:kotest-runner-junit5", version.ref = "kotest" } wiremock = { module = "com.github.tomakehurst:wiremock", version.ref = "wiremock" } kotlin-wiremock = { module = "com.marcinziolo:kotlin-wiremock", version.ref = "kotlin-wiremock" } diff --git a/settings.gradle.kts b/settings.gradle.kts index 671b989c..3d871a61 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -6,11 +6,20 @@ dependencyResolutionManagement { } } +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + rootProject.name = "river" include( "core", "connectors", + "connectors:aws", "connectors:amqp", "connectors:apache:kafka", "connectors:aws:dynamodb", @@ -40,7 +49,6 @@ include( "connectors:red-hat:debezium", "connectors:openai", "connectors:redis", - "examples:sqs-to-http", "examples:s3-csv-jdbc", "examples:debezium-csv-s3",