-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathbuild.gradle.kts
278 lines (248 loc) · 9.94 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
import java.io.File
import java.io.FileInputStream
import java.util.Properties
import java.net.URI
import javax.annotation.Nullable
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
plugins {
`java`
`java-library`
`maven-publish`
`signing`
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
}
var props = Properties().apply {
load(FileInputStream(File(rootProject.rootDir, "../../../project.properties")))
}
group = "software.amazon.cryptography"
version = props.getProperty("projectJavaVersion")
description = "Aws Database Encryption Sdk for DynamoDb Java"
var mplVersion = props.getProperty("mplDependencyJavaVersion")
var dafnyRuntimeJavaVersion = props.getProperty("dafnyRuntimeJavaVersion")
var smithyDafnyJavaConversionVersion = props.getProperty("smithyDafnyJavaConversionVersion")
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(8))
sourceSets["main"].java {
srcDir("src/main/java")
srcDir("src/main/dafny-generated")
srcDir("src/main/smithy-generated")
srcDir("src/main/sdkv1")
}
sourceSets["test"].java {
srcDir("src/test")
}
withJavadocJar()
withSourcesJar()
}
var caUrl: URI? = null
@Nullable
val caUrlStr: String? = System.getenv("CODEARTIFACT_URL_JAVA_CONVERSION")
if (!caUrlStr.isNullOrBlank()) {
caUrl = URI.create(caUrlStr)
}
var caPassword: String? = null
@Nullable
val caPasswordString: String? = System.getenv("CODEARTIFACT_AUTH_TOKEN")
if (!caPasswordString.isNullOrBlank()) {
caPassword = caPasswordString
}
repositories {
mavenLocal()
maven {
name = "DynamoDB Local Release Repository - US West (Oregon) Region"
url = URI.create("https://s3-us-west-2.amazonaws.com/dynamodb-local/release")
}
mavenCentral()
if (caUrl != null && caPassword != null) {
maven {
name = "CodeArtifact"
url = caUrl!!
credentials {
username = "aws"
password = caPassword!!
}
}
}
}
// Configuration to hold SQLLite information.
// DynamoDB-Local needs to have access to native sqllite4java.
val dynamodb by configurations.creating
dependencies {
implementation("org.dafny:DafnyRuntime:${dafnyRuntimeJavaVersion}")
implementation("software.amazon.smithy.dafny:conversion:${smithyDafnyJavaConversionVersion}")
implementation("software.amazon.cryptography:aws-cryptographic-material-providers:${mplVersion}")
implementation(platform("software.amazon.awssdk:bom:2.30.18"))
implementation("software.amazon.awssdk:dynamodb")
implementation("software.amazon.awssdk:dynamodb-enhanced")
implementation("software.amazon.awssdk:kms")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.11.4")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.11.4")
// For the DDB-EC v1
implementation("com.amazonaws:aws-java-sdk-dynamodb:1.12.781")
// https://mvnrepository.com/artifact/org.testng/testng
testImplementation("org.testng:testng:7.5")
// https://mvnrepository.com/artifact/com.amazonaws/DynamoDBLocal
testImplementation("com.amazonaws:DynamoDBLocal:1.+")
// This is where we gather the SQLLite files to copy over
dynamodb("com.amazonaws:DynamoDBLocal:1.+")
// As of 1.21.0 DynamoDBLocal does not support Apple Silicon
// This checks the dependencies and adds a native library
// to support this architecture.
if (org.apache.tools.ant.taskdefs.condition.Os.isArch("aarch64")) {
testImplementation("io.github.ganadist.sqlite4java:libsqlite4java-osx-aarch64:1.0.392")
dynamodb("io.github.ganadist.sqlite4java:libsqlite4java-osx-aarch64:1.0.392")
}
// https://mvnrepository.com/artifact/org.hamcrest/hamcrest-all
testImplementation("org.hamcrest:hamcrest-all:1.3")
// https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk15on
testImplementation("org.bouncycastle:bcprov-jdk15on:1.70")
// https://mvnrepository.com/artifact/org.quicktheories/quicktheories
testImplementation("org.quicktheories:quicktheories:0.26")
// https://mvnrepository.com/artifact/junit/junit
testImplementation("junit:junit:4.13.2")
// https://mvnrepository.com/artifact/edu.umd.cs.mtc/multithreadedtc
testImplementation("edu.umd.cs.mtc:multithreadedtc:1.01")
// https://mvnrepository.com/artifact/org.projectlombok/lombok
testImplementation("org.projectlombok:lombok:1.18.36")
testAnnotationProcessor("org.projectlombok:lombok:1.18.36")
}
publishing {
publications.create<MavenPublication>("mavenLocal") {
groupId = "software.amazon.cryptography"
artifactId = "aws-database-encryption-sdk-dynamodb"
from(components["java"])
}
publications.create<MavenPublication>("maven") {
groupId = "software.amazon.cryptography"
artifactId = "aws-database-encryption-sdk-dynamodb"
from(components["java"])
// Include extra information in the POMs.
afterEvaluate {
pom {
name.set("AWS Database Encryption SDK for DynamoDB")
description.set("AWS Database Encryption SDK for DynamoDB in Java")
url.set("https://github.com/aws/aws-database-encryption-sdk-dynamodb")
licenses {
license {
name.set("Apache License 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
developers {
developer {
id.set("amazonwebservices")
organization.set("Amazon Web Services")
organizationUrl.set("https://aws.amazon.com")
roles.add("developer")
}
}
scm {
url.set("https://github.com/aws/aws-database-encryption-sdk-dynamodb.git")
}
}
}
}
repositories {
mavenLocal()
maven {
name = "StagingCodeArtifact"
url = URI.create("https://crypto-tools-internal-587316601012.d.codeartifact.us-east-1.amazonaws.com/maven/java-dbesdk-ddb-staging/")
credentials {
username = "aws"
password = System.getenv("CODEARTIFACT_TOKEN")
}
}
}
}
tasks.withType<JavaCompile>() {
options.encoding = "UTF-8"
}
tasks.withType<Jar>() {
// to compile a sources jar we need a strategy on how to deal with duplicates;
// we choose to include duplicate classes.
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
tasks.test {
useTestNG()
dependsOn("CopyDynamoDb")
systemProperty("java.library.path", "build/libs")
// This will show System.out.println statements
testLogging.showStandardStreams = true
testLogging {
lifecycle {
events = mutableSetOf(TestLogEvent.FAILED, TestLogEvent.PASSED, TestLogEvent.SKIPPED)
exceptionFormat = TestExceptionFormat.FULL
showExceptions = true
showCauses = true
showStackTraces = true
showStandardStreams = true
}
info.events = lifecycle.events
info.exceptionFormat = lifecycle.exceptionFormat
}
// See https://github.com/gradle/kotlin-dsl/issues/836
addTestListener(object : TestListener {
override fun beforeSuite(suite: TestDescriptor) {}
override fun beforeTest(testDescriptor: TestDescriptor) {}
override fun afterTest(testDescriptor: TestDescriptor, result: TestResult) {}
override fun afterSuite(suite: TestDescriptor, result: TestResult) {
if (suite.parent == null) { // root suite
logger.lifecycle("----")
logger.lifecycle("Test result: ${result.resultType}")
logger.lifecycle("Test summary: ${result.testCount} tests, " +
"${result.successfulTestCount} succeeded, " +
"${result.failedTestCount} failed, " +
"${result.skippedTestCount} skipped")
}
}
})
}
tasks.register<JavaExec>("runTests") {
mainClass.set("TestsFromDafny")
classpath = sourceSets["test"].runtimeClasspath
}
tasks.register<Copy>("CopyDynamoDb") {
from (dynamodb) {
include("*.dll")
include("*.dylib")
include("*.so")
}
into("build/libs")
}
tasks.javadoc {
options {
(this as CoreJavadocOptions).addStringOption("Xdoclint:none", "-quiet")
}
exclude("src/main/dafny-generated")
}
nexusPublishing {
// We are using the nexusPublishing plugin since it is recommended by Sonatype Gradle Project configurations
// and it is easy to supply the creds we need to deploy
// https://github.com/gradle-nexus/publish-plugin/
repositories {
sonatype {
nexusUrl.set(uri("https://aws.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://aws.oss.sonatype.org/content/repositories/snapshots/"))
username.set(System.getenv("SONA_USERNAME"))
password.set(System.getenv("SONA_PASSWORD"))
}
}
}
signing {
useGpgCmd()
// Dynamically set these properties
project.ext.set("signing.gnupg.executable", "gpg")
project.ext.set("signing.gnupg.useLegacyGpg" , "true")
project.ext.set("signing.gnupg.homeDir", System.getenv("HOME") + "/.gnupg/")
project.ext.set("signing.gnupg.optionsFile", System.getenv("HOME") + "/.gnupg/gpg.conf")
project.ext.set("signing.gnupg.keyName", System.getenv("GPG_KEY"))
project.ext.set("signing.gnupg.passphrase", System.getenv("GPG_PASS"))
// Signing is required if building a release version and if we're going to publish it.
// Otherwise if doing a maven publication we will sign
setRequired({
gradle.getTaskGraph().hasTask("publish")
})
sign(publishing.publications["maven"])
}