From 562bffb13ca9c5f61e949166dfec46262f5a09fb Mon Sep 17 00:00:00 2001 From: Hunter Mellema <124718352+hpmellema@users.noreply.github.com> Date: Thu, 11 Jul 2024 10:46:38 -0600 Subject: [PATCH] Rename trait codegen plugin back to package from module (#141) --- .../create-simple-trait/README.md | 0 .../create-simple-trait/build.gradle.kts | 2 +- .../create-simple-trait/model/custom-trait.smithy | 0 .../create-simple-trait/settings.gradle.kts | 0 .../create-simple-trait/smithy-build.json | 0 .../use-with-existing-trait/README.md | 0 .../use-with-existing-trait/build.gradle.kts | 2 +- .../use-with-existing-trait/model/custom-trait.smithy | 0 .../use-with-existing-trait/settings.gradle.kts | 0 .../use-with-existing-trait/smithy-build.json | 0 .../smithy/gradle/examples/traits/JsonNameTrait.java | 0 .../software.amazon.smithy.model.traits.TraitService | 0 settings.gradle.kts | 2 +- .../build.gradle.kts | 6 +++--- .../amazon/smithy/gradle/CreatesCustomTraitTest.java | 2 +- .../amazon/smithy/gradle/RespectsManualTraitTest.java | 2 +- .../smithy/gradle/SmithyTraitPackagePlugin.java | 11 +++++------ .../amazon/smithy/gradle/tasks/MergeSpiFilesTask.java | 0 18 files changed, 13 insertions(+), 14 deletions(-) rename examples/{trait-module-plugin => trait-package-plugin}/create-simple-trait/README.md (100%) rename examples/{trait-module-plugin => trait-package-plugin}/create-simple-trait/build.gradle.kts (78%) rename examples/{trait-module-plugin => trait-package-plugin}/create-simple-trait/model/custom-trait.smithy (100%) rename examples/{trait-module-plugin => trait-package-plugin}/create-simple-trait/settings.gradle.kts (100%) rename examples/{trait-module-plugin => trait-package-plugin}/create-simple-trait/smithy-build.json (100%) rename examples/{trait-module-plugin => trait-package-plugin}/use-with-existing-trait/README.md (100%) rename examples/{trait-module-plugin => trait-package-plugin}/use-with-existing-trait/build.gradle.kts (75%) rename examples/{trait-module-plugin => trait-package-plugin}/use-with-existing-trait/model/custom-trait.smithy (100%) rename examples/{trait-module-plugin => trait-package-plugin}/use-with-existing-trait/settings.gradle.kts (100%) rename examples/{trait-module-plugin => trait-package-plugin}/use-with-existing-trait/smithy-build.json (100%) rename examples/{trait-module-plugin => trait-package-plugin}/use-with-existing-trait/src/main/java/io/smithy/gradle/examples/traits/JsonNameTrait.java (100%) rename examples/{trait-module-plugin => trait-package-plugin}/use-with-existing-trait/src/main/resources/META-INF/services/software.amazon.smithy.model.traits.TraitService (100%) rename {smithy-trait-module => smithy-trait-package}/build.gradle.kts (82%) rename {smithy-trait-module => smithy-trait-package}/src/it/java/software/amazon/smithy/gradle/CreatesCustomTraitTest.java (95%) rename {smithy-trait-module => smithy-trait-package}/src/it/java/software/amazon/smithy/gradle/RespectsManualTraitTest.java (95%) rename smithy-trait-module/src/main/java/software/amazon/smithy/gradle/SmithyTraitModulePlugin.java => smithy-trait-package/src/main/java/software/amazon/smithy/gradle/SmithyTraitPackagePlugin.java (92%) rename {smithy-trait-module => smithy-trait-package}/src/main/java/software/amazon/smithy/gradle/tasks/MergeSpiFilesTask.java (100%) diff --git a/examples/trait-module-plugin/create-simple-trait/README.md b/examples/trait-package-plugin/create-simple-trait/README.md similarity index 100% rename from examples/trait-module-plugin/create-simple-trait/README.md rename to examples/trait-package-plugin/create-simple-trait/README.md diff --git a/examples/trait-module-plugin/create-simple-trait/build.gradle.kts b/examples/trait-package-plugin/create-simple-trait/build.gradle.kts similarity index 78% rename from examples/trait-module-plugin/create-simple-trait/build.gradle.kts rename to examples/trait-package-plugin/create-simple-trait/build.gradle.kts index 4209b2c..b03cde8 100644 --- a/examples/trait-module-plugin/create-simple-trait/build.gradle.kts +++ b/examples/trait-package-plugin/create-simple-trait/build.gradle.kts @@ -1,7 +1,7 @@ description = "Custom Smithy structure trait with multiple inputs" plugins { - id("software.amazon.smithy.gradle.smithy-trait-module") version "1.0.0" + id("software.amazon.smithy.gradle.smithy-trait-package") version "1.0.0" } group = "software.amazon.smithy" diff --git a/examples/trait-module-plugin/create-simple-trait/model/custom-trait.smithy b/examples/trait-package-plugin/create-simple-trait/model/custom-trait.smithy similarity index 100% rename from examples/trait-module-plugin/create-simple-trait/model/custom-trait.smithy rename to examples/trait-package-plugin/create-simple-trait/model/custom-trait.smithy diff --git a/examples/trait-module-plugin/create-simple-trait/settings.gradle.kts b/examples/trait-package-plugin/create-simple-trait/settings.gradle.kts similarity index 100% rename from examples/trait-module-plugin/create-simple-trait/settings.gradle.kts rename to examples/trait-package-plugin/create-simple-trait/settings.gradle.kts diff --git a/examples/trait-module-plugin/create-simple-trait/smithy-build.json b/examples/trait-package-plugin/create-simple-trait/smithy-build.json similarity index 100% rename from examples/trait-module-plugin/create-simple-trait/smithy-build.json rename to examples/trait-package-plugin/create-simple-trait/smithy-build.json diff --git a/examples/trait-module-plugin/use-with-existing-trait/README.md b/examples/trait-package-plugin/use-with-existing-trait/README.md similarity index 100% rename from examples/trait-module-plugin/use-with-existing-trait/README.md rename to examples/trait-package-plugin/use-with-existing-trait/README.md diff --git a/examples/trait-module-plugin/use-with-existing-trait/build.gradle.kts b/examples/trait-package-plugin/use-with-existing-trait/build.gradle.kts similarity index 75% rename from examples/trait-module-plugin/use-with-existing-trait/build.gradle.kts rename to examples/trait-package-plugin/use-with-existing-trait/build.gradle.kts index 02dbac0..4e39d90 100644 --- a/examples/trait-module-plugin/use-with-existing-trait/build.gradle.kts +++ b/examples/trait-package-plugin/use-with-existing-trait/build.gradle.kts @@ -1,7 +1,7 @@ description = "Use existing" plugins { - id("software.amazon.smithy.gradle.smithy-trait-module") version "1.0.0" + id("software.amazon.smithy.gradle.smithy-trait-package") version "1.0.0" } group = "software.amazon.smithy" diff --git a/examples/trait-module-plugin/use-with-existing-trait/model/custom-trait.smithy b/examples/trait-package-plugin/use-with-existing-trait/model/custom-trait.smithy similarity index 100% rename from examples/trait-module-plugin/use-with-existing-trait/model/custom-trait.smithy rename to examples/trait-package-plugin/use-with-existing-trait/model/custom-trait.smithy diff --git a/examples/trait-module-plugin/use-with-existing-trait/settings.gradle.kts b/examples/trait-package-plugin/use-with-existing-trait/settings.gradle.kts similarity index 100% rename from examples/trait-module-plugin/use-with-existing-trait/settings.gradle.kts rename to examples/trait-package-plugin/use-with-existing-trait/settings.gradle.kts diff --git a/examples/trait-module-plugin/use-with-existing-trait/smithy-build.json b/examples/trait-package-plugin/use-with-existing-trait/smithy-build.json similarity index 100% rename from examples/trait-module-plugin/use-with-existing-trait/smithy-build.json rename to examples/trait-package-plugin/use-with-existing-trait/smithy-build.json diff --git a/examples/trait-module-plugin/use-with-existing-trait/src/main/java/io/smithy/gradle/examples/traits/JsonNameTrait.java b/examples/trait-package-plugin/use-with-existing-trait/src/main/java/io/smithy/gradle/examples/traits/JsonNameTrait.java similarity index 100% rename from examples/trait-module-plugin/use-with-existing-trait/src/main/java/io/smithy/gradle/examples/traits/JsonNameTrait.java rename to examples/trait-package-plugin/use-with-existing-trait/src/main/java/io/smithy/gradle/examples/traits/JsonNameTrait.java diff --git a/examples/trait-module-plugin/use-with-existing-trait/src/main/resources/META-INF/services/software.amazon.smithy.model.traits.TraitService b/examples/trait-package-plugin/use-with-existing-trait/src/main/resources/META-INF/services/software.amazon.smithy.model.traits.TraitService similarity index 100% rename from examples/trait-module-plugin/use-with-existing-trait/src/main/resources/META-INF/services/software.amazon.smithy.model.traits.TraitService rename to examples/trait-package-plugin/use-with-existing-trait/src/main/resources/META-INF/services/software.amazon.smithy.model.traits.TraitService diff --git a/settings.gradle.kts b/settings.gradle.kts index a790345..e4ac09a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -2,5 +2,5 @@ rootProject.name = "smithy-gradle" include("smithy-base") include("smithy-jar") -include("smithy-trait-module") +include("smithy-trait-package") include("integ-test-utils") diff --git a/smithy-trait-module/build.gradle.kts b/smithy-trait-package/build.gradle.kts similarity index 82% rename from smithy-trait-module/build.gradle.kts rename to smithy-trait-package/build.gradle.kts index 08ad21d..7b35e2b 100644 --- a/smithy-trait-module/build.gradle.kts +++ b/smithy-trait-package/build.gradle.kts @@ -7,11 +7,11 @@ plugins { gradlePlugin { plugins { - create("smithy-trait-module-plugin") { - id = "${group}.smithy-trait-module" + create("smithy-trait-package-plugin") { + id = "${group}.smithy-trait-package" displayName = "Smithy Gradle Trait Package plugin." description = project.description - implementationClass = "software.amazon.smithy.gradle.SmithyTraitModulePlugin" + implementationClass = "software.amazon.smithy.gradle.SmithyTraitPackagePlugin" tags.addAll("smithy", "api", "building") } } diff --git a/smithy-trait-module/src/it/java/software/amazon/smithy/gradle/CreatesCustomTraitTest.java b/smithy-trait-package/src/it/java/software/amazon/smithy/gradle/CreatesCustomTraitTest.java similarity index 95% rename from smithy-trait-module/src/it/java/software/amazon/smithy/gradle/CreatesCustomTraitTest.java rename to smithy-trait-package/src/it/java/software/amazon/smithy/gradle/CreatesCustomTraitTest.java index 6e69aa2..8bc41e2 100644 --- a/smithy-trait-module/src/it/java/software/amazon/smithy/gradle/CreatesCustomTraitTest.java +++ b/smithy-trait-package/src/it/java/software/amazon/smithy/gradle/CreatesCustomTraitTest.java @@ -11,7 +11,7 @@ public class CreatesCustomTraitTest { @Test public void createsTraitsAndAddsToJar() { - Utils.withCopy("trait-module-plugin/create-simple-trait", buildDir -> { + Utils.withCopy("trait-package-plugin/create-simple-trait", buildDir -> { BuildResult result = GradleRunner.create() .forwardOutput() .withProjectDir(buildDir) diff --git a/smithy-trait-module/src/it/java/software/amazon/smithy/gradle/RespectsManualTraitTest.java b/smithy-trait-package/src/it/java/software/amazon/smithy/gradle/RespectsManualTraitTest.java similarity index 95% rename from smithy-trait-module/src/it/java/software/amazon/smithy/gradle/RespectsManualTraitTest.java rename to smithy-trait-package/src/it/java/software/amazon/smithy/gradle/RespectsManualTraitTest.java index 1c31ff8..b0450a6 100644 --- a/smithy-trait-module/src/it/java/software/amazon/smithy/gradle/RespectsManualTraitTest.java +++ b/smithy-trait-package/src/it/java/software/amazon/smithy/gradle/RespectsManualTraitTest.java @@ -13,7 +13,7 @@ public class RespectsManualTraitTest { @Test public void respectsExistingTraitAndMergesSpiFiles() { - Utils.withCopy("trait-module-plugin/use-with-existing-trait", buildDir -> { + Utils.withCopy("trait-package-plugin/use-with-existing-trait", buildDir -> { BuildResult result = GradleRunner.create() .forwardOutput() .withProjectDir(buildDir) diff --git a/smithy-trait-module/src/main/java/software/amazon/smithy/gradle/SmithyTraitModulePlugin.java b/smithy-trait-package/src/main/java/software/amazon/smithy/gradle/SmithyTraitPackagePlugin.java similarity index 92% rename from smithy-trait-module/src/main/java/software/amazon/smithy/gradle/SmithyTraitModulePlugin.java rename to smithy-trait-package/src/main/java/software/amazon/smithy/gradle/SmithyTraitPackagePlugin.java index 0b35d3a..5f2ecc9 100644 --- a/smithy-trait-module/src/main/java/software/amazon/smithy/gradle/SmithyTraitModulePlugin.java +++ b/smithy-trait-package/src/main/java/software/amazon/smithy/gradle/SmithyTraitPackagePlugin.java @@ -26,7 +26,7 @@ /** * A {@link org.gradle.api.Plugin} that adds sets up a package for a custom trait. */ -public class SmithyTraitModulePlugin implements Plugin { +public class SmithyTraitPackagePlugin implements Plugin { private static final String SMITHY_TRAIT_CODEGEN_DEP_NAME = "smithy-trait-codegen"; private static final String TRAIT_CODEGEN_PLUGIN_NAME = "trait-codegen"; private static final String TRAIT_SPI_FILE_NAME = "software.amazon.smithy.model.traits.TraitService"; @@ -39,7 +39,7 @@ public class SmithyTraitModulePlugin implements Plugin { private final Project project; @Inject - public SmithyTraitModulePlugin(Project project) { + public SmithyTraitPackagePlugin(Project project) { this.project = project; } @@ -89,19 +89,18 @@ private void configureDependencies(SourceSet sourceSet) { // Prefer explicit dependency Optional explicitDepOptional = smithyBuild.getAllDependencies().stream() - .filter(d -> SmithyUtils.isMatchingDependency(d, - SmithyTraitModulePlugin.SMITHY_TRAIT_CODEGEN_DEP_NAME)) + .filter(d -> SmithyUtils.isMatchingDependency(d, SMITHY_TRAIT_CODEGEN_DEP_NAME)) .findFirst(); if (explicitDepOptional.isPresent()) { project.getLogger().info(String.format("(using explicitly configured Dependency for %s: %s)", - SmithyTraitModulePlugin.SMITHY_TRAIT_CODEGEN_DEP_NAME, explicitDepOptional.get().getVersion())); + SMITHY_TRAIT_CODEGEN_DEP_NAME, explicitDepOptional.get().getVersion())); return; } // If trait codegen does not exist, add the dependency with the same version as the resolved CLI version String cliVersion = CliDependencyResolver.resolve(project); project.getDependencies().add(smithyBuild.getName(), - String.format(DEPENDENCY_NOTATION, SmithyTraitModulePlugin.SMITHY_TRAIT_CODEGEN_DEP_NAME, cliVersion)); + String.format(DEPENDENCY_NOTATION, SMITHY_TRAIT_CODEGEN_DEP_NAME, cliVersion)); } private TaskProvider addMergeTask(SourceSet sourceSet, Path pluginPath, File existing) { diff --git a/smithy-trait-module/src/main/java/software/amazon/smithy/gradle/tasks/MergeSpiFilesTask.java b/smithy-trait-package/src/main/java/software/amazon/smithy/gradle/tasks/MergeSpiFilesTask.java similarity index 100% rename from smithy-trait-module/src/main/java/software/amazon/smithy/gradle/tasks/MergeSpiFilesTask.java rename to smithy-trait-package/src/main/java/software/amazon/smithy/gradle/tasks/MergeSpiFilesTask.java