Skip to content

Commit

Permalink
Exclude examples from the workspace (#2535)
Browse files Browse the repository at this point in the history
This commit automates the fix made in awslabs/aws-sdk-rust#767.
When `aws-sdk-rust` is generated, `examples` will be excluded from the
workspace.

Co-authored-by: Yuki Saito <awsaito@amazon.com>
  • Loading branch information
ysaito1001 and ysaito1001 authored Apr 4, 2023
1 parent 724ada8 commit c901c0b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
5 changes: 2 additions & 3 deletions aws/sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import aws.sdk.AwsServices
import aws.sdk.Membership
import aws.sdk.RootTest
import aws.sdk.discoverServices
import aws.sdk.docsLandingPage
import aws.sdk.parseMembership
Expand Down Expand Up @@ -302,9 +301,9 @@ tasks.register<Copy>("relocateChangelog") {
fun generateCargoWorkspace(services: AwsServices): String {
return """
|[workspace]
|exclude = [${"\n"}${services.rootTests.map(RootTest::manifestName).joinToString(",\n") { "| \"$it\"" }}
|exclude = [${"\n"}${services.excludedFromWorkspace().joinToString(",\n") { "| \"$it\"" }}
|]
|members = [${"\n"}${services.allModules.joinToString(",\n") { "| \"$it\"" }}
|members = [${"\n"}${services.includedInWorkspace().joinToString(",\n") { "| \"$it\"" }}
|]
""".trimMargin()
}
Expand Down
16 changes: 13 additions & 3 deletions buildSrc/src/main/kotlin/aws/sdk/ServiceLoader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ class AwsServices(
(
services.map(AwsService::module).map { "sdk/$it" } +
CrateSet.AWS_SDK_SMITHY_RUNTIME.map { "sdk/$it" } +
CrateSet.AWS_SDK_RUNTIME.map { "sdk/$it" } +
examples
CrateSet.AWS_SDK_RUNTIME.map { "sdk/$it" }
// Root tests should not be included since they can't be part of the root Cargo workspace
// in order to test differences in Cargo features.
// in order to test differences in Cargo features. Examples should not be included either
// because each example itself is a workspace.
).toSortedSet()
}

Expand Down Expand Up @@ -78,6 +78,16 @@ class AwsServices(
false
}
}

/**
* Returns a sorted set of members included in the workspace.
*/
fun includedInWorkspace() = allModules

/**
* Returns a list of crates excluded from the workspace.
*/
fun excludedFromWorkspace() = examples + rootTests.map(RootTest::manifestName)
}

/**
Expand Down

0 comments on commit c901c0b

Please sign in to comment.