Search in sources :

Example 1 with FunctionConfiguration

use of com.microsoft.azure.gradle.functions.configuration.FunctionConfiguration in project azure-gradle-plugins by lenala.

the class PackageTask method packageFunction.

@TaskAction
void packageFunction() {
    try {
        final AnnotationHandler handler = getAnnotationHandler();
        final Set<Method> methods = findAnnotatedMethods(handler);
        final Map<String, FunctionConfiguration> configMap = getFunctionConfigurations(handler, methods);
        validateFunctionConfigurations(configMap);
        final ObjectWriter objectWriter = getObjectWriter();
        writeEmptyHostJsonFile(objectWriter);
        copyLocalSettingsJson();
        writeFunctionJsonFiles(objectWriter, configMap);
        copyJarsToStageDirectory();
        getLogger().quiet(BUILD_SUCCESS);
    } catch (Exception ex) {
        throw new TaskExecutionException(this, ex);
    }
}
Also used : TaskExecutionException(org.gradle.api.tasks.TaskExecutionException) FunctionConfiguration(com.microsoft.azure.gradle.functions.configuration.FunctionConfiguration) ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) AnnotationHandler(com.microsoft.azure.gradle.functions.handlers.AnnotationHandler) Method(java.lang.reflect.Method) TaskExecutionException(org.gradle.api.tasks.TaskExecutionException) IOException(java.io.IOException) TaskAction(org.gradle.api.tasks.TaskAction)

Example 2 with FunctionConfiguration

use of com.microsoft.azure.gradle.functions.configuration.FunctionConfiguration in project azure-gradle-plugins by lenala.

the class AnnotationHandlerImpl method generateConfigurations.

@Override
public Map<String, FunctionConfiguration> generateConfigurations(final Set<Method> methods) throws Exception {
    final Map<String, FunctionConfiguration> configMap = new HashMap<>();
    for (final Method method : methods) {
        final FunctionName functionAnnotation = method.getAnnotation(FunctionName.class);
        final String functionName = functionAnnotation.value();
        validateFunctionName(configMap.keySet(), functionName);
        logger.quiet("Starting processing function : " + functionName);
        configMap.put(functionName, generateConfiguration(method));
    }
    return configMap;
}
Also used : FunctionName(com.microsoft.azure.serverless.functions.annotation.FunctionName) HashMap(java.util.HashMap) FunctionConfiguration(com.microsoft.azure.gradle.functions.configuration.FunctionConfiguration) Method(java.lang.reflect.Method)

Example 3 with FunctionConfiguration

use of com.microsoft.azure.gradle.functions.configuration.FunctionConfiguration in project azure-gradle-plugins by lenala.

the class AnnotationHandlerImpl method generateConfiguration.

@Override
public FunctionConfiguration generateConfiguration(final Method method) {
    final FunctionConfiguration config = new FunctionConfiguration();
    final List<BaseBinding> bindings = config.getBindings();
    processParameterAnnotations(method, bindings);
    processMethodAnnotations(method, bindings);
    patchStorageBinding(method, bindings);
    config.setEntryPoint(method.getDeclaringClass().getCanonicalName() + "." + method.getName());
    return config;
}
Also used : FunctionConfiguration(com.microsoft.azure.gradle.functions.configuration.FunctionConfiguration) StorageBaseBinding(com.microsoft.azure.gradle.functions.bindings.StorageBaseBinding) BaseBinding(com.microsoft.azure.gradle.functions.bindings.BaseBinding)

Aggregations

FunctionConfiguration (com.microsoft.azure.gradle.functions.configuration.FunctionConfiguration)3 Method (java.lang.reflect.Method)2 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)1 BaseBinding (com.microsoft.azure.gradle.functions.bindings.BaseBinding)1 StorageBaseBinding (com.microsoft.azure.gradle.functions.bindings.StorageBaseBinding)1 AnnotationHandler (com.microsoft.azure.gradle.functions.handlers.AnnotationHandler)1 FunctionName (com.microsoft.azure.serverless.functions.annotation.FunctionName)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 TaskAction (org.gradle.api.tasks.TaskAction)1 TaskExecutionException (org.gradle.api.tasks.TaskExecutionException)1