Skip to content

Instantly share code, notes, and snippets.

@kmtr
Created June 24, 2021 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmtr/4b04142e944ed30b936f3ade103d184c to your computer and use it in GitHub Desktop.
Save kmtr/4b04142e944ed30b936f3ade103d184c to your computer and use it in GitHub Desktop.
/*
package dynamodb
import com.amazonaws.services.dynamodbv2.local.embedded.DynamoDBEmbedded
import com.amazonaws.services.dynamodbv2.model.*
import software.amazon.awssdk.services.dynamodb.model.GetItemRequest
import software.amazon.awssdk.services.dynamodb.model.AttributeValue
import software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClient
import kotlin.test.Test
class LibraryTest {
@Test
fun test() {
val ddbEm = DynamoDBEmbedded.create()
val eCli = DynamoDbEnhancedClient.builder().dynamoDbClient(ddbEm.dynamoDbClient())
val ctr = CreateTableRequest().also {
it.tableName = "Music"
it.setAttributeDefinitions(
arrayListOf(
AttributeDefinition().withAttributeName("Artist").withAttributeType(ScalarAttributeType.S)
)
)
it.setKeySchema(
arrayListOf(
KeySchemaElement().withAttributeName("Artist").withKeyType(KeyType.HASH)
)
)
it.provisionedThroughput = ProvisionedThroughput().withReadCapacityUnits(1).withWriteCapacityUnits(1)
}
ddbEm.amazonDynamoDB().createTable(ctr)
val req = GetItemRequest().withTableName("Music")
.withKey(hashMapOf("Artist" to AttributeValue("Hi")))
ddbEm.dynamoDbClient().getItem(
GetItemRequest.builder()
.tableName("Music")
.key(hashMapOf("Artist" to AttributeValue.builder().s("Hi").build())).build()
)
}
}
*/
plugins {
// Apply the org.jetbrains.kotlin.jvm Plugin to add support for Kotlin.
kotlin("jvm") version "1.5.20"
// Apply the java-library plugin for API and implementation separation.
`java-library`
}
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
maven("https://s3.ap-northeast-1.amazonaws.com/dynamodb-local-tokyo/release")
}
dependencies {
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
// aws sdk 2
implementation(platform("software.amazon.awssdk:bom:2.16.83"))
implementation("software.amazon.awssdk:dynamodb")
implementation("software.amazon.awssdk:dynamodb-enhanced")
testImplementation("com.amazonaws:DynamoDBLocal:1.16.0")
testImplementation("com.almworks.sqlite4java:sqlite4java:1.0.392")
testImplementation("com.almworks.sqlite4java:libsqlite4java-linux-amd64:1.0.392")
testImplementation("com.almworks.sqlite4java:sqlite4java-win32-x64:1.0.392")
}
val buildNativeLibsPath = "build/native-libs"
val copyNativeDeps = tasks.register<Copy>("copyNativeDeps") {
mkdir(buildNativeLibsPath)
from(configurations.testCompileClasspath) {
include("*.dll")
include("*.dylib")
include("*.so")
}
into(buildNativeLibsPath)
}
tasks.test {
dependsOn(copyNativeDeps)
doFirst {
systemProperties(("java.library.path" to buildNativeLibsPath))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment