Skip to content

Commit

Permalink
Rename trait codegen plugin back to package from module (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpmellema authored Jul 11, 2024
1 parent a626b97 commit 562bffb
Show file tree
Hide file tree
Showing 18 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Project> {
public class SmithyTraitPackagePlugin implements Plugin<Project> {
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";
Expand All @@ -39,7 +39,7 @@ public class SmithyTraitModulePlugin implements Plugin<Project> {
private final Project project;

@Inject
public SmithyTraitModulePlugin(Project project) {
public SmithyTraitPackagePlugin(Project project) {
this.project = project;
}

Expand Down Expand Up @@ -89,19 +89,18 @@ private void configureDependencies(SourceSet sourceSet) {

// Prefer explicit dependency
Optional<Dependency> 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<MergeSpiFilesTask> addMergeTask(SourceSet sourceSet, Path pluginPath, File existing) {
Expand Down

0 comments on commit 562bffb

Please sign in to comment.