|
| 1 | +import java.io.File |
| 2 | +import java.io.FileInputStream |
| 3 | +import java.util.Properties |
| 4 | +import java.net.URI |
| 5 | +import javax.annotation.Nullable |
| 6 | +import org.gradle.api.tasks.testing.logging.TestExceptionFormat |
| 7 | +import org.gradle.api.tasks.testing.logging.TestLogEvent |
| 8 | + |
| 9 | +plugins { |
| 10 | + `java` |
| 11 | + `java-library` |
| 12 | +} |
| 13 | + |
| 14 | +var props = Properties().apply { |
| 15 | + load(FileInputStream(File(rootProject.rootDir, "../../../../project.properties"))) |
| 16 | +} |
| 17 | + |
| 18 | +group = "software.amazon.cryptography" |
| 19 | +version = "1.0-SNAPSHOT" |
| 20 | +description = "DDBECExamples" |
| 21 | + |
| 22 | +var mplVersion = props.getProperty("mplDependencyJavaVersion") |
| 23 | +var ddbecVersion = props.getProperty("projectJavaVersion") |
| 24 | + |
| 25 | +java { |
| 26 | + toolchain.languageVersion.set(JavaLanguageVersion.of(8)) |
| 27 | + sourceSets["main"].java { |
| 28 | + srcDir("src/main/java") |
| 29 | + } |
| 30 | + sourceSets["test"].java { |
| 31 | + srcDir("src/test/java") |
| 32 | + } |
| 33 | +} |
| 34 | + |
| 35 | +var caUrl: URI? = null |
| 36 | +@Nullable |
| 37 | +val caUrlStr: String? = System.getenv("CODEARTIFACT_REPO_URL") |
| 38 | +if (!caUrlStr.isNullOrBlank()) { |
| 39 | + caUrl = URI.create(caUrlStr) |
| 40 | +} |
| 41 | + |
| 42 | +var caPassword: String? = null |
| 43 | +@Nullable |
| 44 | +val caPasswordString: String? = System.getenv("CODEARTIFACT_TOKEN") |
| 45 | +if (!caPasswordString.isNullOrBlank()) { |
| 46 | + caPassword = caPasswordString |
| 47 | +} |
| 48 | + |
| 49 | +repositories { |
| 50 | + mavenLocal() |
| 51 | + maven { |
| 52 | + name = "DynamoDB Local Release Repository - US West (Oregon) Region" |
| 53 | + url = URI.create("https://s3-us-west-2.amazonaws.com/dynamodb-local/release") |
| 54 | + } |
| 55 | + mavenCentral() |
| 56 | + if (caUrl != null && caPassword != null) { |
| 57 | + maven { |
| 58 | + name = "CodeArtifact" |
| 59 | + url = caUrl!! |
| 60 | + credentials { |
| 61 | + username = "aws" |
| 62 | + password = caPassword!! |
| 63 | + } |
| 64 | + } |
| 65 | + } |
| 66 | +} |
| 67 | + |
| 68 | +dependencies { |
| 69 | + implementation("software.amazon.cryptography:aws-database-encryption-sdk-dynamodb:${ddbecVersion}") |
| 70 | + implementation("software.amazon.cryptography:aws-cryptographic-material-providers:${mplVersion}") |
| 71 | + |
| 72 | + implementation(platform("software.amazon.awssdk:bom:2.19.1")) |
| 73 | + implementation("software.amazon.awssdk:dynamodb") |
| 74 | + implementation("software.amazon.awssdk:dynamodb-enhanced") |
| 75 | + implementation("software.amazon.awssdk:kms") |
| 76 | + |
| 77 | + testImplementation("org.testng:testng:7.5") |
| 78 | +} |
| 79 | + |
| 80 | +tasks.withType<JavaCompile>() { |
| 81 | + options.encoding = "UTF-8" |
| 82 | +} |
| 83 | + |
| 84 | +tasks.test { |
| 85 | + useTestNG() |
| 86 | + |
| 87 | + // This will show System.out.println statements |
| 88 | + testLogging.showStandardStreams = true |
| 89 | + |
| 90 | + testLogging { |
| 91 | + lifecycle { |
| 92 | + events = mutableSetOf(TestLogEvent.FAILED, TestLogEvent.PASSED, TestLogEvent.SKIPPED) |
| 93 | + exceptionFormat = TestExceptionFormat.FULL |
| 94 | + showExceptions = true |
| 95 | + showCauses = true |
| 96 | + showStackTraces = true |
| 97 | + showStandardStreams = true |
| 98 | + } |
| 99 | + info.events = lifecycle.events |
| 100 | + info.exceptionFormat = lifecycle.exceptionFormat |
| 101 | + } |
| 102 | + |
| 103 | + // See https://github.com/gradle/kotlin-dsl/issues/836 |
| 104 | + addTestListener(object : TestListener { |
| 105 | + override fun beforeSuite(suite: TestDescriptor) {} |
| 106 | + override fun beforeTest(testDescriptor: TestDescriptor) {} |
| 107 | + override fun afterTest(testDescriptor: TestDescriptor, result: TestResult) {} |
| 108 | + |
| 109 | + override fun afterSuite(suite: TestDescriptor, result: TestResult) { |
| 110 | + if (suite.parent == null) { // root suite |
| 111 | + logger.lifecycle("----") |
| 112 | + logger.lifecycle("Test result: ${result.resultType}") |
| 113 | + logger.lifecycle("Test summary: ${result.testCount} tests, " + |
| 114 | + "${result.successfulTestCount} succeeded, " + |
| 115 | + "${result.failedTestCount} failed, " + |
| 116 | + "${result.skippedTestCount} skipped") |
| 117 | + } |
| 118 | + } |
| 119 | + }) |
| 120 | +} |
0 commit comments