Class AddMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

    @Mojo(name="add")
    public class AddMojo
    extends AbstractFunctionMojo
    Create new Azure Functions (as Java class) and add to current project.
    • Constructor Detail

      • AddMojo

        public AddMojo()
    • Method Detail

      • getFunctionPackageName

        public String getFunctionPackageName()
      • getFunctionName

        public String getFunctionName()
      • getClassName

        public String getClassName()
      • getFunctionTemplate

        public String getFunctionTemplate()
      • getBasedir

        protected String getBasedir()
      • getSourceRoot

        protected String getSourceRoot()
      • setFunctionPackageName

        protected void setFunctionPackageName​(String functionPackageName)
      • setFunctionName

        protected void setFunctionName​(String functionName)
      • setFunctionTemplate

        protected void setFunctionTemplate​(String functionTemplate)
      • doExecute

        protected void doExecute()
                          throws com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException
        Specified by:
        doExecute in class com.microsoft.azure.maven.AbstractAzureMojo
        Throws:
        com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException
      • loadAllFunctionTemplates

        protected List<com.microsoft.azure.toolkit.lib.legacy.function.template.FunctionTemplate> loadAllFunctionTemplates​(com.microsoft.azure.toolkit.lib.legacy.function.configurations.FunctionExtensionVersion bundleVersion)
                                                                                                                    throws com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException
        Throws:
        com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException
      • getFunctionTemplate

        protected com.microsoft.azure.toolkit.lib.legacy.function.template.FunctionTemplate getFunctionTemplate​(List<com.microsoft.azure.toolkit.lib.legacy.function.template.FunctionTemplate> templates)
                                                                                                         throws IOException,
                                                                                                                com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException,
                                                                                                                org.apache.maven.plugin.MojoFailureException
        Throws:
        IOException
        com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException
        org.apache.maven.plugin.MojoFailureException
      • getTemplateNames

        protected List<String> getTemplateNames​(List<com.microsoft.azure.toolkit.lib.legacy.function.template.FunctionTemplate> templates)
      • findTemplateByName

        protected com.microsoft.azure.toolkit.lib.legacy.function.template.FunctionTemplate findTemplateByName​(List<com.microsoft.azure.toolkit.lib.legacy.function.template.FunctionTemplate> templates,
                                                                                                               String templateName)
                                                                                                        throws com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException
        Throws:
        com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException
      • prepareRequiredParameters

        protected Map<String,​String> prepareRequiredParameters​(com.microsoft.azure.toolkit.lib.legacy.function.template.FunctionTemplate template,
                                                                     com.microsoft.azure.toolkit.lib.legacy.function.template.BindingTemplate bindingTemplate)
                                                              throws org.apache.maven.plugin.MojoFailureException
        Throws:
        org.apache.maven.plugin.MojoFailureException
      • prepareFunctionName

        protected void prepareFunctionName()
                                    throws org.apache.maven.plugin.MojoFailureException
        Throws:
        org.apache.maven.plugin.MojoFailureException
      • preparePackageName

        protected void preparePackageName()
                                   throws org.apache.maven.plugin.MojoFailureException
        Throws:
        org.apache.maven.plugin.MojoFailureException
      • prepareTemplateParameters

        protected Map<String,​String> prepareTemplateParameters​(com.microsoft.azure.toolkit.lib.legacy.function.template.FunctionTemplate template,
                                                                     com.microsoft.azure.toolkit.lib.legacy.function.template.BindingTemplate bindingTemplate,
                                                                     Map<String,​String> params)
                                                              throws org.apache.maven.plugin.MojoFailureException
        Throws:
        org.apache.maven.plugin.MojoFailureException
      • getStringInputFromUser

        protected String getStringInputFromUser​(String attributeName,
                                                String initValue,
                                                com.microsoft.azure.toolkit.lib.legacy.function.template.FunctionSettingTemplate template)
      • getStringInputErrorMessage

        protected String getStringInputErrorMessage​(com.microsoft.azure.toolkit.lib.legacy.function.template.FunctionSettingTemplate template)
      • getStringInputPromptString

        protected String getStringInputPromptString​(String attributeName,
                                                    String defaultValue)
      • getStringInputValidator

        protected java.util.function.Function<String,​Boolean> getStringInputValidator​(com.microsoft.azure.toolkit.lib.legacy.function.template.FunctionSettingTemplate template)
      • displayParameters

        protected void displayParameters​(Map<String,​String> params)
      • substituteParametersInTemplate

        protected String substituteParametersInTemplate​(com.microsoft.azure.toolkit.lib.legacy.function.template.FunctionTemplate template,
                                                        Map<String,​String> params)
      • saveNewFunctionToFile

        protected void saveNewFunctionToFile​(String newFunctionClass)
                                      throws IOException,
                                             com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException
        Throws:
        IOException
        com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException
      • getPackageDir

        protected File getPackageDir()
      • getTargetFile

        protected File getTargetFile​(File packageDir)
                              throws com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException
        Throws:
        com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException
      • createPackageDirIfNotExist

        protected void createPackageDirIfNotExist​(File packageDir)
      • assureInputFromUser

        protected void assureInputFromUser​(String prompt,
                                           String initValue,
                                           List<String> options,
                                           java.util.function.Consumer<String> setter)
      • assureInputFromUser

        protected void assureInputFromUser​(String prompt,
                                           String initValue,
                                           java.util.function.Function<String,​Boolean> validator,
                                           String errorMessage,
                                           java.util.function.Consumer<String> setter)
      • assureInputInBatchMode

        protected void assureInputInBatchMode​(String input,
                                              java.util.function.Function<String,​Boolean> validator,
                                              java.util.function.Consumer<String> setter,
                                              boolean required)
                                       throws org.apache.maven.plugin.MojoFailureException
        Throws:
        org.apache.maven.plugin.MojoFailureException
      • getScanner

        protected Scanner getScanner()