2626import java .nio .file .attribute .BasicFileAttributes ;
2727import java .util .Arrays ;
2828import java .util .Collections ;
29+ import java .util .HashMap ;
2930import java .util .LinkedHashSet ;
3031import java .util .List ;
32+ import java .util .Map ;
3133import java .util .Set ;
3234import java .util .stream .Collectors ;
3335import 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}
0 commit comments