From b85327d3fd14eaa7ec92935d0bb2c911d38e9b6f Mon Sep 17 00:00:00 2001 From: Vladimir Orany Date: Fri, 12 Jul 2024 10:16:49 +0200 Subject: [PATCH] Reintroduce dynamodb kotlin (#244) * Reintroduce DynamoDB v2 Kotlin DSL * using latest Micronaut * fixed Kotlin classpath * migrated imports * fixed incompatibility with varargs * updated license --- gradle.properties | 5 +++-- settings.gradle | 3 +++ ...> micronaut-amazon-awssdk-dynamodb-kotlin.gradle} | 8 ++++---- .../amazon/awssdk/dynamodb/kotlin/DynamoDbDsl.kt | 2 +- .../dynamodb/kotlin/FilterConditionCollector.kt | 2 +- .../amazon/awssdk/dynamodb/kotlin/QueryBuilder.kt | 2 +- .../amazon/awssdk/dynamodb/kotlin/QueryFunction.kt | 2 +- .../amazon/awssdk/dynamodb/kotlin/ScanBuilder.kt | 2 +- .../amazon/awssdk/dynamodb/kotlin/ScanFunction.kt | 2 +- .../amazon/awssdk/dynamodb/kotlin/UpdateBuilder.kt | 2 +- .../amazon/awssdk/dynamodb/kotlin/UpdateFunction.kt | 2 +- .../awssdk/dynamodb/kotlin/DeclarativeServiceTest.kt | 12 +++++++----- .../amazon/awssdk/dynamodb/kotlin/DynamoDBEntity.kt | 2 +- .../awssdk/dynamodb/kotlin/DynamoDBEntityService.kt | 3 +-- 14 files changed, 27 insertions(+), 22 deletions(-) rename subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/{x-micronaut-amazon-awssdk-dynamodb-kotlin.gradle => micronaut-amazon-awssdk-dynamodb-kotlin.gradle} (83%) diff --git a/gradle.properties b/gradle.properties index be7a4ca0c..cd5f64d8e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,8 +18,8 @@ slug=agorapulse/micronaut-aws-sdk group=com.agorapulse -micronautVersion = 4.2.0 -micronautGradlePluginVersion = 4.2.0 +micronautVersion = 4.5.0 +micronautGradlePluginVersion = 4.4.0 gruVersion = 2.0.5 awsSdkVersion = 1.12.692 awsSdk2Version = 2.25.22 @@ -32,6 +32,7 @@ nexusPluginVersion=1.0.0 closureSupportVersion=0.6.3 mockitoVersion=2.23.4 kotlinVersion=1.9.21 +kspVersion=1.9.21-1.0.15 # other versions creates conflicts in Groovydoc groovyVersion = 4.0.16 diff --git a/settings.gradle b/settings.gradle index e2f350600..0d66c0759 100644 --- a/settings.gradle +++ b/settings.gradle @@ -37,6 +37,9 @@ buildscript { gradlePluginPortal() } dependencies { + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") + classpath("org.jetbrains.kotlin.plugin.allopen:org.jetbrains.kotlin.plugin.allopen.gradle.plugin:$kotlinVersion") + classpath("com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:$kspVersion") classpath("io.micronaut.gradle:micronaut-minimal-plugin:$micronautGradlePluginVersion") } } diff --git a/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/x-micronaut-amazon-awssdk-dynamodb-kotlin.gradle b/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/micronaut-amazon-awssdk-dynamodb-kotlin.gradle similarity index 83% rename from subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/x-micronaut-amazon-awssdk-dynamodb-kotlin.gradle rename to subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/micronaut-amazon-awssdk-dynamodb-kotlin.gradle index 57981f78a..1fc0f5c2f 100644 --- a/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/x-micronaut-amazon-awssdk-dynamodb-kotlin.gradle +++ b/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/micronaut-amazon-awssdk-dynamodb-kotlin.gradle @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: Apache-2.0 * - * Copyright 2018-2023 Agorapulse. + * Copyright 2018-2024 Agorapulse. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,9 +16,9 @@ * limitations under the License. */ plugins { - id 'org.jetbrains.kotlin.jvm' version "$kotlinVersion" - id 'org.jetbrains.kotlin.plugin.allopen' version "$kotlinVersion" - id 'com.google.devtools.ksp' version '1.9.21-1.0.15' + id 'org.jetbrains.kotlin.jvm' + id 'org.jetbrains.kotlin.plugin.allopen' + id 'com.google.devtools.ksp' } dependencies { diff --git a/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/DynamoDbDsl.kt b/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/DynamoDbDsl.kt index 6f9eb7fc8..0e54c18cc 100644 --- a/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/DynamoDbDsl.kt +++ b/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/DynamoDbDsl.kt @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: Apache-2.0 * - * Copyright 2018-2023 Agorapulse. + * Copyright 2018-2024 Agorapulse. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/FilterConditionCollector.kt b/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/FilterConditionCollector.kt index fafc8e86a..343f6c3ca 100644 --- a/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/FilterConditionCollector.kt +++ b/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/FilterConditionCollector.kt @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: Apache-2.0 * - * Copyright 2018-2023 Agorapulse. + * Copyright 2018-2024 Agorapulse. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/QueryBuilder.kt b/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/QueryBuilder.kt index 67b13259a..2e5226c18 100644 --- a/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/QueryBuilder.kt +++ b/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/QueryBuilder.kt @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: Apache-2.0 * - * Copyright 2018-2023 Agorapulse. + * Copyright 2018-2024 Agorapulse. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/QueryFunction.kt b/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/QueryFunction.kt index 4b169690a..d9877494c 100644 --- a/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/QueryFunction.kt +++ b/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/QueryFunction.kt @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: Apache-2.0 * - * Copyright 2018-2023 Agorapulse. + * Copyright 2018-2024 Agorapulse. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/ScanBuilder.kt b/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/ScanBuilder.kt index 7c108305f..8e6c5049d 100644 --- a/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/ScanBuilder.kt +++ b/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/ScanBuilder.kt @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: Apache-2.0 * - * Copyright 2018-2023 Agorapulse. + * Copyright 2018-2024 Agorapulse. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/ScanFunction.kt b/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/ScanFunction.kt index 06a390c9e..dee35eed0 100644 --- a/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/ScanFunction.kt +++ b/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/ScanFunction.kt @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: Apache-2.0 * - * Copyright 2018-2023 Agorapulse. + * Copyright 2018-2024 Agorapulse. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/UpdateBuilder.kt b/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/UpdateBuilder.kt index b895798df..e366dd7c6 100644 --- a/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/UpdateBuilder.kt +++ b/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/UpdateBuilder.kt @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: Apache-2.0 * - * Copyright 2018-2023 Agorapulse. + * Copyright 2018-2024 Agorapulse. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/UpdateFunction.kt b/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/UpdateFunction.kt index f78ab1aa1..f9fc02f7f 100644 --- a/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/UpdateFunction.kt +++ b/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/main/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/UpdateFunction.kt @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: Apache-2.0 * - * Copyright 2018-2023 Agorapulse. + * Copyright 2018-2024 Agorapulse. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/test/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/DeclarativeServiceTest.kt b/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/test/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/DeclarativeServiceTest.kt index 671312776..15d8e86a0 100644 --- a/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/test/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/DeclarativeServiceTest.kt +++ b/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/test/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/DeclarativeServiceTest.kt @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: Apache-2.0 * - * Copyright 2018-2023 Agorapulse. + * Copyright 2018-2024 Agorapulse. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,14 +17,14 @@ */ package com.agorapulse.micronaut.amazon.awssdk.dynamodb.kotlin -import io.micronaut.test.annotation.MicronautTest +import io.micronaut.test.extensions.junit5.annotation.MicronautTest +import jakarta.inject.Inject import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import reactor.core.publisher.Flux import java.time.Instant import java.time.temporal.ChronoUnit import java.util.* -import javax.inject.Inject // tag::header[] @MicronautTest // <1> @@ -56,16 +56,18 @@ class DeclarativeServiceTest { ) Assertions.assertNotNull( s.saveAll( + listOf( createEntity("3", "1", "foo", Date.from(REFERENCE_DATE.plus(7, ChronoUnit.DAYS))), createEntity("3", "2", "bar", Date.from(REFERENCE_DATE.plus(14, ChronoUnit.DAYS))) + ) ) ) Assertions.assertNotNull(s.get("1", "1")) Assertions.assertNotNull(s.load("1", "1")) Assertions.assertEquals(2, s.getAll("1", Arrays.asList("2", "1"))!!.size) Assertions.assertEquals(2, s.loadAll("1", Arrays.asList("2", "1"))!!.size) - Assertions.assertEquals(2, s.getAll("1", "2", "1")!!.size) - Assertions.assertEquals(0, s.loadAll("1", "3", "4")!!.size) + Assertions.assertEquals(2, s.getAll("1", listOf("2", "1"))!!.size) + Assertions.assertEquals(0, s.loadAll("1", listOf("3", "4"))!!.size) Assertions.assertEquals(2, s.count("1")) Assertions.assertEquals(1, s.count("1", "1")) Assertions.assertEquals(1, s.countByRangeIndex("1", "bar")) diff --git a/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/test/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/DynamoDBEntity.kt b/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/test/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/DynamoDBEntity.kt index a05ae3f4a..21e6c1904 100644 --- a/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/test/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/DynamoDBEntity.kt +++ b/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/test/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/DynamoDBEntity.kt @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: Apache-2.0 * - * Copyright 2018-2023 Agorapulse. + * Copyright 2018-2024 Agorapulse. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/test/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/DynamoDBEntityService.kt b/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/test/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/DynamoDBEntityService.kt index 6609d2384..08d10fd71 100644 --- a/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/test/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/DynamoDBEntityService.kt +++ b/subprojects/micronaut-amazon-awssdk-dynamodb-kotlin/src/test/kotlin/com/agorapulse/micronaut/amazon/awssdk/dynamodb/kotlin/DynamoDBEntityService.kt @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: Apache-2.0 * - * Copyright 2018-2023 Agorapulse. + * Copyright 2018-2024 Agorapulse. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,6 @@ interface DynamoDBEntityService { fun loadAll(hash: String?, rangeKeys: List?): List? fun loadAll(hash: String?, vararg rangeKeys: String?): List? fun save(entity: DynamoDBEntity?): DynamoDBEntity? - fun saveAll(vararg entities: DynamoDBEntity?): List? fun saveAll(entities: Iterable?): List? fun count(hashKey: String?): Int fun count(hashKey: String?, rangeKey: String?): Int