-
Notifications
You must be signed in to change notification settings - Fork 197
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
Establish the codegen-core
module
#1697
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d1246b5
Create the `codegen-core` module
jdisanti 46e65fe
Move the `Version` class into `codegen-core`
jdisanti ec29999
Rename `codegen` to `codegen-client`
jdisanti 8cf9929
Rename `codegen-test` to `codegen-client-test`
jdisanti 655d453
Merge remote-tracking branch 'origin/main' into jdisanti-codegen-core
jdisanti aa9c798
Move shared test models to common location
jdisanti 6c74dbf
Fix Smithy validation errors in `misc.smithy`
jdisanti bfbe259
Merge remote-tracking branch 'origin/main' into jdisanti-codegen-core
jdisanti b6e4bb5
Merge remote-tracking branch 'origin/main' into jdisanti-codegen-core
jdisanti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,16 +10,28 @@ import org.gradle.kotlin.dsl.register | |
import java.io.File | ||
|
||
/** | ||
* This file contains common functionality shared across the buildscripts for the `codegen-test` and `codegen-server-test` | ||
* modules. | ||
* This file contains common functionality shared across the build scripts for the | ||
* `codegen-client-test` and `codegen-server-test` modules. | ||
*/ | ||
|
||
data class CodegenTest(val service: String, val module: String, val extraConfig: String? = null) | ||
data class CodegenTest( | ||
val service: String, | ||
val module: String, | ||
val extraConfig: String? = null, | ||
val imports: List<String> = emptyList(), | ||
) | ||
|
||
fun generateImports(imports: List<String>): String = if (imports.isEmpty()) { | ||
"" | ||
} else { | ||
"\"imports\": [${imports.map { "\"$it\"" }.joinToString(", ")}]," | ||
} | ||
|
||
private fun generateSmithyBuild(projectDir: String, pluginName: String, tests: List<CodegenTest>): String { | ||
val projections = tests.joinToString(",\n") { | ||
""" | ||
"${it.module}": { | ||
${generateImports(it.imports)} | ||
"plugins": { | ||
"$pluginName": { | ||
"runtimeConfig": { | ||
|
@@ -31,8 +43,8 @@ private fun generateSmithyBuild(projectDir: String, pluginName: String, tests: L | |
"moduleDescription": "test", | ||
"moduleAuthors": ["[email protected]"] | ||
${it.extraConfig ?: ""} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
""".trimIndent() | ||
} | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
extra["displayName"] = "Smithy :: Rust :: Codegen :: Test" | ||
extra["moduleName"] = "software.amazon.smithy.kotlin.codegen.test" | ||
|
||
tasks["jar"].enabled = false | ||
|
||
plugins { | ||
val smithyGradlePluginVersion: String by project | ||
id("software.amazon.smithy").version(smithyGradlePluginVersion) | ||
} | ||
|
||
val smithyVersion: String by project | ||
val defaultRustDocFlags: String by project | ||
val properties = PropertyRetriever(rootProject, project) | ||
|
||
val pluginName = "rust-codegen" | ||
val workingDirUnderBuildDir = "smithyprojections/codegen-client-test/" | ||
|
||
buildscript { | ||
val smithyVersion: String by project | ||
dependencies { | ||
classpath("software.amazon.smithy:smithy-cli:$smithyVersion") | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(project(":codegen-client")) | ||
implementation("software.amazon.smithy:smithy-aws-protocol-tests:$smithyVersion") | ||
implementation("software.amazon.smithy:smithy-protocol-test-traits:$smithyVersion") | ||
implementation("software.amazon.smithy:smithy-aws-traits:$smithyVersion") | ||
} | ||
|
||
val allCodegenTests = "../codegen-core/common-test-models".let { commonModels -> | ||
listOf( | ||
CodegenTest("com.amazonaws.simple#SimpleService", "simple", imports = listOf("$commonModels/simple.smithy")), | ||
CodegenTest("com.amazonaws.dynamodb#DynamoDB_20120810", "dynamo"), | ||
CodegenTest("com.amazonaws.ebs#Ebs", "ebs", imports = listOf("$commonModels/ebs.json")), | ||
CodegenTest("aws.protocoltests.json10#JsonRpc10", "json_rpc10"), | ||
CodegenTest("aws.protocoltests.json#JsonProtocol", "json_rpc11"), | ||
CodegenTest("aws.protocoltests.restjson#RestJson", "rest_json"), | ||
CodegenTest("aws.protocoltests.restjson#RestJsonExtras", "rest_json_extras", imports = listOf("$commonModels/rest-json-extras.smithy")), | ||
CodegenTest("aws.protocoltests.misc#MiscService", "misc", imports = listOf("$commonModels/misc.smithy")), | ||
CodegenTest( | ||
"aws.protocoltests.restxml#RestXml", "rest_xml", | ||
extraConfig = """, "codegen": { "addMessageToErrors": false } """, | ||
), | ||
|
||
CodegenTest( | ||
"aws.protocoltests.query#AwsQuery", "aws_query", | ||
extraConfig = """, "codegen": { "addMessageToErrors": false } """, | ||
), | ||
CodegenTest( | ||
"aws.protocoltests.ec2#AwsEc2", "ec2_query", | ||
extraConfig = """, "codegen": { "addMessageToErrors": false } """, | ||
), | ||
CodegenTest( | ||
"aws.protocoltests.restxml.xmlns#RestXmlWithNamespace", | ||
"rest_xml_namespace", | ||
extraConfig = """, "codegen": { "addMessageToErrors": false } """, | ||
), | ||
CodegenTest( | ||
"aws.protocoltests.restxml#RestXmlExtras", | ||
"rest_xml_extras", | ||
extraConfig = """, "codegen": { "addMessageToErrors": false } """, | ||
), | ||
CodegenTest( | ||
"aws.protocoltests.restxmlunwrapped#RestXmlExtrasUnwrappedErrors", | ||
"rest_xml_extras_unwrapped", | ||
extraConfig = """, "codegen": { "addMessageToErrors": false } """, | ||
), | ||
CodegenTest( | ||
"crate#Config", | ||
"naming_test_ops", | ||
""" | ||
, "codegen": { "renameErrors": false } | ||
""".trimIndent(), | ||
imports = listOf("$commonModels/naming-obstacle-course-ops.smithy"), | ||
), | ||
CodegenTest( | ||
"naming_obs_structs#NamingObstacleCourseStructs", | ||
"naming_test_structs", | ||
""" | ||
, "codegen": { "renameErrors": false } | ||
""".trimIndent(), | ||
imports = listOf("$commonModels/naming-obstacle-course-structs.smithy"), | ||
), | ||
CodegenTest("com.aws.example#PokemonService", "pokemon-service-client", imports = listOf("$commonModels/pokemon.smithy")), | ||
) | ||
} | ||
|
||
project.registerGenerateSmithyBuildTask(rootProject, pluginName, allCodegenTests) | ||
project.registerGenerateCargoWorkspaceTask(rootProject, pluginName, allCodegenTests, workingDirUnderBuildDir) | ||
project.registerGenerateCargoConfigTomlTask(buildDir.resolve(workingDirUnderBuildDir)) | ||
|
||
tasks["smithyBuildJar"].dependsOn("generateSmithyBuild") | ||
tasks["assemble"].finalizedBy("generateCargoWorkspace") | ||
|
||
project.registerModifyMtimeTask() | ||
project.registerCargoCommandsTasks(buildDir.resolve(workingDirUnderBuildDir), defaultRustDocFlags) | ||
|
||
tasks["test"].finalizedBy(cargoCommands(properties).map { it.toString }) | ||
|
||
tasks["clean"].doFirst { delete("smithy-build.json") } |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import org.gradle.api.tasks.testing.logging.TestExceptionFormat | ||
|
||
plugins { | ||
kotlin("jvm") | ||
id("org.jetbrains.dokka") | ||
jacoco | ||
`maven-publish` | ||
} | ||
|
||
description = "Generates Rust client code from Smithy models" | ||
extra["displayName"] = "Smithy :: Rust :: CodegenClient" | ||
extra["moduleName"] = "software.amazon.smithy.rust.codegen.client" | ||
|
||
group = "software.amazon.smithy.rust.codegen" | ||
version = "0.1.0" | ||
|
||
val smithyVersion: String by project | ||
val kotestVersion: String by project | ||
|
||
dependencies { | ||
implementation(project(":codegen-core")) | ||
implementation(kotlin("stdlib-jdk8")) | ||
implementation("org.jsoup:jsoup:1.14.3") | ||
api("software.amazon.smithy:smithy-codegen-core:$smithyVersion") | ||
api("com.moandjiezana.toml:toml4j:0.7.2") | ||
implementation("software.amazon.smithy:smithy-aws-traits:$smithyVersion") | ||
implementation("software.amazon.smithy:smithy-protocol-test-traits:$smithyVersion") | ||
implementation("software.amazon.smithy:smithy-waiters:$smithyVersion") | ||
runtimeOnly(project(":rust-runtime")) | ||
testImplementation("org.junit.jupiter:junit-jupiter:5.6.1") | ||
testImplementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion") | ||
} | ||
|
||
tasks.compileTestKotlin { | ||
kotlinOptions.jvmTarget = "1.8" | ||
} | ||
|
||
tasks.compileKotlin { | ||
kotlinOptions.jvmTarget = "1.8" | ||
} | ||
|
||
// Reusable license copySpec | ||
val licenseSpec = copySpec { | ||
from("${project.rootDir}/LICENSE") | ||
from("${project.rootDir}/NOTICE") | ||
} | ||
|
||
// Configure jars to include license related info | ||
tasks.jar { | ||
metaInf.with(licenseSpec) | ||
inputs.property("moduleName", project.name) | ||
manifest { | ||
attributes["Automatic-Module-Name"] = project.name | ||
} | ||
} | ||
|
||
val sourcesJar by tasks.creating(Jar::class) { | ||
group = "publishing" | ||
description = "Assembles Kotlin sources jar" | ||
classifier = "sources" | ||
from(sourceSets.getByName("main").allSource) | ||
} | ||
|
||
tasks.test { | ||
useJUnitPlatform() | ||
testLogging { | ||
events("passed", "skipped", "failed") | ||
exceptionFormat = TestExceptionFormat.FULL | ||
showCauses = true | ||
showExceptions = true | ||
showStackTraces = true | ||
showStandardStreams = true | ||
} | ||
} | ||
|
||
tasks.dokka { | ||
outputFormat = "html" | ||
outputDirectory = "$buildDir/javadoc" | ||
} | ||
|
||
// Always build documentation | ||
tasks["build"].finalizedBy(tasks["dokka"]) | ||
|
||
// Configure jacoco (code coverage) to generate an HTML report | ||
tasks.jacocoTestReport { | ||
reports { | ||
xml.isEnabled = false | ||
csv.isEnabled = false | ||
html.destination = file("$buildDir/reports/jacoco") | ||
} | ||
} | ||
|
||
// Always run the jacoco test report after testing. | ||
tasks["test"].finalizedBy(tasks["jacocoTestReport"]) | ||
|
||
publishing { | ||
publications { | ||
create<MavenPublication>("default") { | ||
from(components["java"]) | ||
artifact(sourcesJar) | ||
} | ||
} | ||
repositories { maven { url = uri("$buildDir/repository") } } | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.