26
26
import java .nio .file .attribute .BasicFileAttributes ;
27
27
import java .util .Arrays ;
28
28
import java .util .Collections ;
29
+ import java .util .HashMap ;
29
30
import java .util .LinkedHashSet ;
30
31
import java .util .List ;
32
+ import java .util .Map ;
31
33
import java .util .Set ;
32
34
import java .util .stream .Collectors ;
33
35
import java .util .stream .Stream ;
@@ -73,6 +75,14 @@ public class CreateNewServiceModuleMain extends Cli {
73
75
74
76
private static final Set <String > DEFAULT_INTERNAL_DEPENDENCIES = toSet ("http-auth-aws" );
75
77
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
+
76
86
private CreateNewServiceModuleMain () {
77
87
super (requiredOption ("service-module-name" , "The name of the service module to be created." ),
78
88
requiredOption ("service-id" , "The service ID of the service module to be created." ),
@@ -103,9 +113,10 @@ static List<String> toList(String[] optionValues) {
103
113
return Arrays .asList (optionValues );
104
114
}
105
115
106
- static Set <String > computeInternalDependencies (List <String > includes , List <String > excludes ) {
116
+ static Set <String > computeInternalDependencies (String serviceProtocol , List <String > includes , List <String > excludes ) {
107
117
Set <String > result = new LinkedHashSet <>(DEFAULT_INTERNAL_DEPENDENCIES );
108
118
result .addAll (includes );
119
+ result .addAll (ADDITIONAL_INTERNAL_PROTOCOL_DEPENDENCIES .getOrDefault (serviceProtocol , Collections .emptySet ()));
109
120
excludes .forEach (result ::remove );
110
121
return Collections .unmodifiableSet (result );
111
122
}
@@ -129,7 +140,8 @@ private NewServiceCreator(CommandLine commandLine) {
129
140
this .serviceModuleName = commandLine .getOptionValue ("service-module-name" ).trim ();
130
141
this .serviceId = commandLine .getOptionValue ("service-id" ).trim ();
131
142
this .serviceProtocol = transformSpecialProtocols (commandLine .getOptionValue ("service-protocol" ).trim ());
132
- this .internalDependencies = computeInternalDependencies (toList (commandLine
143
+ this .internalDependencies = computeInternalDependencies (serviceProtocol ,
144
+ toList (commandLine
133
145
.getOptionValues ("include-internal-dependency" )),
134
146
toList (commandLine
135
147
.getOptionValues ("exclude-internal-dependency" )));
@@ -180,10 +192,10 @@ private void replacePlaceholdersInFile(Path file) throws IOException {
180
192
181
193
private String replacePlaceholders (String line ) {
182
194
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}}"
187
199
};
188
200
String [] replaceList = {
189
201
serviceModuleName ,
@@ -217,5 +229,4 @@ protected void updateDocument(Document doc) {
217
229
}
218
230
}
219
231
}
220
-
221
232
}
0 commit comments