Search in sources :

Example 1 with PackageHandler

use of com.microsoft.azure.plugin.functions.gradle.handler.PackageHandler in project azure-gradle-plugins by microsoft.

the class PackageTask method build.

@TaskAction
@AzureOperation(name = "functionapp.package", type = AzureOperation.Type.ACTION)
public void build() throws GradleException {
    try {
        TelemetryAgent.getInstance().trackTaskStart(this.getClass());
        final GradleFunctionContext ctx = new GradleFunctionContext(getProject(), this.getFunctionsExtension());
        TelemetryAgent.getInstance().addDefaultProperties(ctx.getTelemetryProperties());
        final File stagingFolder = new File(ctx.getDeploymentStagingDirectoryPath());
        // package task will start from a empty staging folder
        if (stagingFolder.exists()) {
            FileUtils.cleanDirectory(stagingFolder);
        } else {
            stagingFolder.mkdirs();
        }
        final PackageHandler packageHandler = new PackageHandler(ctx.getProject(), ctx.getDeploymentStagingDirectoryPath());
        packageHandler.execute();
        TelemetryAgent.getInstance().trackTaskSuccess(this.getClass());
    } catch (Exception e) {
        TelemetryAgent.getInstance().traceException(this.getClass(), e);
        throw new GradleException(PACKAGE_FAILURE + e.getMessage(), e);
    }
}
Also used : PackageHandler(com.microsoft.azure.plugin.functions.gradle.handler.PackageHandler) GradleException(org.gradle.api.GradleException) GradleFunctionContext(com.microsoft.azure.plugin.functions.gradle.GradleFunctionContext) File(java.io.File) GradleException(org.gradle.api.GradleException) TaskAction(org.gradle.api.tasks.TaskAction) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Aggregations

GradleFunctionContext (com.microsoft.azure.plugin.functions.gradle.GradleFunctionContext)1 PackageHandler (com.microsoft.azure.plugin.functions.gradle.handler.PackageHandler)1 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)1 File (java.io.File)1 GradleException (org.gradle.api.GradleException)1 TaskAction (org.gradle.api.tasks.TaskAction)1