fun generateSmithyBuild()

in codegen/sdk-codegen/build.gradle.kts [77:119]


fun generateSmithyBuild(services: List<AwsService>): String {
    require(services.isNotEmpty()) {
        "No services discovered. Verify aws.services and aws.protocols properties in local.build. Aborting."
    }
    val buildStandaloneSdk = getProperty("buildStandaloneSdk")?.toBoolean() ?: false
    val projections = services.joinToString(",") { service ->
        // escape windows paths for valid json
        val absModelPath = service.modelFile.absolutePath.replace("\\", "\\\\")
        val importPaths = mutableListOf(absModelPath)
        if (file(service.modelExtrasDir).exists()) {
            importPaths.add(service.modelExtrasDir.replace("\\", "\\\\"))
        }
        val imports = importPaths.joinToString { "\"$it\"" }
        """
            "${service.projectionName}": {
                "imports": [$imports],
                "plugins": {
                    "swift-codegen": {
                      "service": "${service.name}",
                      "module" : "${service.packageName}",
                      "moduleVersion": "${service.packageVersion}",
                      "homepage": "https://docs.amplify.aws/",
                      "sdkId": "${service.sdkId}",
                      "author": "Amazon Web Services",
                      "gitRepo": "${service.gitRepo}",
                      "swiftVersion": "5.4.0",
                      "build": {
                          "rootProject": $buildStandaloneSdk
                      }
                    }
                }
            }
        """
    }
    return """
    {
        "version": "1.0",
        "projections": {
            $projections
        }
    }
    """.trimIndent()
}