@@ -47,26 +47,6 @@ public AndroidClientCodegen() {
47
47
"native" , "super" , "while" )
48
48
);
49
49
50
- additionalProperties .put ("invokerPackage" , invokerPackage );
51
- additionalProperties .put ("groupId" , groupId );
52
- additionalProperties .put ("artifactId" , artifactId );
53
- additionalProperties .put ("artifactVersion" , artifactVersion );
54
-
55
- supportingFiles .add (new SupportingFile ("pom.mustache" , "" , "pom.xml" ));
56
- additionalProperties .put ("useAndroidMavenGradlePlugin" , useAndroidMavenGradlePlugin );
57
-
58
- supportingFiles .add (new SupportingFile ("settings.gradle.mustache" , "" , "settings.gradle" ));
59
- supportingFiles .add (new SupportingFile ("build.mustache" , "" , "build.gradle" ));
60
- supportingFiles .add (new SupportingFile ("manifest.mustache" , projectFolder , "AndroidManifest.xml" ));
61
- supportingFiles .add (new SupportingFile ("apiInvoker.mustache" ,
62
- (sourceFolder + File .separator + invokerPackage ).replace ("." , java .io .File .separator ), "ApiInvoker.java" ));
63
- supportingFiles .add (new SupportingFile ("httpPatch.mustache" ,
64
- (sourceFolder + File .separator + invokerPackage ).replace ("." , java .io .File .separator ), "HttpPatch.java" ));
65
- supportingFiles .add (new SupportingFile ("jsonUtil.mustache" ,
66
- (sourceFolder + File .separator + invokerPackage ).replace ("." , java .io .File .separator ), "JsonUtil.java" ));
67
- supportingFiles .add (new SupportingFile ("apiException.mustache" ,
68
- (sourceFolder + File .separator + invokerPackage ).replace ("." , java .io .File .separator ), "ApiException.java" ));
69
-
70
50
languageSpecificPrimitives = new HashSet <String >(
71
51
Arrays .asList (
72
52
"String" ,
@@ -80,6 +60,13 @@ public AndroidClientCodegen() {
80
60
);
81
61
instantiationTypes .put ("array" , "ArrayList" );
82
62
instantiationTypes .put ("map" , "HashMap" );
63
+
64
+ cliOptions .add (new CliOption ("invokerPackage" , "root package to use for the generated code" ));
65
+ cliOptions .add (new CliOption ("groupId" , "groupId for use in the generated build.gradle and pom.xml" ));
66
+ cliOptions .add (new CliOption ("artifactId" , "artifactId for use in the generated build.gradle and pom.xml" ));
67
+ cliOptions .add (new CliOption ("artifactVersion" , "artifact version for use in the generated build.gradle and pom.xml" ));
68
+ cliOptions .add (new CliOption ("sourceFolder" , "source folder for generated code" ));
69
+ cliOptions .add (new CliOption ("useAndroidMavenGradlePlugin" , "A flag to toggle android-maven gradle plugin. Default is true." ));
83
70
}
84
71
85
72
@ Override
@@ -177,6 +164,96 @@ public String toOperationId(String operationId) {
177
164
178
165
return camelize (operationId , true );
179
166
}
167
+
168
+ @ Override
169
+ public void processOpts () {
170
+ super .processOpts ();
171
+
172
+ if (additionalProperties .containsKey ("invokerPackage" )) {
173
+ this .setInvokerPackage ((String )additionalProperties .get ("invokerPackage" ));
174
+ }
175
+ else {
176
+ //not set, use default to be passed to template
177
+ additionalProperties .put ("invokerPackage" , invokerPackage );
178
+ }
179
+
180
+ if (additionalProperties .containsKey ("groupId" )) {
181
+ this .setGroupId ((String )additionalProperties .get ("groupId" ));
182
+ }
183
+ else {
184
+ //not set, use to be passed to template
185
+ additionalProperties .put ("groupId" , groupId );
186
+ }
187
+
188
+ if (additionalProperties .containsKey ("artifactId" )) {
189
+ this .setArtifactId ((String )additionalProperties .get ("artifactId" ));
190
+ }
191
+ else {
192
+ //not set, use to be passed to template
193
+ additionalProperties .put ("artifactId" , artifactId );
194
+ }
195
+
196
+ if (additionalProperties .containsKey ("artifactVersion" )) {
197
+ this .setArtifactVersion ((String )additionalProperties .get ("artifactVersion" ));
198
+ }
199
+ else {
200
+ //not set, use to be passed to template
201
+ additionalProperties .put ("artifactVersion" , artifactVersion );
202
+ }
203
+
204
+ if (additionalProperties .containsKey ("sourceFolder" )) {
205
+ this .setSourceFolder ((String )additionalProperties .get ("sourceFolder" ));
206
+ }
180
207
208
+ if (additionalProperties .containsKey ("useAndroidMavenGradlePlugin" )) {
209
+ this .setUseAndroidMavenGradlePlugin ((Boolean )additionalProperties .get ("useAndroidMavenGradlePlugin" ));
210
+ }
211
+ else {
212
+ additionalProperties .put ("useAndroidMavenGradlePlugin" , useAndroidMavenGradlePlugin );
213
+ }
214
+
215
+ supportingFiles .add (new SupportingFile ("pom.mustache" , "" , "pom.xml" ));
216
+ additionalProperties .put ("useAndroidMavenGradlePlugin" , useAndroidMavenGradlePlugin );
217
+
218
+ supportingFiles .add (new SupportingFile ("settings.gradle.mustache" , "" , "settings.gradle" ));
219
+ supportingFiles .add (new SupportingFile ("build.mustache" , "" , "build.gradle" ));
220
+ supportingFiles .add (new SupportingFile ("manifest.mustache" , projectFolder , "AndroidManifest.xml" ));
221
+ supportingFiles .add (new SupportingFile ("apiInvoker.mustache" ,
222
+ (sourceFolder + File .separator + invokerPackage ).replace ("." , java .io .File .separator ), "ApiInvoker.java" ));
223
+ supportingFiles .add (new SupportingFile ("httpPatch.mustache" ,
224
+ (sourceFolder + File .separator + invokerPackage ).replace ("." , java .io .File .separator ), "HttpPatch.java" ));
225
+ supportingFiles .add (new SupportingFile ("jsonUtil.mustache" ,
226
+ (sourceFolder + File .separator + invokerPackage ).replace ("." , java .io .File .separator ), "JsonUtil.java" ));
227
+ supportingFiles .add (new SupportingFile ("apiException.mustache" ,
228
+ (sourceFolder + File .separator + invokerPackage ).replace ("." , java .io .File .separator ), "ApiException.java" ));
229
+ }
230
+
231
+ public Boolean getUseAndroidMavenGradlePlugin () {
232
+ return useAndroidMavenGradlePlugin ;
233
+ }
234
+
235
+ public void setUseAndroidMavenGradlePlugin (Boolean useAndroidMavenGradlePlugin ) {
236
+ this .useAndroidMavenGradlePlugin = useAndroidMavenGradlePlugin ;
237
+ }
238
+
239
+ public void setInvokerPackage (String invokerPackage ) {
240
+ this .invokerPackage = invokerPackage ;
241
+ }
242
+
243
+ public void setGroupId (String groupId ) {
244
+ this .groupId = groupId ;
245
+ }
246
+
247
+ public void setArtifactId (String artifactId ) {
248
+ this .artifactId = artifactId ;
249
+ }
250
+
251
+ public void setArtifactVersion (String artifactVersion ) {
252
+ this .artifactVersion = artifactVersion ;
253
+ }
254
+
255
+ public void setSourceFolder (String sourceFolder ) {
256
+ this .sourceFolder = sourceFolder ;
257
+ }
181
258
182
259
}
0 commit comments