Add command to display all library templates supported

for a specific language
This commit is contained in:
xhh
2015-08-05 16:37:08 +08:00
parent 4ba521a5c0
commit 07f10a8abc
8 changed files with 98 additions and 4 deletions

View File

@@ -109,6 +109,8 @@ public interface CodegenConfig {
void setSkipOverwrite(boolean skipOverwrite);
Map<String, String> supportedLibraries();
void setLibrary(String library);
/**

View File

@@ -81,6 +81,7 @@ public class DefaultCodegen {
protected List<CliOption> cliOptions = new ArrayList<CliOption>();
protected boolean skipOverwrite;
protected boolean supportsInheritance = false;
protected Map<String, String> supportedLibraries = new HashMap<String, String>();
protected String library = null;
public List<CliOption> cliOptions() {
@@ -1389,7 +1390,16 @@ public class DefaultCodegen {
this.skipOverwrite = skipOverwrite;
}
/**
* All library templates supported.
*/
public Map<String, String> supportedLibraries() {
return supportedLibraries;
}
public void setLibrary(String library) {
if (library != null && !supportedLibraries.containsKey(library))
throw new RuntimeException("unknown library: " + library);
this.library = library;
}

View File

@@ -266,7 +266,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
String templateFile = null;
String library = config.getLibrary();
if (library != null) {
if (library != null && !"".equals(library)) {
String libTemplateFile = config.templateDir() + File.separator +
"libraries" + File.separator + library + File.separator +
support.templateFile;

View File

@@ -61,6 +61,9 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
cliOptions.add(new CliOption("artifactId", "artifactId in generated pom.xml"));
cliOptions.add(new CliOption("artifactVersion", "artifact version in generated pom.xml"));
cliOptions.add(new CliOption("sourceFolder", "source folder for generated code"));
supportedLibraries.put("", "HTTP client: Jersey client 1.18. JSON processing: Jackson 2.4.2");
supportedLibraries.put("jersey2", "HTTP client: Jersey client 2.6");
}
public CodegenType getTag() {