diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..5948671 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,6 @@ +allprojects { + repositories { + mavenLocal() + mavenCentral() + } +} diff --git a/custom-trait-examples/custom-annotation-trait/build.gradle.kts b/custom-trait-examples/custom-annotation-trait/build.gradle.kts index bab0a5a..69ac883 100644 --- a/custom-trait-examples/custom-annotation-trait/build.gradle.kts +++ b/custom-trait-examples/custom-annotation-trait/build.gradle.kts @@ -1,11 +1,9 @@ description = "A package used to define an annotation trait" plugins { - val smithyGradleVersion: String by project - `java-library` id("com.github.spotbugs").version("4.7.1") - id("software.amazon.smithy").version(smithyGradleVersion) + id("software.amazon.smithy.gradle.smithy-jar").version("0.8.0") } java { @@ -53,17 +51,10 @@ repositories { mavenCentral() } -buildscript { - val smithyVersion: String by project - - // Set the version of the CLI for the smithy gradle plugin to use when building this project - dependencies { - classpath("software.amazon.smithy:smithy-cli:$smithyVersion") - } -} - dependencies { val smithyVersion: String by project + smithyCli("software.amazon.smithy:smithy-cli:$smithyVersion") + implementation("software.amazon.smithy:smithy-model:$smithyVersion") -} \ No newline at end of file +} diff --git a/custom-trait-examples/custom-annotation-trait/model/custom-trait.smithy b/custom-trait-examples/custom-annotation-trait/model/custom-trait.smithy index d8ad533..ee2531f 100644 --- a/custom-trait-examples/custom-annotation-trait/model/custom-trait.smithy +++ b/custom-trait-examples/custom-annotation-trait/model/custom-trait.smithy @@ -3,4 +3,4 @@ $version: "2.0" namespace smithy.example @trait(selector: "structure") -structure special {} \ No newline at end of file +structure special {} diff --git a/custom-trait-examples/custom-string-trait/build.gradle.kts b/custom-trait-examples/custom-string-trait/build.gradle.kts index 7127cb4..f797ece 100644 --- a/custom-trait-examples/custom-string-trait/build.gradle.kts +++ b/custom-trait-examples/custom-string-trait/build.gradle.kts @@ -2,11 +2,9 @@ description = "Package for a custom Smithy string trait" plugins { - val smithyGradleVersion: String by project - `java-library` id("com.github.spotbugs").version("4.7.3") - id("software.amazon.smithy").version(smithyGradleVersion) + id("software.amazon.smithy.gradle.smithy-jar").version("0.8.0") } java { @@ -54,18 +52,11 @@ repositories { mavenCentral() } -buildscript { - val smithyVersion: String by project - - // Set the version of the CLI for the smithy gradle plugin to use when building this project - dependencies { - classpath("software.amazon.smithy:smithy-cli:$smithyVersion") - } -} - dependencies { val smithyVersion: String by project + smithyCli("software.amazon.smithy:smithy-cli:$smithyVersion") + implementation("software.amazon.smithy:smithy-model:$smithyVersion") testImplementation("org.junit.jupiter:junit-jupiter-api:5.4.0") diff --git a/custom-trait-examples/custom-string-trait/model/custom-trait.smithy b/custom-trait-examples/custom-string-trait/model/custom-trait.smithy index 6001727..a07532f 100644 --- a/custom-trait-examples/custom-string-trait/model/custom-trait.smithy +++ b/custom-trait-examples/custom-string-trait/model/custom-trait.smithy @@ -3,4 +3,4 @@ $version: "2.0" namespace io.smithy.example @trait(selector: "member") -string jsonName \ No newline at end of file +string jsonName diff --git a/custom-trait-examples/custom-structure-trait/build.gradle.kts b/custom-trait-examples/custom-structure-trait/build.gradle.kts index bfabd28..e7690e4 100644 --- a/custom-trait-examples/custom-structure-trait/build.gradle.kts +++ b/custom-trait-examples/custom-structure-trait/build.gradle.kts @@ -2,19 +2,9 @@ description = "Custom Smithy structure trait with multiple inputs" plugins { - val smithyGradleVersion: String by project `java-library` id("com.github.spotbugs").version("4.7.3") - id("software.amazon.smithy").version(smithyGradleVersion) -} - -buildscript { - val smithyVersion: String by project - - // Set the version of the CLI for the smithy gradle plugin to use when building this project - dependencies { - classpath("software.amazon.smithy:smithy-cli:$smithyVersion") - } + id("software.amazon.smithy.gradle.smithy-jar").version("0.8.0") } java { @@ -59,6 +49,9 @@ repositories { dependencies { val smithyVersion: String by project + + smithyCli("software.amazon.smithy:smithy-cli:$smithyVersion") + implementation("software.amazon.smithy:smithy-model:$smithyVersion") testImplementation("org.junit.jupiter:junit-jupiter-api:5.4.0") diff --git a/custom-trait-examples/custom-structure-trait/model/custom-trait.smithy b/custom-trait-examples/custom-structure-trait/model/custom-trait.smithy index 30e7fca..41b3822 100644 --- a/custom-trait-examples/custom-structure-trait/model/custom-trait.smithy +++ b/custom-trait-examples/custom-structure-trait/model/custom-trait.smithy @@ -3,13 +3,15 @@ $version: "2.0" namespace io.smithy.example @trait( - selector: "resource", - breakingChanges: [{change: "presence"}] + selector: "resource" + breakingChanges: [ + {change: "presence"} + ] ) structure resourceMetadata { /// Provides a custom name for your resource. @required - description: String, + description: String /// A type for the resource @required @@ -20,8 +22,8 @@ structure resourceMetadata { } enum ResourceType { - NORMAL, - SPECIAL, + NORMAL + SPECIAL NONE } @@ -29,4 +31,4 @@ enum ResourceType { list StructureIdList { @idRef(failWhenMissing: true, selector: "structure") member: String -} \ No newline at end of file +} diff --git a/custom-trait-examples/integ/custom-annotation-trait-test/build.gradle.kts b/custom-trait-examples/integ/custom-annotation-trait-test/build.gradle.kts index c4adf77..39179c2 100644 --- a/custom-trait-examples/integ/custom-annotation-trait-test/build.gradle.kts +++ b/custom-trait-examples/integ/custom-annotation-trait-test/build.gradle.kts @@ -1,27 +1,16 @@ plugins { - val smithyGradleVersion: String by project - - id("software.amazon.smithy").version(smithyGradleVersion) + id("java-library") + id("software.amazon.smithy.gradle.smithy-jar").version("0.8.0") } // The test project doesn't produce a JAR. tasks["jar"].enabled = false -repositories { - mavenLocal() - mavenCentral() -} - -buildscript { +dependencies { val smithyVersion: String by project - // Set the version of the CLI for the smithy gradle plugin to use when building this project - dependencies { - classpath("software.amazon.smithy:smithy-cli:$smithyVersion") - } -} + smithyCli("software.amazon.smithy:smithy-cli:$smithyVersion") -dependencies { implementation(project(":custom-trait-examples:custom-annotation-trait")) } diff --git a/custom-trait-examples/integ/custom-annotation-trait-test/model/main.smithy b/custom-trait-examples/integ/custom-annotation-trait-test/model/main.smithy index 37ad800..5046e13 100644 --- a/custom-trait-examples/integ/custom-annotation-trait-test/model/main.smithy +++ b/custom-trait-examples/integ/custom-annotation-trait-test/model/main.smithy @@ -8,4 +8,3 @@ use smithy.example#special structure MyStructure { myMember: String } - diff --git a/custom-trait-examples/integ/custom-string-trait-test/build.gradle.kts b/custom-trait-examples/integ/custom-string-trait-test/build.gradle.kts index 7b2f64d..10be1d5 100644 --- a/custom-trait-examples/integ/custom-string-trait-test/build.gradle.kts +++ b/custom-trait-examples/integ/custom-string-trait-test/build.gradle.kts @@ -1,28 +1,18 @@ plugins { - val smithyGradleVersion: String by project - - id("software.amazon.smithy").version(smithyGradleVersion) + id("java-library") + id("software.amazon.smithy.gradle.smithy-jar").version("0.8.0") } // The test project doesn't produce a JAR. tasks["jar"].enabled = false -repositories { - mavenLocal() - mavenCentral() -} -buildscript { +dependencies { val smithyVersion: String by project - // Set the version of the CLI for the smithy gradle plugin to use when building this project - dependencies { - classpath("software.amazon.smithy:smithy-cli:$smithyVersion") - } -} + smithyCli("software.amazon.smithy:smithy-cli:$smithyVersion") -dependencies { implementation(project(":custom-trait-examples:custom-string-trait")) } diff --git a/custom-trait-examples/integ/custom-string-trait-test/model/main.smithy b/custom-trait-examples/integ/custom-string-trait-test/model/main.smithy index 2d41d9b..92fc1cd 100644 --- a/custom-trait-examples/integ/custom-string-trait-test/model/main.smithy +++ b/custom-trait-examples/integ/custom-string-trait-test/model/main.smithy @@ -9,4 +9,3 @@ structure MyStructure { @jsonName("TESTING") myMember: String } - diff --git a/custom-trait-examples/integ/custom-structure-trait-test/build.gradle.kts b/custom-trait-examples/integ/custom-structure-trait-test/build.gradle.kts index 9eaa72a..d7119fd 100644 --- a/custom-trait-examples/integ/custom-structure-trait-test/build.gradle.kts +++ b/custom-trait-examples/integ/custom-structure-trait-test/build.gradle.kts @@ -1,28 +1,16 @@ plugins { - val smithyGradleVersion: String by project - - id("software.amazon.smithy").version(smithyGradleVersion) + id("java-library") + id("software.amazon.smithy.gradle.smithy-jar").version("0.8.0") } - // The test project doesn't produce a JAR. tasks["jar"].enabled = false -buildscript { +dependencies { val smithyVersion: String by project - // Set the version of the CLI for the smithy gradle plugin to use when building this project - dependencies { - classpath("software.amazon.smithy:smithy-cli:$smithyVersion") - } -} + smithyCli("software.amazon.smithy:smithy-cli:$smithyVersion") -repositories { - mavenLocal() - mavenCentral() -} - -dependencies { implementation(project(":custom-trait-examples:custom-structure-trait")) } diff --git a/custom-trait-examples/integ/custom-structure-trait-test/model/main.smithy b/custom-trait-examples/integ/custom-structure-trait-test/model/main.smithy index 03eed9b..4211d90 100644 --- a/custom-trait-examples/integ/custom-structure-trait-test/model/main.smithy +++ b/custom-trait-examples/integ/custom-structure-trait-test/model/main.smithy @@ -5,17 +5,14 @@ namespace example use io.smithy.example#resourceMetadata @resourceMetadata( - description: "woo", + description: "woo" type: "NORMAL" - associatedStructures: [ ForecastStruct ] + associatedStructures: [ForecastStruct] ) resource Forecast { - identifiers: { forecastId: ForecastId } + identifiers: {forecastId: ForecastId} } string ForecastId structure ForecastStruct {} - - - diff --git a/linting-and-validation-examples/common-linting-configuration/build.gradle.kts b/linting-and-validation-examples/common-linting-configuration/build.gradle.kts index c32fb57..389769e 100644 --- a/linting-and-validation-examples/common-linting-configuration/build.gradle.kts +++ b/linting-and-validation-examples/common-linting-configuration/build.gradle.kts @@ -1,18 +1,8 @@ description = "A package used to share a common linting configuration between smithy projects" plugins { - val smithyGradleVersion: String by project - - id("software.amazon.smithy").version(smithyGradleVersion) -} - -buildscript { - val smithyVersion: String by project - - // Set the version of the CLI for the smithy gradle plugin to use when building this project - dependencies { - classpath("software.amazon.smithy:smithy-cli:$smithyVersion") - } + id("java-library") + id("software.amazon.smithy.gradle.smithy-jar").version("0.8.0") } repositories { @@ -23,9 +13,10 @@ repositories { dependencies { val smithyVersion: String by project + smithyCli("software.amazon.smithy:smithy-cli:$smithyVersion") implementation("software.amazon.smithy:smithy-linters:$smithyVersion") } smithy { - tags = setOf("validators", "common-config") + tags.addAll("validators", "common-config") } diff --git a/linting-and-validation-examples/common-linting-configuration/model/validators.smithy b/linting-and-validation-examples/common-linting-configuration/model/validators.smithy index f5c80d9..95b43a1 100644 --- a/linting-and-validation-examples/common-linting-configuration/model/validators.smithy +++ b/linting-and-validation-examples/common-linting-configuration/model/validators.smithy @@ -3,94 +3,92 @@ $version: "2.0" // The validators used here are either built-in linters (see: https://smithy.io/2.0/guides/model-linters.html#linters-in-smithy-linters) // or they are from the following guide:https://smithy.io/2.0/guides/model-validation-examples.html metadata validators = [ - {name: "AbbreviationName", - severity: "WARNING" - }, - {name: "CamelCase", - severity: "WARNING" - }, - {name: "MissingSensitiveTrait", - severity: "WARNING", - configuration: { - excludeDefaults: false, - terms: ["spork"] - }}, + {name: "AbbreviationName", severity: "WARNING"} + {name: "CamelCase", severity: "WARNING"} + { + name: "MissingSensitiveTrait" + severity: "WARNING" + configuration: { + excludeDefaults: false + terms: ["spork"] + } + } // Enforce a common naming scheme for operation inputs { - name: "EmitEachSelector", - severity: "WARNING", - id: "OperationInputName", + name: "EmitEachSelector" + severity: "WARNING" + id: "OperationInputName" configuration: { messageTemplate: """ - `@{id}` is bound as an input of `@{var|operation|id}` \ - but does not have a name ending with 'Request'. - """, + `@{id}` is bound as an input of `@{var|operation|id}` \ + but does not have a name ending with 'Request'. + """ selector: "$operation(*) -[input]-> :not([id|name$=Request])" } - }, + } // Enforce a common naming scheme for errors { - name: "EmitEachSelector", - severity: "WARNING", - id: "OperationErrorName", + name: "EmitEachSelector" + severity: "WARNING" + id: "OperationErrorName" configuration: { messageTemplate: """ - `@{id}` is bound as an error but does not have a name ending with 'Exception'. \ - Perhaps you should rename this shape to `@{id|name}Exception`. - """, + `@{id}` is bound as an error but does not have a name ending with 'Exception'. \ + Perhaps you should rename this shape to `@{id|name}Exception`. + """ selector: "operation -[error]-> :not([id|name$=Exception])" } - }, + } // Require integers to have range min and max specified { - name: "EmitEachSelector", - severity: "WARNING", - id: "RawIntegerWithoutRange", + name: "EmitEachSelector" + severity: "WARNING" + id: "RawIntegerWithoutRange" configuration: { messageTemplate: """ - This number shape in member `@{id}` of the operation input `@{var|structure}` \ - does not have a range constraint on both its minimum or maximum value. \ - Add the `@@range` trait to this integer shape and provide both minimum and maximum values. \ - For example, `@@range(min: 1, max: 500)`. - """, + This number shape in member `@{id}` of the operation input `@{var|structure}` \ + does not have a range constraint on both its minimum or maximum value. \ + Add the `@@range` trait to this integer shape and provide both minimum and maximum values. \ + For example, `@@range(min: 1, max: 500)`. + """ selector: """ - operation -[input]-> $structure(*) > member - :test(> number:not([trait|range|min]):not([trait|range|max])) - """ + operation -[input]-> $structure(*) > member + :test(> number:not([trait|range|min]):not([trait|range|max])) + """ } - }, + } { - name: "EmitEachSelector", - severity: "WARNING", - id: "RawIntegerWithoutRangeMin", + name: "EmitEachSelector" + severity: "WARNING" + id: "RawIntegerWithoutRangeMin" configuration: { messageTemplate: """ - This number shape in member `@{id}` of the operation input `@{var|structure}` \ - does not have a maximum range constraint. \ - Add a minimum value to the `@@range` trait on this shape. \ - For example, `@@range(>>> min: 1 <<<, max: 500)`. - """, + This number shape in member `@{id}` of the operation input `@{var|structure}` \ + does not have a maximum range constraint. \ + Add a minimum value to the `@@range` trait on this shape. \ + For example, `@@range(>>> min: 1 <<<, max: 500)`. + """ selector: """ - operation -[input]-> $structure(*) > member - :test(> number[trait|range]:not([trait|range|min])) - """ + operation -[input]-> $structure(*) > member + :test(> number[trait|range]:not([trait|range|min])) + """ } - }, + } { - name: "EmitEachSelector", - severity: "WARNING", - id: "RawIntegerWithoutRangeMax", + name: "EmitEachSelector" + severity: "WARNING" + id: "RawIntegerWithoutRangeMax" configuration: { messageTemplate: """ - This number shape in member `@{id}` of the operation input `@{var|structure}` \ - does not have a maximum range constraint. \ - Add a maximum value to the `@@range` trait on this shape. \ - For example, `@@range(min: 1, >>> max: 500 <<<)`. - """, + This number shape in member `@{id}` of the operation input `@{var|structure}` \ + does not have a maximum range constraint. \ + Add a maximum value to the `@@range` trait on this shape. \ + For example, `@@range(min: 1, >>> max: 500 <<<)`. + """ selector: """ - operation -[input]-> $structure(*) > member - :test(> number[trait|range]:not([trait|range|max])) - """ + operation -[input]-> $structure(*) > member + :test(> number[trait|range]:not([trait|range|max])) + """ } } ] diff --git a/linting-and-validation-examples/custom-validator/build.gradle.kts b/linting-and-validation-examples/custom-validator/build.gradle.kts index e2fdbb9..004e665 100644 --- a/linting-and-validation-examples/custom-validator/build.gradle.kts +++ b/linting-and-validation-examples/custom-validator/build.gradle.kts @@ -2,10 +2,9 @@ description = "Creates a custom Smithy model validator" plugins { - val smithyGradleVersion: String by project `java-library` id("com.github.spotbugs").version("4.7.3") - id("software.amazon.smithy").version(smithyGradleVersion) + id("software.amazon.smithy.gradle.smithy-jar").version("0.8.0") } java { @@ -47,18 +46,10 @@ repositories { mavenCentral() } -buildscript { - val smithyVersion: String by project - - // Set the version of the CLI for the smithy gradle plugin to use when building this project - dependencies { - classpath("software.amazon.smithy:smithy-cli:$smithyVersion") - } -} - dependencies { val smithyVersion: String by project + smithyCli("software.amazon.smithy:smithy-cli:$smithyVersion") implementation("software.amazon.smithy:smithy-model:$smithyVersion") testImplementation("org.junit.jupiter:junit-jupiter-api:5.4.0") diff --git a/linting-and-validation-examples/integ/common-linting-configuration-test/build.gradle.kts b/linting-and-validation-examples/integ/common-linting-configuration-test/build.gradle.kts index 0cb51ef..b091d0d 100644 --- a/linting-and-validation-examples/integ/common-linting-configuration-test/build.gradle.kts +++ b/linting-and-validation-examples/integ/common-linting-configuration-test/build.gradle.kts @@ -1,19 +1,11 @@ -import software.amazon.smithy.gradle.tasks.SmithyBuild plugins { - val smithyGradleVersion: String by project - - id("software.amazon.smithy").version(smithyGradleVersion) + id("java-library") + id("software.amazon.smithy.gradle.smithy-jar").version("0.8.0") } - // The test project doesn't produce a JAR. tasks["jar"].enabled = false -tasks["smithyBuildJar"].enabled = false - -tasks.create("buildPackage") { - addRuntimeClasspath = true -} tasks.named("test") { useJUnitPlatform() @@ -22,26 +14,13 @@ tasks.named("test") { systemProperty("projectUnderTest", project(":linting-and-validation-examples:common-linting-configuration").buildDir.absolutePath) } -tasks["test"].dependsOn(tasks["buildPackage"]) - - -buildscript { - val smithyVersion: String by project - - // Set the version of the CLI for the smithy gradle plugin to use when building this project - dependencies { - classpath("software.amazon.smithy:smithy-cli:$smithyVersion") - } -} - -repositories { - mavenLocal() - mavenCentral() -} +tasks["test"].dependsOn(tasks["smithyBuild"]) dependencies { val smithyVersion: String by project + smithyCli("software.amazon.smithy:smithy-cli:$smithyVersion") + implementation(project(":linting-and-validation-examples:common-linting-configuration")) implementation("software.amazon.smithy:smithy-linters:$smithyVersion") diff --git a/linting-and-validation-examples/integ/common-linting-configuration-test/model/main.smithy b/linting-and-validation-examples/integ/common-linting-configuration-test/model/main.smithy index 76da658..30d2bf8 100644 --- a/linting-and-validation-examples/integ/common-linting-configuration-test/model/main.smithy +++ b/linting-and-validation-examples/integ/common-linting-configuration-test/model/main.smithy @@ -11,10 +11,11 @@ string shouldbecamelcase // Fails the `MissingSensitiveTrait` linter string Ssn - operation MyOperation { input: BadlyNamedOperationInput - errors: [BadlyName404] + errors: [ + BadlyName404 + ] } // This will fail the `OperationInputName` validator diff --git a/linting-and-validation-examples/integ/custom-linter-test/build.gradle.kts b/linting-and-validation-examples/integ/custom-linter-test/build.gradle.kts index 6fc6a38..82458f8 100644 --- a/linting-and-validation-examples/integ/custom-linter-test/build.gradle.kts +++ b/linting-and-validation-examples/integ/custom-linter-test/build.gradle.kts @@ -1,18 +1,12 @@ plugins { - val smithyGradleVersion: String by project - - id("software.amazon.smithy").version(smithyGradleVersion) + id("java-library") + id("software.amazon.smithy.gradle.smithy-jar").version("0.8.0") } // The test project doesn't produce a JAR. tasks["jar"].enabled = false -tasks["smithyBuildJar"].enabled = false - -tasks.create("buildPackage") { - addRuntimeClasspath = true -} tasks.named("test") { useJUnitPlatform() @@ -21,25 +15,13 @@ tasks.named("test") { systemProperty("projectUnderTest", project(":linting-and-validation-examples:custom-linter").buildDir.absolutePath) } -tasks["test"].dependsOn(tasks["buildPackage"]) - -buildscript { - val smithyVersion: String by project - - // Set the version of the CLI for the smithy gradle plugin to use when building this project - dependencies { - classpath("software.amazon.smithy:smithy-cli:$smithyVersion") - } -} - -repositories { - mavenLocal() - mavenCentral() -} +tasks["test"].dependsOn(tasks["smithyBuild"]) dependencies { val smithyVersion: String by project + smithyCli("software.amazon.smithy:smithy-cli:$smithyVersion") + implementation(project(":linting-and-validation-examples:custom-linter")) testImplementation("software.amazon.smithy:smithy-model:$smithyVersion") diff --git a/linting-and-validation-examples/integ/custom-linter-test/model/main.smithy b/linting-and-validation-examples/integ/custom-linter-test/model/main.smithy index 0d8b23f..77f38b2 100644 --- a/linting-and-validation-examples/integ/custom-linter-test/model/main.smithy +++ b/linting-and-validation-examples/integ/custom-linter-test/model/main.smithy @@ -15,4 +15,3 @@ namespace example // This will fail the `ForbiddedDocumentation` validator @documentation("meow is your time!") string BadAbbreviationShapeID - diff --git a/linting-and-validation-examples/integ/custom-validator-test/build.gradle.kts b/linting-and-validation-examples/integ/custom-validator-test/build.gradle.kts index 722349a..c92d222 100644 --- a/linting-and-validation-examples/integ/custom-validator-test/build.gradle.kts +++ b/linting-and-validation-examples/integ/custom-validator-test/build.gradle.kts @@ -1,18 +1,12 @@ plugins { - val smithyGradleVersion: String by project - - id("software.amazon.smithy").version(smithyGradleVersion) + id("java-library") + id("software.amazon.smithy.gradle.smithy-jar").version("0.8.0") } // The test project doesn't produce a JAR. tasks["jar"].enabled = false -tasks["smithyBuildJar"].enabled = false - -tasks.create("buildPackage") { - addRuntimeClasspath = true -} tasks.named("test") { useJUnitPlatform() @@ -21,26 +15,13 @@ tasks.named("test") { systemProperty("projectUnderTest", project(":linting-and-validation-examples:custom-validator").buildDir.absolutePath) } -tasks["test"].dependsOn(tasks["buildPackage"]) - - -repositories { - mavenLocal() - mavenCentral() -} - -buildscript { - val smithyVersion: String by project - - // Set the version of the CLI for the smithy gradle plugin to use when building this project - dependencies { - classpath("software.amazon.smithy:smithy-cli:$smithyVersion") - } -} +tasks["test"].dependsOn(tasks["smithyBuild"]) dependencies { val smithyVersion: String by project + smithyCli("software.amazon.smithy:smithy-cli:$smithyVersion") + implementation(project(":linting-and-validation-examples:custom-validator")) testImplementation("software.amazon.smithy:smithy-model:$smithyVersion") diff --git a/linting-and-validation-examples/integ/custom-validator-test/model/main.smithy b/linting-and-validation-examples/integ/custom-validator-test/model/main.smithy index 4a82307..216c907 100644 --- a/linting-and-validation-examples/integ/custom-validator-test/model/main.smithy +++ b/linting-and-validation-examples/integ/custom-validator-test/model/main.smithy @@ -4,4 +4,3 @@ namespace example // This will fail the `Documentation` validator string BadAbbreviationShapeID - diff --git a/linting-and-validation-examples/integ/decorators-test/build.gradle.kts b/linting-and-validation-examples/integ/decorators-test/build.gradle.kts index eb1c86e..21d7542 100644 --- a/linting-and-validation-examples/integ/decorators-test/build.gradle.kts +++ b/linting-and-validation-examples/integ/decorators-test/build.gradle.kts @@ -4,6 +4,7 @@ plugins { // Apply the maven publish to publish your package to maven repositories `maven-publish` } + // The test project doesn't produce a JAR. tasks["jar"].enabled = false diff --git a/quickstart-examples/quickstart-gradle/build.gradle.kts b/quickstart-examples/quickstart-gradle/build.gradle.kts index 0f82933..74c4c5e 100644 --- a/quickstart-examples/quickstart-gradle/build.gradle.kts +++ b/quickstart-examples/quickstart-gradle/build.gradle.kts @@ -1,16 +1,6 @@ plugins { - val smithyGradleVersion: String by project - - id("software.amazon.smithy").version(smithyGradleVersion) -} - -buildscript { - val smithyVersion: String by project - - // Set the version of the CLI for the smithy gradle plugin to use when building this project - dependencies { - classpath("software.amazon.smithy:smithy-cli:$smithyVersion") - } + id("java-library") + id("software.amazon.smithy.gradle.smithy-jar").version("0.8.0") } repositories { @@ -21,6 +11,8 @@ repositories { dependencies { val smithyVersion: String by project + smithyCli("software.amazon.smithy:smithy-cli:$smithyVersion") + // Uncomment below to add various smithy dependencies (see full list of smithy dependencies in https://github.com/awslabs/smithy) // implementation("software.amazon.smithy:smithy-model:$smithyVersion") // implementation("software.amazon.smithy:smithy-linters:$smithyVersion") diff --git a/quickstart-examples/quickstart-gradle/gradle.properties b/quickstart-examples/quickstart-gradle/gradle.properties index cacdb20..dc3a78f 100644 --- a/quickstart-examples/quickstart-gradle/gradle.properties +++ b/quickstart-examples/quickstart-gradle/gradle.properties @@ -1,2 +1 @@ smithyVersion=1.37.0 -smithyGradleVersion=0.7.0 \ No newline at end of file diff --git a/quickstart-examples/quickstart-gradle/gradle/wrapper/gradle-wrapper.properties b/quickstart-examples/quickstart-gradle/gradle/wrapper/gradle-wrapper.properties index 75668a3..17a8ddc 100644 --- a/quickstart-examples/quickstart-gradle/gradle/wrapper/gradle-wrapper.properties +++ b/quickstart-examples/quickstart-gradle/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/shared-model-examples/common-shapes/build.gradle.kts b/shared-model-examples/common-shapes/build.gradle.kts index baa4a4d..5ea51c1 100644 --- a/shared-model-examples/common-shapes/build.gradle.kts +++ b/shared-model-examples/common-shapes/build.gradle.kts @@ -2,9 +2,8 @@ description = "A package used to share common shapes between smithy projects" plugins { - val smithyGradleVersion: String by project `java-library` - id("software.amazon.smithy").version(smithyGradleVersion) + id("software.amazon.smithy.gradle.smithy-jar").version("0.8.0") } repositories { @@ -12,26 +11,18 @@ repositories { mavenCentral() } -buildscript { - val smithyVersion: String by project - - // Set the version of the CLI for the smithy gradle plugin to use when building this project - dependencies { - classpath("software.amazon.smithy:smithy-cli:$smithyVersion") - classpath("software.amazon.smithy:smithy-linters:$smithyVersion") - } -} - // use the `package` projection to filter out validators so downstream consumers are not // force to use them. smithy { - projection = "package" + sourceProjection.set("package") // Set tags so other smithy packages can include this in their built packages - tags = setOf("common", "example") + tags.addAll("common", "example") } dependencies { val smithyVersion: String by project + + smithyCli("software.amazon.smithy:smithy-cli:$smithyVersion") implementation("software.amazon.smithy:smithy-linters:$smithyVersion") } diff --git a/shared-model-examples/common-shapes/model/common-enums.smithy b/shared-model-examples/common-shapes/model/common-enums.smithy index 955dd10..fc2b980 100644 --- a/shared-model-examples/common-shapes/model/common-enums.smithy +++ b/shared-model-examples/common-shapes/model/common-enums.smithy @@ -3,18 +3,17 @@ $version: "2.0" namespace example.common.enums enum IpAddressVersion { - V4, + V4 V6 } /// Example country code list with just a few entries enum CountryCode { - AF = "Afgahanistan", - BR = "Brazil", - GB = "United Kingdom", - US = "United States", - MV = "Maldives", - TV = "Tuvalu", + AF = "Afgahanistan" + BR = "Brazil" + GB = "United Kingdom" + US = "United States" + MV = "Maldives" + TV = "Tuvalu" VE = "Venezuela" } - diff --git a/shared-model-examples/common-shapes/model/common-string-shapes.smithy b/shared-model-examples/common-shapes/model/common-string-shapes.smithy index ebd98f9..97520b0 100644 --- a/shared-model-examples/common-shapes/model/common-string-shapes.smithy +++ b/shared-model-examples/common-shapes/model/common-string-shapes.smithy @@ -9,4 +9,3 @@ string IpV4Address @pattern("^[ a-zA-Z0-9_:-]{1,256}$") @length(min: 1, max: 256) string AlphaNumericName - diff --git a/shared-model-examples/common-shapes/model/validators.smithy b/shared-model-examples/common-shapes/model/validators.smithy index 6674494..f972ea2 100644 --- a/shared-model-examples/common-shapes/model/validators.smithy +++ b/shared-model-examples/common-shapes/model/validators.smithy @@ -1,124 +1,124 @@ $version: "2.0" metadata validators = [ - {name: "AbbreviationName"}, - {name: "CamelCase"}, - {name: "NoninclusiveTerms"}, - {name: "RepeatedShapeName"}, - {name: "ShouldHaveUsedTimestamp"}, + {name: "AbbreviationName"} + {name: "CamelCase"} + {name: "NoninclusiveTerms"} + {name: "RepeatedShapeName"} + {name: "ShouldHaveUsedTimestamp"} // Require range for integers { - name: "EmitEachSelector", - id: "RawIntegerWithoutRange", + name: "EmitEachSelector" + id: "RawIntegerWithoutRange" configuration: { messageTemplate: """ - This number shape in member `@{id}` of the operation input `@{var|structure}` \ - does not have a range constraint on both its minimum or maximum value. \ - Add the `@@range` trait to this integer shape and provide both minimum and maximum values. \ - For example, `@@range(min: 1, max: 500)`. - """, + This number shape in member `@{id}` of the operation input `@{var|structure}` \ + does not have a range constraint on both its minimum or maximum value. \ + Add the `@@range` trait to this integer shape and provide both minimum and maximum values. \ + For example, `@@range(min: 1, max: 500)`. + """ selector: """ - operation -[input]-> $structure(*) > member - :test(> number:not([trait|range|min]):not([trait|range|max])) - """ + operation -[input]-> $structure(*) > member + :test(> number:not([trait|range|min]):not([trait|range|max])) + """ } - }, + } { - name: "EmitEachSelector", - id: "RawIntegerWithoutRangeMin", + name: "EmitEachSelector" + id: "RawIntegerWithoutRangeMin" configuration: { messageTemplate: """ - This number shape in member `@{id}` of the operation input `@{var|structure}` \ - does not have a maximum range constraint. \ - Add a minimum value to the `@@range` trait on this shape. \ - For example, `@@range(>>> min: 1 <<<, max: 500)`. - """, + This number shape in member `@{id}` of the operation input `@{var|structure}` \ + does not have a maximum range constraint. \ + Add a minimum value to the `@@range` trait on this shape. \ + For example, `@@range(>>> min: 1 <<<, max: 500)`. + """ selector: """ - operation -[input]-> $structure(*) > member - :test(> number[trait|range]:not([trait|range|min])) - """ + operation -[input]-> $structure(*) > member + :test(> number[trait|range]:not([trait|range|min])) + """ } - }, + } { - name: "EmitEachSelector", - id: "RawIntegerWithoutRangeMax", + name: "EmitEachSelector" + id: "RawIntegerWithoutRangeMax" configuration: { messageTemplate: """ - This number shape in member `@{id}` of the operation input `@{var|structure}` \ - does not have a maximum range constraint. \ - Add a maximum value to the `@@range` trait on this shape. \ - For example, `@@range(min: 1, >>> max: 500 <<<)`. - """, + This number shape in member `@{id}` of the operation input `@{var|structure}` \ + does not have a maximum range constraint. \ + Add a maximum value to the `@@range` trait on this shape. \ + For example, `@@range(min: 1, >>> max: 500 <<<)`. + """ selector: """ - operation -[input]-> $structure(*) > member - :test(> number[trait|range]:not([trait|range|max])) - """ + operation -[input]-> $structure(*) > member + :test(> number[trait|range]:not([trait|range|max])) + """ } - }, + } // Require limits on all lists { - name: "EmitEachSelector", - id: "ListWithoutLengthConstraint", + name: "EmitEachSelector" + id: "ListWithoutLengthConstraint" configuration: { messageTemplate: """ - List shape `@{id}` does not have a length constraint specified. \ - Add the `@@length` trait to the list shape. For example, `@@length(min: 1, max: 2)`. - """, + List shape `@{id}` does not have a length constraint specified. \ + Add the `@@length` trait to the list shape. For example, `@@length(min: 1, max: 2)`. + """ selector: "list:not([trait|length])" } - }, + } { - name: "EmitEachSelector", - id: "ListWithoutLengthConstraintMinimum", + name: "EmitEachSelector" + id: "ListWithoutLengthConstraintMinimum" configuration: { messageTemplate: """ - List shape `@{id}` does not have a minimum length specified. \ - Add a `min` value to the `@@length` trait on the list shape. \ - For example, `@@length(>>> min: 1 <<<, max: 2)`. - """, + List shape `@{id}` does not have a minimum length specified. \ + Add a `min` value to the `@@length` trait on the list shape. \ + For example, `@@length(>>> min: 1 <<<, max: 2)`. + """ selector: "list[trait|length]:not([trait|length|min])" } - }, + } { - name: "EmitEachSelector", - id: "ListWithoutLengthConstraintMaximum", + name: "EmitEachSelector" + id: "ListWithoutLengthConstraintMaximum" configuration: { messageTemplate: """ - List shape `@{id}` does not have a maximum length specified. \ - Add a `max` value to the `@@length` trait on the list shape. \ - For example, `@@length(min: 1, >>> max: 2 <<<)`. - """, + List shape `@{id}` does not have a maximum length specified. \ + Add a `max` value to the `@@length` trait on the list shape. \ + For example, `@@length(min: 1, >>> max: 2 <<<)`. + """ selector: "list[trait|length]:not([trait|length|max])" } - }, + } // Require strings to have a pattern constraint { - name: "EmitEachSelector", - id: "RawStringWithoutPattern", - namespaces: ["example.common"], + name: "EmitEachSelector" + id: "RawStringWithoutPattern" + namespaces: ["example.common"] configuration: { messageTemplate: """ - This String shape in member `@{id}` of the operation input `@{var|structure}` \ - does not have a pattern constraint. \ - Add the `@@pattern` trait to this string shape and provide a regex pattern. \ - For example, `@@pattern("^[\\S\\s]+$")`. - """, + This String shape in member `@{id}` of the operation input `@{var|structure}` \ + does not have a pattern constraint. \ + Add the `@@pattern` trait to this string shape and provide a regex pattern. \ + For example, `@@pattern("^[\\S\\s]+$")`. + """ selector: """ - operation -[input]-> $structure(*) > member - :test(> string:not([trait|enum]):not([trait|pattern])) - """ + operation -[input]-> $structure(*) > member + :test(> string:not([trait|enum]):not([trait|pattern])) + """ } - }, + } // Limit shape name length { name: "EmitEachSelector" - id: "ShapeNameLength", - namespaces: ["example.common"], + id: "ShapeNameLength" + namespaces: ["example.common"] configuration: { messageTemplate: """ - Shape name @{id|name} is @{id|name|(length)} characters long. - Shape names must be less than 60 characters and longer than 3 characters. - """, + Shape name @{id|name} is @{id|name|(length)} characters long. + Shape names must be less than 60 characters and longer than 3 characters. + """ selector: ":not([@id|name: @{(length)} <= 60 && @{(length)} >= 3])" } } diff --git a/shared-model-examples/integ/build.gradle.kts b/shared-model-examples/integ/build.gradle.kts index ede33bf..5a646d2 100644 --- a/shared-model-examples/integ/build.gradle.kts +++ b/shared-model-examples/integ/build.gradle.kts @@ -1,29 +1,14 @@ plugins { - val smithyGradleVersion: String by project - - id("software.amazon.smithy").version(smithyGradleVersion) + id("java-library") + id("software.amazon.smithy.gradle.smithy-jar").version("0.8.0") } - // The test project doesn't produce a JAR. tasks["jar"].enabled = false -repositories { - mavenLocal() - mavenCentral() -} - -buildscript { - val smithyVersion: String by project - - // Set the version of the CLI for the smithy gradle plugin to use when building this project - dependencies { - classpath("software.amazon.smithy:smithy-cli:$smithyVersion") - } -} - dependencies { val smithyVersion: String by project + smithyCli("software.amazon.smithy:smithy-cli:$smithyVersion") implementation(project(":shared-model-examples:common-shapes")) }