Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: setup DynamoDbMapper publication #1419

Merged
merged 15 commits into from
Oct 3, 2024
6 changes: 4 additions & 2 deletions .brazil.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
{
"dependencies": {
"org.jetbrains.kotlin:kotlin-gradle-plugin:2.*": "KotlinGradlePlugin-2.x",
"org.jetbrains.kotlin:kotlin-stdlib-common:2.*.*": "KotlinStdlibCommon-2.x",
"org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.*.*": "KotlinStdlibJdk8-2.x",
"org.jetbrains.kotlin:kotlin-stdlib:2.*.*": "KotlinStdlib-2.x",
"org.jetbrains.kotlinx:atomicfu:0.*.*": "Atomicfu-0.x",
"org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.*": "KotlinxCoroutinesCoreJvm-1.x",
"org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.*": "KotlinxCoroutinesJdk8-1.x"
"org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.*": "KotlinxCoroutinesJdk8-1.x",
"com.google.devtools.ksp:symbol-processing-api:2.*": "Maven-com-google-devtools-ksp_symbol-processing-api-2.x",
"com.google.devtools.ksp:symbol-processing-gradle-plugin:2.*": "Maven-com-google-devtools-ksp_symbol-processing-gradle-plugin-2.x"
},
"packageHandlingRules": {
"versioning": {
"defaultVersionLayout": "{MAJOR}.0.x"
},
"ignore": [
"aws.sdk.kotlin:bom",
"aws.sdk.kotlin.crt:aws-crt-kotlin-android",
"aws.sdk.kotlin:testing",
"aws.sdk.kotlin:version-catalog"
],
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ksp-version = "2.0.10-1.0.24" # Keep in sync with kotlin-version

dokka-version = "1.9.10"

aws-kotlin-repo-tools-version = "0.4.10"
aws-kotlin-repo-tools-version = "0.4.11"

# libs
coroutines-version = "1.9.0"
Expand Down
23 changes: 17 additions & 6 deletions hll/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import aws.sdk.kotlin.gradle.dsl.configurePublishing
import aws.sdk.kotlin.gradle.kmp.*
import aws.smithy.kotlin.runtime.InternalApi
import aws.smithy.kotlin.runtime.text.ensureSuffix
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

description = "High-level libraries for the AWS SDK for Kotlin"
Expand All @@ -31,22 +33,32 @@ val optinAnnotations = listOf(
"kotlin.RequiresOptIn",
)

@OptIn(InternalApi::class)
fun getHllPreviewVersion() = if (sdkVersion.contains("-SNAPSHOT")) { // i.e. 1.3.29-beta-SNAPSHOT
sdkVersion
.removeSuffix("-SNAPSHOT")
.ensureSuffix("-beta-SNAPSHOT")
} else {
sdkVersion.ensureSuffix("-beta") // i.e. 1.3.29-beta
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: "i.e." → "e.g."

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Any reason not to make this a val instead of a fun?


subprojects {
group = "aws.sdk.kotlin"
version = getHllPreviewVersion()
configurePublishing("aws-sdk-kotlin")
}

subprojects {
if (!needsKmpConfigured) {
return@subprojects
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Why was group, version, and configurePublishing refactored into a second subprojects block?

Copy link
Member Author

@lauzadis lauzadis Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All subprojects should have those values configured, they are not KMP-specific which is what the pre-existing block is for


group = "aws.sdk.kotlin"
version = sdkVersion

apply {
plugin("org.jetbrains.kotlin.multiplatform")
plugin("org.jetbrains.dokka")
plugin(libraries.plugins.aws.kotlin.repo.tools.kmp.get().pluginId)
}

configurePublishing("aws-sdk-kotlin")

kotlin {
explicitApi()

Expand Down Expand Up @@ -94,7 +106,6 @@ apiValidation {

ignoredProjects += listOf(
"hll-codegen",
"dynamodb-mapper-annotation-processor-test",
"dynamodb-mapper-codegen",
"dynamodb-mapper-ops-codegen",
"dynamodb-mapper-schema-codegen",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ kotlin {
}
}

val sdkVersion: String by project
group = "aws.sdk.kotlin"
version = sdkVersion

val sourcesJar by tasks.creating(Jar::class) {
group = "publishing"
description = "Assembles Kotlin sources jar"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ tasks.test {
}
}

val sdkVersion: String by project
group = "aws.sdk.kotlin"
version = sdkVersion

val sourcesJar by tasks.creating(Jar::class) {
group = "publishing"
description = "Assembles Kotlin sources jar"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import aws.smithy.kotlin.runtime.InternalApi
import aws.smithy.kotlin.runtime.text.ensureSuffix
Comment on lines +1 to +2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: How are these imports resolvable by the build script? Do we have the SDK/Smithy runtime in the classpath at this point?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why it works like this, but we do have a dependency on smithy-kotlin:runtime-core in this module, and the imports to resolve

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

/*
Expand Down Expand Up @@ -45,10 +47,6 @@ gradlePlugin {
}
}

val sdkVersion: String by project
group = "aws.sdk.kotlin"
version = sdkVersion

publishing {
publications {
create<MavenPublication>("dynamodb-mapper-schema-generator-plugin") {
Expand All @@ -57,6 +55,27 @@ publishing {
}
}

/**
* The `java-gradle-plugin` plugin creates a javadoc jar by default, conflicting with the empty javadoc jar (emptyJar)
* created in aws-kotlin-repo-tools. Configure dependencies and disable the emptyJar task to avoid conflicts.
*/
afterEvaluate {
tasks.withType<PublishToMavenRepository> {
dependsOn(tasks.named("javadocJar"))
}

tasks.named("publishDynamodb-mapper-schema-generatorPluginMarkerMavenPublicationToMavenLocal") {
dependsOn(tasks.named("javadocJar"))
}

tasks.findByName("signDynamodb-mapper-schema-generatorPluginMarkerMavenPublication")
?.dependsOn(tasks.named("javadocJar"))
Comment on lines +63 to +72
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Refactor tasks.named("javadocJar") into a val


tasks.named("emptyJar") {
enabled = false
}
}

tasks.test {
useJUnitPlatform()
testLogging {
Expand All @@ -69,6 +88,17 @@ tasks.test {
}

// FIXME Commonize the following functions into the aws-kotlin-repo-tools build-support
val sdkVersion: String by project

@OptIn(InternalApi::class)
fun getHllPreviewVersion() = if (sdkVersion.contains("-SNAPSHOT")) { // i.e. 1.3.29-beta-SNAPSHOT
sdkVersion
.removeSuffix("-SNAPSHOT")
.ensureSuffix("-beta-SNAPSHOT")
} else {
sdkVersion.ensureSuffix("-beta") // i.e. 1.3.29-beta
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: When commonizing this function I'm assuming we'll also commonize the other declaration of getHllPreviewVersion()?

Nit: If so can we add a // FIXME or a // TODO to the other instance to remind us

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I don't think this function will last long enough, it should be removed once we GA the DynamoDbMapper

/**
* Create a file containing the sdkVersion to use as a resource
* This saves us from having to manually change version numbers in multiple places
Expand All @@ -81,7 +111,7 @@ val generateSdkVersionFile by tasks.registering {
outputs.file(versionFile)
sourceSets.main.get().output.dir(resourcesDir)
doLast {
versionFile.writeText(sdkVersion)
versionFile.writeText(getHllPreviewVersion())
}
}

Expand Down
4 changes: 4 additions & 0 deletions hll/dynamodb-mapper/dynamodb-mapper/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
import java.nio.file.Files
import java.nio.file.StandardCopyOption

description = "High level DynamoDbMapper client"
extra["displayName"] = "AWS :: SDK :: Kotlin :: HLL :: DynamoDbMapper"
extra["moduleName"] = "aws.sdk.kotlin.hll.dynamodbmapper"

buildscript {
dependencies {
classpath(libs.ddb.local)
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 0 additions & 4 deletions hll/hll-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ dependencies {
testImplementation(libs.kotlin.test.junit5)
}

val sdkVersion: String by project
group = "aws.sdk.kotlin"
version = sdkVersion

Comment on lines -40 to -43
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: What version will hll-codegen use now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK so we'll just re-add version = sdkVersion when it comes time to GA the mapper?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and it's set up so we just have to change it in that one spot

val sourcesJar by tasks.creating(Jar::class) {
group = "publishing"
description = "Assembles Kotlin sources jar"
Expand Down
1 change: 0 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ if ("dynamodb".isBootstrappedService) {
include(":hll:dynamodb-mapper:dynamodb-mapper-ops-codegen")
include(":hll:dynamodb-mapper:dynamodb-mapper-schema-codegen")
include(":hll:dynamodb-mapper:dynamodb-mapper-annotations")
include(":hll:dynamodb-mapper:tests:dynamodb-mapper-annotation-processor-test")
include(":hll:dynamodb-mapper:dynamodb-mapper-schema-generator-plugin")
include(":hll:dynamodb-mapper:tests:dynamodb-mapper-schema-generator-plugin-test")
} else {
Expand Down
Loading