Skip to content

Commit dd3571f

Browse files
authored
Fix dependency generation for new smithy-rpc-v2-cbor services (#6276)
1 parent 75836d7 commit dd3571f

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

release-scripts/src/main/java/software/amazon/awssdk/release/CreateNewServiceModuleMain.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@
2626
import java.nio.file.attribute.BasicFileAttributes;
2727
import java.util.Arrays;
2828
import java.util.Collections;
29+
import java.util.HashMap;
2930
import java.util.LinkedHashSet;
3031
import java.util.List;
32+
import java.util.Map;
3133
import java.util.Set;
3234
import java.util.stream.Collectors;
3335
import java.util.stream.Stream;
@@ -73,6 +75,14 @@ public class CreateNewServiceModuleMain extends Cli {
7375

7476
private static final Set<String> DEFAULT_INTERNAL_DEPENDENCIES = toSet("http-auth-aws");
7577

78+
private static final Map<String, Set<String>> ADDITIONAL_INTERNAL_PROTOCOL_DEPENDENCIES;
79+
80+
static {
81+
// Note, the protocol keys must match the values returned from transformSpecialProtocols
82+
ADDITIONAL_INTERNAL_PROTOCOL_DEPENDENCIES = new HashMap<>();
83+
ADDITIONAL_INTERNAL_PROTOCOL_DEPENDENCIES.put("smithy-rpcv2", toSet("aws-json-protocol"));
84+
}
85+
7686
private CreateNewServiceModuleMain() {
7787
super(requiredOption("service-module-name", "The name of the service module to be created."),
7888
requiredOption("service-id", "The service ID of the service module to be created."),
@@ -103,9 +113,10 @@ static List<String> toList(String[] optionValues) {
103113
return Arrays.asList(optionValues);
104114
}
105115

106-
static Set<String> computeInternalDependencies(List<String> includes, List<String> excludes) {
116+
static Set<String> computeInternalDependencies(String serviceProtocol, List<String> includes, List<String> excludes) {
107117
Set<String> result = new LinkedHashSet<>(DEFAULT_INTERNAL_DEPENDENCIES);
108118
result.addAll(includes);
119+
result.addAll(ADDITIONAL_INTERNAL_PROTOCOL_DEPENDENCIES.getOrDefault(serviceProtocol, Collections.emptySet()));
109120
excludes.forEach(result::remove);
110121
return Collections.unmodifiableSet(result);
111122
}
@@ -129,7 +140,8 @@ private NewServiceCreator(CommandLine commandLine) {
129140
this.serviceModuleName = commandLine.getOptionValue("service-module-name").trim();
130141
this.serviceId = commandLine.getOptionValue("service-id").trim();
131142
this.serviceProtocol = transformSpecialProtocols(commandLine.getOptionValue("service-protocol").trim());
132-
this.internalDependencies = computeInternalDependencies(toList(commandLine
143+
this.internalDependencies = computeInternalDependencies(serviceProtocol,
144+
toList(commandLine
133145
.getOptionValues("include-internal-dependency")),
134146
toList(commandLine
135147
.getOptionValues("exclude-internal-dependency")));
@@ -180,10 +192,10 @@ private void replacePlaceholdersInFile(Path file) throws IOException {
180192

181193
private String replacePlaceholders(String line) {
182194
String[] searchList = {
183-
"{{MVN_ARTIFACT_ID}}",
184-
"{{MVN_NAME}}",
185-
"{{MVN_VERSION}}",
186-
"{{PROTOCOL}}"
195+
"{{MVN_ARTIFACT_ID}}",
196+
"{{MVN_NAME}}",
197+
"{{MVN_VERSION}}",
198+
"{{PROTOCOL}}"
187199
};
188200
String[] replaceList = {
189201
serviceModuleName,
@@ -217,5 +229,4 @@ protected void updateDocument(Document doc) {
217229
}
218230
}
219231
}
220-
221232
}

release-scripts/src/main/java/software/amazon/awssdk/release/NewServiceMain.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ private NewServiceCreator(CommandLine commandLine) {
8686
this.serviceModuleName = commandLine.getOptionValue("service-module-name").trim();
8787
this.serviceId = commandLine.getOptionValue("service-id").trim();
8888
this.serviceProtocol = transformSpecialProtocols(commandLine.getOptionValue("service-protocol").trim());
89-
this.internalDependencies = computeInternalDependencies(toList(commandLine
89+
this.internalDependencies = computeInternalDependencies(serviceProtocol,
90+
toList(commandLine
9091
.getOptionValues("include-internal-dependency")),
9192
toList(commandLine
9293
.getOptionValues("exclude-internal-dependency")));
@@ -98,7 +99,7 @@ private String transformSpecialProtocols(String protocol) {
9899
case "ec2": return "aws-query";
99100
case "rest-xml": return "aws-xml";
100101
case "rest-json": return "aws-json";
101-
case "rpc-v2-cbor": return "smithy-rpcv2";
102+
case "smithy-rpc-v2-cbor": return "smithy-rpcv2";
102103
default: return "aws-" + protocol;
103104
}
104105
}

0 commit comments

Comments
 (0)