Skip to content

Commit 953b042

Browse files
feat(Tools): Add helper for AWS SDK for .NET VCS path curations
The AWS SDK for .NET libraries are stored in a monorepo [1]. Add a helper to create the required VCS path curations. [1]: https://github.com/aws/aws-sdk-net Signed-off-by: Marcel Bochtler <[email protected]>
1 parent be2fd89 commit 953b042

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

tools/curations/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import org.ossreviewtoolkit.tools.curations.GenerateAspNetCoreCurationsTask
2+
import org.ossreviewtoolkit.tools.curations.GenerateAwsSdkForNetCurationsTask
23
import org.ossreviewtoolkit.tools.curations.GenerateAzureSdkForNetCurationsTask
34
import org.ossreviewtoolkit.tools.curations.GenerateDotNetRuntimeCurationsTask
45
import org.ossreviewtoolkit.tools.curations.GenerateLicenseClassificationsTask
@@ -9,6 +10,7 @@ tasks {
910
register<GenerateLicenseClassificationsTask>("generateLicenseClassifications")
1011
register<GenerateAspNetCoreCurationsTask>("generateAspNetCoreCurations")
1112
register<GenerateAzureSdkForNetCurationsTask>("generateAzureSdkForNetCurations")
13+
register<GenerateAwsSdkForNetCurationsTask>("generateAwsSdkForNetCurations")
1214
register<GenerateDotNetRuntimeCurationsTask>("generateDotNetRuntimeCurations")
1315

1416
register<VerifyPackageConfigurationsTask>("verifyPackageConfigurations")
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package org.ossreviewtoolkit.tools.curations
2+
3+
import org.gradle.api.tasks.TaskAction
4+
import org.ossreviewtoolkit.model.Identifier
5+
6+
open class GenerateAwsSdkForNetCurationsTask : BaseGenerateCurationsTask() {
7+
private val fourDigitVersionRegex = Regex("""\d+\.\d+\.\d+\.\d+""")
8+
9+
@TaskAction
10+
fun generate() {
11+
val data = mutableSetOf<PathCurationData>()
12+
val targetFrameworkRegex = Regex("""\.Net.+$""")
13+
14+
getTagsFromRepository(owner = "aws", repository = "aws-sdk-net")
15+
.filter { it.isFourDigitVersion() }
16+
.forEach { tag ->
17+
logger.quiet("Processing tag $tag.")
18+
19+
getFilesFromRepository(owner = "aws", repository = "aws-sdk-net", ref = tag)
20+
.filter { it.startsWith("sdk/src/Services/") && it.endsWith(".csproj") }
21+
.forEach {
22+
val project = it.substringAfterLast("/")
23+
.removeSuffix(".csproj")
24+
.replace(targetFrameworkRegex, "")
25+
val path = it.substringBeforeLast("/")
26+
val id = Identifier("NuGet::$project")
27+
28+
// The AWS SDK for .NET uses a four-part version number for all packages. However, Semver4j
29+
// does not support four-part version numbers. Therefore, remove the fourth digit.
30+
val threeDigitVersionTag =
31+
if (tag.count { c -> c == '.' } == 3) tag.substringBeforeLast(".") else tag
32+
33+
if ("AWSSDK." in project) {
34+
data += PathCurationData(id, path, threeDigitVersionTag)
35+
}
36+
}
37+
}
38+
39+
data.groupBy { it.id }.forEach { (_, curationData) ->
40+
curationData.toPathCurations().forEach { saveCuration(it) }
41+
}
42+
}
43+
44+
private fun String.isFourDigitVersion() = fourDigitVersionRegex.matches(this)
45+
}

0 commit comments

Comments
 (0)