|
| 1 | +import java.net.URI |
| 2 | +import javax.annotation.Nullable |
| 3 | +import org.gradle.api.tasks.testing.logging.TestExceptionFormat |
| 4 | +import org.gradle.api.tasks.testing.logging.TestLogEvent |
| 5 | +import java.awt.SystemColor.info |
| 6 | +import java.nio.file.Files.delete |
| 7 | + |
| 8 | +plugins { |
| 9 | + `java` |
| 10 | + `java-library` |
| 11 | + id("me.champeau.jmh") version "0.7.0" |
| 12 | +} |
| 13 | + |
| 14 | +group = "software.amazon.cryptography" |
| 15 | +version = "1.0-SNAPSHOT" |
| 16 | +description = "DynamoDbEncryptionPerformanceTest" |
| 17 | + |
| 18 | +java { |
| 19 | + toolchain.languageVersion.set(JavaLanguageVersion.of(17)) |
| 20 | + sourceSets["main"].java { |
| 21 | + srcDir("src/main/java") |
| 22 | + } |
| 23 | + sourceSets["test"].java { |
| 24 | + srcDir("src/test/java") |
| 25 | + } |
| 26 | +} |
| 27 | + |
| 28 | +sourceSets { |
| 29 | + this.jmh { |
| 30 | + java.setSrcDirs(mutableListOf("src/main/java")) |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +var caUrl: URI? = null |
| 35 | +@Nullable |
| 36 | +val caUrlStr: String? = System.getenv("CODEARTIFACT_URL_JAVA_CONVERSION") |
| 37 | +if (!caUrlStr.isNullOrBlank()) { |
| 38 | + caUrl = URI.create(caUrlStr) |
| 39 | +} |
| 40 | + |
| 41 | +var caPassword: String? = null |
| 42 | +@Nullable |
| 43 | +val caPasswordString: String? = System.getenv("CODEARTIFACT_AUTH_TOKEN") |
| 44 | +if (!caPasswordString.isNullOrBlank()) { |
| 45 | + caPassword = caPasswordString |
| 46 | +} |
| 47 | + |
| 48 | +repositories { |
| 49 | + mavenCentral() |
| 50 | + mavenLocal() |
| 51 | + |
| 52 | + // While commented out, this project will not pull from CodeArtifact, you must build and deploy dependencies locally |
| 53 | + // |
| 54 | + // maven { |
| 55 | + // name = "CodeArtifact" |
| 56 | + // url = URI.create("https://avp10745-648638458147.d.codeartifact.us-west-2.amazonaws.com/maven/AVP-10745/") |
| 57 | + // credentials { |
| 58 | + // username = "aws" |
| 59 | + // password = System.getenv("CODEARTIFACT_AUTH_TOKEN") |
| 60 | + // } |
| 61 | + //} |
| 62 | +} |
| 63 | + |
| 64 | +dependencies { |
| 65 | + implementation("software.amazon.cryptography:aws-database-encryption-sdk-dynamodb:1.0-SNAPSHOT") |
| 66 | + implementation("software.amazon.cryptography:AwsCryptographicMaterialProviders:1.0-SNAPSHOT") |
| 67 | + |
| 68 | + implementation(platform("software.amazon.awssdk:bom:2.19.1")) |
| 69 | + implementation("software.amazon.awssdk:dynamodb:2.20.64") |
| 70 | + implementation("software.amazon.awssdk:dynamodb-enhanced") |
| 71 | + implementation("com.amazonaws:aws-java-sdk-dynamodb:1.12.409") |
| 72 | + implementation("software.amazon.awssdk:kms") |
| 73 | + |
| 74 | + implementation("org.openjdk.jmh:jmh-core:1.36") |
| 75 | + implementation("org.openjdk.jmh:jmh-generator-annprocess:1.36") |
| 76 | + annotationProcessor ("org.openjdk.jmh:jmh-generator-annprocess:1.36") |
| 77 | + implementation("com.fasterxml.jackson.core:jackson-databind:2.15.0") |
| 78 | + implementation("com.univocity:univocity-parsers:2.9.1") |
| 79 | + implementation("javax.xml.bind:jaxb-api:2.3.1") |
| 80 | + implementation("org.apache.commons:commons-lang3:3.8.1") |
| 81 | + |
| 82 | + // https://mvnrepository.com/artifact/org.testng/testng |
| 83 | + testImplementation("org.testng:testng:7.5") |
| 84 | +} |
| 85 | + |
| 86 | +tasks.withType<JavaCompile>() { |
| 87 | + options.encoding = "UTF-8" |
| 88 | +} |
| 89 | + |
| 90 | +gradle.taskGraph.whenReady { |
| 91 | + delete { |
| 92 | + file("build/results/").deleteRecursively() |
| 93 | + } |
| 94 | +} |
| 95 | + |
| 96 | +tasks.test { |
| 97 | + useTestNG() |
| 98 | + |
| 99 | + // This will show System.out.println statements |
| 100 | + testLogging.showStandardStreams = true |
| 101 | + |
| 102 | + testLogging { |
| 103 | + lifecycle { |
| 104 | + events = mutableSetOf(TestLogEvent.FAILED, TestLogEvent.PASSED, TestLogEvent.SKIPPED) |
| 105 | + exceptionFormat = TestExceptionFormat.FULL |
| 106 | + showExceptions = true |
| 107 | + showCauses = true |
| 108 | + showStackTraces = true |
| 109 | + showStandardStreams = true |
| 110 | + } |
| 111 | + info.events = lifecycle.events |
| 112 | + info.exceptionFormat = lifecycle.exceptionFormat |
| 113 | + } |
| 114 | + |
| 115 | + // See https://github.com/gradle/kotlin-dsl/issues/836 |
| 116 | + addTestListener(object : TestListener { |
| 117 | + override fun beforeSuite(suite: TestDescriptor) {} |
| 118 | + override fun beforeTest(testDescriptor: TestDescriptor) {} |
| 119 | + override fun afterTest(testDescriptor: TestDescriptor, result: TestResult) {} |
| 120 | + |
| 121 | + override fun afterSuite(suite: TestDescriptor, result: TestResult) { |
| 122 | + if (suite.parent == null) { // root suite |
| 123 | + logger.lifecycle("----") |
| 124 | + logger.lifecycle("Test result: ${result.resultType}") |
| 125 | + logger.lifecycle("Test summary: ${result.testCount} tests, " + |
| 126 | + "${result.successfulTestCount} succeeded, " + |
| 127 | + "${result.failedTestCount} failed, " + |
| 128 | + "${result.skippedTestCount} skipped") |
| 129 | + } |
| 130 | + } |
| 131 | + }) |
| 132 | +} |
0 commit comments