diff --git a/release-scripts/src/main/java/software/amazon/awssdk/release/CreateNewServiceModuleMain.java b/release-scripts/src/main/java/software/amazon/awssdk/release/CreateNewServiceModuleMain.java index f48ff01ff00c..c9fc86bf6833 100644 --- a/release-scripts/src/main/java/software/amazon/awssdk/release/CreateNewServiceModuleMain.java +++ b/release-scripts/src/main/java/software/amazon/awssdk/release/CreateNewServiceModuleMain.java @@ -26,8 +26,10 @@ import java.nio.file.attribute.BasicFileAttributes; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -73,6 +75,14 @@ public class CreateNewServiceModuleMain extends Cli { private static final Set DEFAULT_INTERNAL_DEPENDENCIES = toSet("http-auth-aws"); + private static final Map> ADDITIONAL_INTERNAL_PROTOCOL_DEPENDENCIES; + + static { + // Note, the protocol keys must match the values returned from transformSpecialProtocols + ADDITIONAL_INTERNAL_PROTOCOL_DEPENDENCIES = new HashMap<>(); + ADDITIONAL_INTERNAL_PROTOCOL_DEPENDENCIES.put("smithy-rpcv2", toSet("aws-json-protocol")); + } + private CreateNewServiceModuleMain() { super(requiredOption("service-module-name", "The name of the service module to be created."), requiredOption("service-id", "The service ID of the service module to be created."), @@ -103,9 +113,10 @@ static List toList(String[] optionValues) { return Arrays.asList(optionValues); } - static Set computeInternalDependencies(List includes, List excludes) { + static Set computeInternalDependencies(String serviceProtocol, List includes, List excludes) { Set result = new LinkedHashSet<>(DEFAULT_INTERNAL_DEPENDENCIES); result.addAll(includes); + result.addAll(ADDITIONAL_INTERNAL_PROTOCOL_DEPENDENCIES.getOrDefault(serviceProtocol, Collections.emptySet())); excludes.forEach(result::remove); return Collections.unmodifiableSet(result); } @@ -129,7 +140,8 @@ private NewServiceCreator(CommandLine commandLine) { this.serviceModuleName = commandLine.getOptionValue("service-module-name").trim(); this.serviceId = commandLine.getOptionValue("service-id").trim(); this.serviceProtocol = transformSpecialProtocols(commandLine.getOptionValue("service-protocol").trim()); - this.internalDependencies = computeInternalDependencies(toList(commandLine + this.internalDependencies = computeInternalDependencies(serviceProtocol, + toList(commandLine .getOptionValues("include-internal-dependency")), toList(commandLine .getOptionValues("exclude-internal-dependency"))); @@ -141,7 +153,7 @@ private String transformSpecialProtocols(String protocol) { case "ec2": return "aws-query"; case "rest-xml": return "aws-xml"; case "rest-json": return "aws-json"; - case "rpc-v2-cbor": return "smithy-rpcv2"; + case "smithy-rpc-v2-cbor": return "smithy-rpcv2"; default: return "aws-" + protocol; } } @@ -180,10 +192,10 @@ private void replacePlaceholdersInFile(Path file) throws IOException { private String replacePlaceholders(String line) { String[] searchList = { - "{{MVN_ARTIFACT_ID}}", - "{{MVN_NAME}}", - "{{MVN_VERSION}}", - "{{PROTOCOL}}" + "{{MVN_ARTIFACT_ID}}", + "{{MVN_NAME}}", + "{{MVN_VERSION}}", + "{{PROTOCOL}}" }; String[] replaceList = { serviceModuleName, @@ -217,5 +229,4 @@ protected void updateDocument(Document doc) { } } } - } diff --git a/release-scripts/src/main/java/software/amazon/awssdk/release/NewServiceMain.java b/release-scripts/src/main/java/software/amazon/awssdk/release/NewServiceMain.java index d1e40a6c360a..b90593e81353 100644 --- a/release-scripts/src/main/java/software/amazon/awssdk/release/NewServiceMain.java +++ b/release-scripts/src/main/java/software/amazon/awssdk/release/NewServiceMain.java @@ -86,7 +86,8 @@ private NewServiceCreator(CommandLine commandLine) { this.serviceModuleName = commandLine.getOptionValue("service-module-name").trim(); this.serviceId = commandLine.getOptionValue("service-id").trim(); this.serviceProtocol = transformSpecialProtocols(commandLine.getOptionValue("service-protocol").trim()); - this.internalDependencies = computeInternalDependencies(toList(commandLine + this.internalDependencies = computeInternalDependencies(serviceProtocol, + toList(commandLine .getOptionValues("include-internal-dependency")), toList(commandLine .getOptionValues("exclude-internal-dependency"))); @@ -98,7 +99,7 @@ private String transformSpecialProtocols(String protocol) { case "ec2": return "aws-query"; case "rest-xml": return "aws-xml"; case "rest-json": return "aws-json"; - case "rpc-v2-cbor": return "smithy-rpcv2"; + case "smithy-rpc-v2-cbor": return "smithy-rpcv2"; default: return "aws-" + protocol; } }