use of com.microsoft.azure.gradle.functions.template.FunctionTemplate in project azure-gradle-plugins by lenala.
the class AddTask method loadAllFunctionTemplates.
private List<FunctionTemplate> loadAllFunctionTemplates() throws Exception {
getLogger().quiet(LOAD_TEMPLATES);
try (final InputStream is = AddTask.class.getResourceAsStream("/templates.json")) {
final String templatesJsonStr = IOUtils.toString(is);
final List<FunctionTemplate> templates = parseTemplateJson(templatesJsonStr);
getLogger().quiet(LOAD_TEMPLATES_DONE);
return templates;
} catch (Exception e) {
getLogger().quiet(LOAD_TEMPLATES_FAIL);
throw e;
}
}
use of com.microsoft.azure.gradle.functions.template.FunctionTemplate in project azure-gradle-plugins by lenala.
the class AddTask method add.
@TaskAction
void add() {
try {
final List<FunctionTemplate> templates = loadAllFunctionTemplates();
final FunctionTemplate template = getFunctionTemplate(templates);
final Map params = prepareRequiredParameters(template);
final String newFunctionClass = substituteParametersInTemplate(template, params);
saveNewFunctionToFile(newFunctionClass);
} catch (Exception ex) {
throw new TaskExecutionException(this, ex);
}
}
Aggregations