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