Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changes/703da74b-6f77-4555-b129-295486571361.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"id": "703da74b-6f77-4555-b129-295486571361",
"type": "feature",
"description": "Publish a BOM and a Version Catalog",
"issues": [
"awslabs/aws-sdk-kotlin#605",
"awslabs/aws-sdk-kotlin#805"
]
}
90 changes: 90 additions & 0 deletions bom/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
import aws.sdk.kotlin.gradle.dsl.configurePublishing
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMetadataTarget
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget
import java.util.*

plugins {
`maven-publish`
`java-platform`
`version-catalog`
}

val sdkVersion: String by project

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

val evaluateAfter = listOf(":services", ":aws-runtime", ":tests", ":codegen")
evaluateAfter.forEach { evaluationDependsOn(it) }

fun createBomConstraintsAndVersionCatalog() {
val bomConstraints: DependencyConstraintHandler = dependencies.constraints
val catalogExt = catalog

rootProject.subprojects {
val subproject = this
val hasMavenPublish = subproject.plugins.hasPlugin("maven-publish")
if (!hasMavenPublish) {
logger.info("skipping bom and version-catalog entry for ${subproject.name}")
return@subprojects
}
subproject.plugins.withType<KotlinMultiplatformPluginWrapper> {
subproject.extensions.getByType<KotlinMultiplatformExtension>().targets.all {
val target = this
val gavCoordinates = gav(target)
bomConstraints.api(gavCoordinates)
catalogExt.versionCatalog {
val prefix = when {
subproject.path.contains(":services") -> "services-"
subproject.path.contains(":aws-runtime") -> "runtime-"
else -> ""
}
val alias = prefix + artifactId(target)
library(alias, gavCoordinates)
}
}
}
}
}

fun Project.artifactId(target: KotlinTarget): String = when (target) {
is KotlinMetadataTarget -> name
is KotlinJsTarget -> "$name-js"
else -> "$name-${target.targetName.toLowerCase(Locale.ROOT)}"
}

/**
* Returns a string like "aws.sdk.kotlin:s3-linuxx64:1.0.2" for this target.
*/
fun Project.gav(target: KotlinTarget): String {
val artifactId = artifactId(target)
return "$group:$artifactId:$version"
}

fun DependencyConstraintHandler.api(constraintNotation: Any) =
add("api", constraintNotation)

createBomConstraintsAndVersionCatalog()

configurePublishing("aws-sdk-kotlin")

publishing {
publications {
create("bom", MavenPublication::class) {
artifactId = "bom"
from(project.components.getByName("javaPlatform"))
}

create<MavenPublication>("versionCatalog") {
artifactId = "version-catalog"
from(components["versionCatalog"])
}
}
}
2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ rootProject.name = "aws-sdk-kotlin"
includeBuild("./gradle/sdk-plugins")

include(":dokka-aws")
include(":bom")
include(":codegen:sdk")
include(":codegen:smithy-aws-kotlin-codegen")
include(":codegen:protocol-tests")
Expand All @@ -45,6 +46,7 @@ include(":aws-runtime:aws-core")
include(":aws-runtime:aws-config")
include(":aws-runtime:aws-endpoint")
include(":aws-runtime:aws-http")
include(":services")
include(":tests")
include(":tests:benchmarks:service-benchmarks")
include(":tests:codegen:event-stream")
Expand Down