From d93ca48af47c6d5021f24a5843be40df3fab9a3a Mon Sep 17 00:00:00 2001 From: "Andy Xu(devdiv)" Date: Fri, 9 Jul 2021 17:59:23 +0800 Subject: [PATCH] split gradle plugin common to allow sharing code between gradle webapp plugins (#87) --- azure-functions-gradle-plugin/build.gradle | 2 + .../gradle/AzureFunctionsExtension.java | 4 +- .../gradle/AzureFunctionsPlugin.java | 4 +- .../gradle/GradleFunctionContext.java | 6 +-- .../functions/gradle/IAppServiceContext.java | 4 +- .../gradle/handler/DeployHandler.java | 4 +- .../gradle/handler/PackageHandler.java | 1 - .../functions/gradle/task/DeployTask.java | 5 +- .../functions/gradle/task/LocalRunTask.java | 2 +- .../functions/gradle/task/PackageTask.java | 2 +- .../functions/gradle/task/PackageZipTask.java | 4 +- ...Test.java => GradleRuntimeConfigTest.java} | 3 +- .../auth/GradleAuthConfigTest.java | 1 + azure-gradle-plugins-common/build.gradle | 54 +++++++++++++++++++ azure-gradle-plugins-common/settings.gradle | 1 + .../appservice/GradleAppServiceConfig.java | 28 ++++++++++ .../azure/gradle}/auth/GradleAuthConfig.java | 2 +- .../azure/gradle}/auth/GradleAuthHelper.java | 18 +++---- .../configuration/GradleRuntimeConfig.java | 3 +- .../configuration/GradleWebAppConfig.java | 20 +++++++ .../gradle/temeletry}/AppInsightsProxy.java | 2 +- .../gradle/temeletry}/TelemetryAgent.java | 4 +- .../temeletry}/TelemetryConfiguration.java | 2 +- .../gradle/temeletry}/TelemetryConstants.java | 2 +- .../gradle/util/GradleAzureMessager.java | 2 +- .../azure}/gradle/util/GradleProxyUtils.java | 2 +- settings.gradle | 1 + 27 files changed, 142 insertions(+), 41 deletions(-) rename azure-functions-gradle-plugin/src/test/java/com/microsoft/azure/plugin/functions/gradle/configuration/{GradleRuntimeConfigurationTest.java => GradleRuntimeConfigTest.java} (88%) create mode 100644 azure-gradle-plugins-common/build.gradle create mode 100644 azure-gradle-plugins-common/settings.gradle create mode 100644 azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/appservice/GradleAppServiceConfig.java rename {azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/configuration => azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle}/auth/GradleAuthConfig.java (86%) rename {azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/configuration => azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle}/auth/GradleAuthHelper.java (91%) rename {azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions => azure-gradle-plugins-common/src/main/java/com/microsoft/azure}/gradle/configuration/GradleRuntimeConfig.java (90%) create mode 100644 azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/configuration/GradleWebAppConfig.java rename {azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/telemetry => azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/temeletry}/AppInsightsProxy.java (98%) rename {azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/telemetry => azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/temeletry}/TelemetryAgent.java (97%) rename {azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/telemetry => azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/temeletry}/TelemetryConfiguration.java (81%) rename {azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/telemetry => azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/temeletry}/TelemetryConstants.java (93%) rename {azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions => azure-gradle-plugins-common/src/main/java/com/microsoft/azure}/gradle/util/GradleAzureMessager.java (96%) rename {azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions => azure-gradle-plugins-common/src/main/java/com/microsoft/azure}/gradle/util/GradleProxyUtils.java (94%) diff --git a/azure-functions-gradle-plugin/build.gradle b/azure-functions-gradle-plugin/build.gradle index 817f880..ed3e747 100644 --- a/azure-functions-gradle-plugin/build.gradle +++ b/azure-functions-gradle-plugin/build.gradle @@ -67,6 +67,8 @@ dependencies { implementation 'com.microsoft.azure:azure-toolkit-applicationinsights-lib:0.9.0' implementation 'com.microsoft.azure:azure-toolkit-appservice-lib:0.9.0' implementation 'com.microsoft.azure:azure-toolkit-applicationinsights-lib:0.9.0' + + implementation project(':azure-gradle-plugins-common') compileOnly 'org.projectlombok:lombok:1.18.20' annotationProcessor 'org.projectlombok:lombok:1.18.20' diff --git a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/AzureFunctionsExtension.java b/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/AzureFunctionsExtension.java index bfe1eb4..bb0812c 100644 --- a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/AzureFunctionsExtension.java +++ b/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/AzureFunctionsExtension.java @@ -5,8 +5,8 @@ package com.microsoft.azure.plugin.functions.gradle; -import com.microsoft.azure.plugin.functions.gradle.configuration.GradleRuntimeConfig; -import com.microsoft.azure.plugin.functions.gradle.configuration.auth.GradleAuthConfig; +import com.microsoft.azure.gradle.auth.GradleAuthConfig; +import com.microsoft.azure.gradle.configuration.GradleRuntimeConfig; import com.microsoft.azure.plugin.functions.gradle.configuration.deploy.Deployment; import groovy.lang.Closure; import org.gradle.api.Project; diff --git a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/AzureFunctionsPlugin.java b/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/AzureFunctionsPlugin.java index 51b2fbe..c810858 100644 --- a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/AzureFunctionsPlugin.java +++ b/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/AzureFunctionsPlugin.java @@ -5,12 +5,12 @@ package com.microsoft.azure.plugin.functions.gradle; import com.azure.core.http.policy.HttpLogDetailLevel; +import com.microsoft.azure.gradle.temeletry.TelemetryAgent; +import com.microsoft.azure.gradle.util.GradleAzureMessager; import com.microsoft.azure.plugin.functions.gradle.task.DeployTask; import com.microsoft.azure.plugin.functions.gradle.task.LocalRunTask; import com.microsoft.azure.plugin.functions.gradle.task.PackageTask; import com.microsoft.azure.plugin.functions.gradle.task.PackageZipTask; -import com.microsoft.azure.plugin.functions.gradle.telemetry.TelemetryAgent; -import com.microsoft.azure.plugin.functions.gradle.util.GradleAzureMessager; import com.microsoft.azure.toolkit.lib.Azure; import com.microsoft.azure.toolkit.lib.common.messager.AzureMessager; import com.microsoft.azure.toolkit.lib.common.proxy.ProxyManager; diff --git a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/GradleFunctionContext.java b/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/GradleFunctionContext.java index 587f01b..06c5060 100644 --- a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/GradleFunctionContext.java +++ b/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/GradleFunctionContext.java @@ -4,9 +4,9 @@ */ package com.microsoft.azure.plugin.functions.gradle; -import com.microsoft.azure.plugin.functions.gradle.configuration.GradleRuntimeConfig; -import com.microsoft.azure.plugin.functions.gradle.configuration.auth.GradleAuthConfig; -import com.microsoft.azure.plugin.functions.gradle.configuration.auth.GradleAuthHelper; +import com.microsoft.azure.gradle.auth.GradleAuthConfig; +import com.microsoft.azure.gradle.auth.GradleAuthHelper; +import com.microsoft.azure.gradle.configuration.GradleRuntimeConfig; import com.microsoft.azure.plugin.functions.gradle.util.GradleProjectUtils; import com.microsoft.azure.toolkit.lib.Azure; import com.microsoft.azure.toolkit.lib.appservice.AzureAppService; diff --git a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/IAppServiceContext.java b/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/IAppServiceContext.java index 5ebeaf7..759f545 100644 --- a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/IAppServiceContext.java +++ b/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/IAppServiceContext.java @@ -5,8 +5,8 @@ package com.microsoft.azure.plugin.functions.gradle; -import com.microsoft.azure.plugin.functions.gradle.configuration.GradleRuntimeConfig; -import com.microsoft.azure.plugin.functions.gradle.configuration.auth.GradleAuthConfig; +import com.microsoft.azure.gradle.auth.GradleAuthConfig; +import com.microsoft.azure.gradle.configuration.GradleRuntimeConfig; import com.microsoft.azure.toolkit.lib.appservice.AzureAppService; import com.microsoft.azure.toolkit.lib.common.IProject; diff --git a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/handler/DeployHandler.java b/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/handler/DeployHandler.java index 9714278..8dfbdda 100644 --- a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/handler/DeployHandler.java +++ b/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/handler/DeployHandler.java @@ -9,9 +9,9 @@ import com.azure.core.management.AzureEnvironment; import com.azure.core.management.exception.ManagementException; import com.google.common.base.Preconditions; import com.microsoft.azure.functions.annotation.AuthorizationLevel; +import com.microsoft.azure.gradle.configuration.GradleRuntimeConfig; +import com.microsoft.azure.gradle.temeletry.TelemetryAgent; import com.microsoft.azure.plugin.functions.gradle.IAppServiceContext; -import com.microsoft.azure.plugin.functions.gradle.configuration.GradleRuntimeConfig; -import com.microsoft.azure.plugin.functions.gradle.telemetry.TelemetryAgent; import com.microsoft.azure.toolkit.lib.Azure; import com.microsoft.azure.toolkit.lib.applicationinsights.ApplicationInsights; import com.microsoft.azure.toolkit.lib.applicationinsights.ApplicationInsightsEntity; diff --git a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/handler/PackageHandler.java b/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/handler/PackageHandler.java index 12a626d..a18199c 100644 --- a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/handler/PackageHandler.java +++ b/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/handler/PackageHandler.java @@ -13,7 +13,6 @@ import com.fasterxml.jackson.databind.SerializationFeature; import com.google.common.base.Preconditions; import com.google.gson.JsonObject; import com.google.gson.JsonParser; - import com.microsoft.azure.toolkit.lib.common.IProject; import com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException; import com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException; diff --git a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/task/DeployTask.java b/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/task/DeployTask.java index feef8e1..6d54877 100644 --- a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/task/DeployTask.java +++ b/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/task/DeployTask.java @@ -5,12 +5,11 @@ package com.microsoft.azure.plugin.functions.gradle.task; +import com.microsoft.azure.gradle.temeletry.TelemetryAgent; +import com.microsoft.azure.gradle.util.GradleProxyUtils; import com.microsoft.azure.plugin.functions.gradle.AzureFunctionsExtension; import com.microsoft.azure.plugin.functions.gradle.GradleFunctionContext; import com.microsoft.azure.plugin.functions.gradle.handler.DeployHandler; -import com.microsoft.azure.plugin.functions.gradle.telemetry.TelemetryAgent; - -import com.microsoft.azure.plugin.functions.gradle.util.GradleProxyUtils; import com.microsoft.azure.toolkit.lib.common.messager.AzureMessager; import org.gradle.api.DefaultTask; import org.gradle.api.GradleException; diff --git a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/task/LocalRunTask.java b/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/task/LocalRunTask.java index 9033d82..162c874 100644 --- a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/task/LocalRunTask.java +++ b/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/task/LocalRunTask.java @@ -4,9 +4,9 @@ */ package com.microsoft.azure.plugin.functions.gradle.task; +import com.microsoft.azure.gradle.temeletry.TelemetryAgent; import com.microsoft.azure.plugin.functions.gradle.AzureFunctionsExtension; import com.microsoft.azure.plugin.functions.gradle.GradleFunctionContext; -import com.microsoft.azure.plugin.functions.gradle.telemetry.TelemetryAgent; import com.microsoft.azure.plugin.functions.gradle.util.FunctionCliResolver; import com.microsoft.azure.plugin.functions.gradle.util.FunctionUtils; import com.microsoft.azure.toolkit.lib.legacy.function.utils.CommandUtils; diff --git a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/task/PackageTask.java b/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/task/PackageTask.java index 9588362..ae004e8 100644 --- a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/task/PackageTask.java +++ b/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/task/PackageTask.java @@ -4,10 +4,10 @@ */ package com.microsoft.azure.plugin.functions.gradle.task; +import com.microsoft.azure.gradle.temeletry.TelemetryAgent; import com.microsoft.azure.plugin.functions.gradle.AzureFunctionsExtension; import com.microsoft.azure.plugin.functions.gradle.GradleFunctionContext; import com.microsoft.azure.plugin.functions.gradle.handler.PackageHandler; -import com.microsoft.azure.plugin.functions.gradle.telemetry.TelemetryAgent; import org.apache.commons.io.FileUtils; import org.gradle.api.DefaultTask; import org.gradle.api.GradleException; diff --git a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/task/PackageZipTask.java b/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/task/PackageZipTask.java index 7248a54..30ef6d8 100644 --- a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/task/PackageZipTask.java +++ b/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/task/PackageZipTask.java @@ -4,12 +4,11 @@ */ package com.microsoft.azure.plugin.functions.gradle.task; +import com.microsoft.azure.gradle.temeletry.TelemetryAgent; import com.microsoft.azure.plugin.functions.gradle.AzureFunctionsExtension; import com.microsoft.azure.plugin.functions.gradle.GradleFunctionContext; import com.microsoft.azure.plugin.functions.gradle.handler.PackageHandler; -import com.microsoft.azure.plugin.functions.gradle.telemetry.TelemetryAgent; import com.microsoft.azure.plugin.functions.gradle.util.FunctionUtils; - import com.microsoft.azure.toolkit.lib.common.messager.AzureMessager; import org.gradle.api.DefaultTask; import org.gradle.api.GradleException; @@ -18,7 +17,6 @@ import org.gradle.api.tasks.TaskAction; import org.zeroturnaround.zip.ZipUtil; import javax.annotation.Nullable; - import java.io.File; import java.io.IOException; diff --git a/azure-functions-gradle-plugin/src/test/java/com/microsoft/azure/plugin/functions/gradle/configuration/GradleRuntimeConfigurationTest.java b/azure-functions-gradle-plugin/src/test/java/com/microsoft/azure/plugin/functions/gradle/configuration/GradleRuntimeConfigTest.java similarity index 88% rename from azure-functions-gradle-plugin/src/test/java/com/microsoft/azure/plugin/functions/gradle/configuration/GradleRuntimeConfigurationTest.java rename to azure-functions-gradle-plugin/src/test/java/com/microsoft/azure/plugin/functions/gradle/configuration/GradleRuntimeConfigTest.java index 06f6458..438df5a 100644 --- a/azure-functions-gradle-plugin/src/test/java/com/microsoft/azure/plugin/functions/gradle/configuration/GradleRuntimeConfigurationTest.java +++ b/azure-functions-gradle-plugin/src/test/java/com/microsoft/azure/plugin/functions/gradle/configuration/GradleRuntimeConfigTest.java @@ -5,12 +5,13 @@ package com.microsoft.azure.plugin.functions.gradle.configuration; +import com.microsoft.azure.gradle.configuration.GradleRuntimeConfig; import org.junit.Before; import org.junit.Test; import static org.junit.Assert.assertEquals; -public class GradleRuntimeConfigurationTest { +public class GradleRuntimeConfigTest { private GradleRuntimeConfig runtime; @Before diff --git a/azure-functions-gradle-plugin/src/test/java/com/microsoft/azure/plugin/functions/gradle/configuration/auth/GradleAuthConfigTest.java b/azure-functions-gradle-plugin/src/test/java/com/microsoft/azure/plugin/functions/gradle/configuration/auth/GradleAuthConfigTest.java index d2b3642..e1602d7 100644 --- a/azure-functions-gradle-plugin/src/test/java/com/microsoft/azure/plugin/functions/gradle/configuration/auth/GradleAuthConfigTest.java +++ b/azure-functions-gradle-plugin/src/test/java/com/microsoft/azure/plugin/functions/gradle/configuration/auth/GradleAuthConfigTest.java @@ -5,6 +5,7 @@ package com.microsoft.azure.plugin.functions.gradle.configuration.auth; +import com.microsoft.azure.gradle.auth.GradleAuthConfig; import org.junit.Before; import org.junit.Test; diff --git a/azure-gradle-plugins-common/build.gradle b/azure-gradle-plugins-common/build.gradle new file mode 100644 index 0000000..e565b44 --- /dev/null +++ b/azure-gradle-plugins-common/build.gradle @@ -0,0 +1,54 @@ + +plugins { + id "net.linguica.maven-settings" version "0.5" + id 'java' +} +apply plugin: 'maven-publish' +apply plugin: 'eclipse' +apply plugin: 'idea' +apply plugin: 'checkstyle' + +repositories { + mavenLocal() + mavenCentral() +} + +checkstyle { + toolVersion '8.36.1'; + // Whether or not to allow the build to continue if there are warnings. + ignoreFailures = false + + // Whether or not rule violations are to be displayed on the console. + showViolations = true +} + +publishing { + repositories { + mavenLocal() + } +} + +dependencies { + implementation 'commons-io:commons-io:2.10.0' + implementation 'org.apache.commons:commons-lang3:3.12.0' + implementation 'com.google.guava:guava:30.1.1-jre' + implementation 'com.microsoft.azure:azure-toolkit-common-lib:0.9.0' + implementation 'com.microsoft.azure:azure-toolkit-resource-lib:0.9.0' + implementation 'com.microsoft.azure:azure-toolkit-appservice-lib:0.9.0' + implementation 'com.microsoft.azure:azure-toolkit-applicationinsights-lib:0.9.0' + testImplementation "junit:junit:4.13.2" + testImplementation "org.mockito:mockito-core:3.11.2" + + compileOnly 'org.projectlombok:lombok:1.18.20' + annotationProcessor 'org.projectlombok:lombok:1.18.20' +} + + + +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + } + } +} diff --git a/azure-gradle-plugins-common/settings.gradle b/azure-gradle-plugins-common/settings.gradle new file mode 100644 index 0000000..9b39b10 --- /dev/null +++ b/azure-gradle-plugins-common/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'azure-gradle-plugins-common' diff --git a/azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/appservice/GradleAppServiceConfig.java b/azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/appservice/GradleAppServiceConfig.java new file mode 100644 index 0000000..7ca85ee --- /dev/null +++ b/azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/appservice/GradleAppServiceConfig.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + */ + +package com.microsoft.azure.gradle.appservice; + +import com.microsoft.azure.gradle.configuration.GradleRuntimeConfig; +import lombok.Getter; +import lombok.Setter; + +import java.util.Map; + +@Getter +@Setter +public class GradleAppServiceConfig { + private String subscriptionId; + private String resourceGroup; + private String region; + private String pricingTier; + private String appName; + private String servicePlanResourceGroup; + private String servicePlanName; + private GradleRuntimeConfig runtime; + private Map appSettings; + private String deploymentSlotName; + private String deploymentSlotConfigurationSource; +} diff --git a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/configuration/auth/GradleAuthConfig.java b/azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/auth/GradleAuthConfig.java similarity index 86% rename from azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/configuration/auth/GradleAuthConfig.java rename to azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/auth/GradleAuthConfig.java index d4b9ca1..62c7876 100644 --- a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/configuration/auth/GradleAuthConfig.java +++ b/azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/auth/GradleAuthConfig.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. */ -package com.microsoft.azure.plugin.functions.gradle.configuration.auth; +package com.microsoft.azure.gradle.auth; import lombok.Getter; import lombok.Setter; diff --git a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/configuration/auth/GradleAuthHelper.java b/azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/auth/GradleAuthHelper.java similarity index 91% rename from azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/configuration/auth/GradleAuthHelper.java rename to azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/auth/GradleAuthHelper.java index f6e632e..d62f3eb 100644 --- a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/configuration/auth/GradleAuthHelper.java +++ b/azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/auth/GradleAuthHelper.java @@ -3,11 +3,12 @@ * Licensed under the MIT License. See License.txt in the project root for license information. */ -package com.microsoft.azure.plugin.functions.gradle.configuration.auth; +package com.microsoft.azure.gradle.auth; import com.azure.core.management.AzureEnvironment; import com.azure.identity.DeviceCodeInfo; -import com.microsoft.azure.plugin.functions.gradle.telemetry.TelemetryAgent; +import com.microsoft.azure.gradle.temeletry.TelemetryAgent; +import com.microsoft.azure.gradle.temeletry.TelemetryConstants; import com.microsoft.azure.toolkit.lib.Azure; import com.microsoft.azure.toolkit.lib.auth.Account; import com.microsoft.azure.toolkit.lib.auth.AzureAccount; @@ -34,11 +35,6 @@ import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; -import static com.microsoft.azure.plugin.functions.gradle.telemetry.TelemetryConstants.AUTH_METHOD_KEY; -import static com.microsoft.azure.plugin.functions.gradle.telemetry.TelemetryConstants.AUTH_TYPE_KEY; -import static com.microsoft.azure.plugin.functions.gradle.telemetry.TelemetryConstants.AZURE_ENVIRONMENT_KEY; -import static com.microsoft.azure.plugin.functions.gradle.telemetry.TelemetryConstants.SUBSCRIPTION_ID_KEY; - public class GradleAuthHelper { protected static final String SUBSCRIPTION_TEMPLATE = "Subscription: %s(%s)"; private static final String USING_AZURE_ENVIRONMENT = "Using Azure environment: %s."; @@ -93,7 +89,7 @@ public class GradleAuthHelper { if (StringUtils.isBlank(targetSubscriptionId) && !subscriptions.isEmpty()) { targetSubscriptionId = subscriptions.stream().map(Subscription::getId).findFirst().orElse(null); } - TelemetryAgent.getInstance().addDefaultProperty(SUBSCRIPTION_ID_KEY, targetSubscriptionId); + TelemetryAgent.getInstance().addDefaultProperty(TelemetryConstants.SUBSCRIPTION_ID_KEY, targetSubscriptionId); return targetSubscriptionId; } @@ -107,9 +103,9 @@ public class GradleAuthHelper { Log.prompt(String.format(USING_AZURE_ENVIRONMENT, TextUtils.cyan(environmentName))); } printCredentialDescription(account, isInteractiveLogin); - TelemetryAgent.getInstance().addDefaultProperty(AUTH_TYPE_KEY, Objects.toString(auth.getType())); - TelemetryAgent.getInstance().addDefaultProperty(AUTH_METHOD_KEY, Objects.toString(account.getAuthType())); - TelemetryAgent.getInstance().addDefaultProperty(AZURE_ENVIRONMENT_KEY, environmentName); + TelemetryAgent.getInstance().addDefaultProperty(TelemetryConstants.AUTH_TYPE_KEY, Objects.toString(auth.getType())); + TelemetryAgent.getInstance().addDefaultProperty(TelemetryConstants.AUTH_METHOD_KEY, Objects.toString(account.getAuthType())); + TelemetryAgent.getInstance().addDefaultProperty(TelemetryConstants.AZURE_ENVIRONMENT_KEY, environmentName); return account; } diff --git a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/configuration/GradleRuntimeConfig.java b/azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/configuration/GradleRuntimeConfig.java similarity index 90% rename from azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/configuration/GradleRuntimeConfig.java rename to azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/configuration/GradleRuntimeConfig.java index bb21b89..15acf10 100644 --- a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/configuration/GradleRuntimeConfig.java +++ b/azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/configuration/GradleRuntimeConfig.java @@ -2,7 +2,8 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. */ -package com.microsoft.azure.plugin.functions.gradle.configuration; + +package com.microsoft.azure.gradle.configuration; import lombok.Getter; import lombok.Setter; diff --git a/azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/configuration/GradleWebAppConfig.java b/azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/configuration/GradleWebAppConfig.java new file mode 100644 index 0000000..ccc1bef --- /dev/null +++ b/azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/configuration/GradleWebAppConfig.java @@ -0,0 +1,20 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + */ + +package com.microsoft.azure.gradle.configuration; + +import com.microsoft.azure.gradle.appservice.GradleAppServiceConfig; +import com.microsoft.azure.toolkit.lib.appservice.model.WebAppArtifact; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +public class GradleWebAppConfig extends GradleAppServiceConfig { + // resources + @Getter + @Setter + private List webAppArtifacts; +} diff --git a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/telemetry/AppInsightsProxy.java b/azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/temeletry/AppInsightsProxy.java similarity index 98% rename from azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/telemetry/AppInsightsProxy.java rename to azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/temeletry/AppInsightsProxy.java index 8a13bfe..04cdbde 100644 --- a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/telemetry/AppInsightsProxy.java +++ b/azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/temeletry/AppInsightsProxy.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. */ -package com.microsoft.azure.plugin.functions.gradle.telemetry; +package com.microsoft.azure.gradle.temeletry; import com.microsoft.applicationinsights.TelemetryClient; import com.microsoft.applicationinsights.channel.TelemetryChannel; diff --git a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/telemetry/TelemetryAgent.java b/azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/temeletry/TelemetryAgent.java similarity index 97% rename from azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/telemetry/TelemetryAgent.java rename to azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/temeletry/TelemetryAgent.java index 0277566..0ad3700 100644 --- a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/telemetry/TelemetryAgent.java +++ b/azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/temeletry/TelemetryAgent.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. */ -package com.microsoft.azure.plugin.functions.gradle.telemetry; +package com.microsoft.azure.gradle.temeletry; import com.microsoft.azure.toolkit.lib.common.messager.AzureMessager; import com.microsoft.azure.toolkit.lib.common.telemetry.AzureTelemeter; @@ -24,7 +24,7 @@ import java.util.Optional; import java.util.Properties; import java.util.UUID; -import static com.microsoft.azure.plugin.functions.gradle.telemetry.TelemetryConstants.*; +import static com.microsoft.azure.gradle.temeletry.TelemetryConstants.*; public class TelemetryAgent implements TelemetryConfiguration { diff --git a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/telemetry/TelemetryConfiguration.java b/azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/temeletry/TelemetryConfiguration.java similarity index 81% rename from azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/telemetry/TelemetryConfiguration.java rename to azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/temeletry/TelemetryConfiguration.java index 7d8d67e..046fbc6 100644 --- a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/telemetry/TelemetryConfiguration.java +++ b/azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/temeletry/TelemetryConfiguration.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. */ -package com.microsoft.azure.plugin.functions.gradle.telemetry; +package com.microsoft.azure.gradle.temeletry; import java.util.Map; diff --git a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/telemetry/TelemetryConstants.java b/azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/temeletry/TelemetryConstants.java similarity index 93% rename from azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/telemetry/TelemetryConstants.java rename to azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/temeletry/TelemetryConstants.java index 269e533..b7c7887 100644 --- a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/telemetry/TelemetryConstants.java +++ b/azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/temeletry/TelemetryConstants.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. */ -package com.microsoft.azure.plugin.functions.gradle.telemetry; +package com.microsoft.azure.gradle.temeletry; public class TelemetryConstants { public static final String TELEMETRY_NOT_ALLOWED = "TelemetryNotAllowed"; diff --git a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/util/GradleAzureMessager.java b/azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/util/GradleAzureMessager.java similarity index 96% rename from azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/util/GradleAzureMessager.java rename to azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/util/GradleAzureMessager.java index ac81fc4..e58f8dc 100644 --- a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/util/GradleAzureMessager.java +++ b/azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/util/GradleAzureMessager.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. */ -package com.microsoft.azure.plugin.functions.gradle.util; +package com.microsoft.azure.gradle.util; import com.microsoft.azure.toolkit.lib.common.messager.IAzureMessage; import com.microsoft.azure.toolkit.lib.common.messager.IAzureMessager; diff --git a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/util/GradleProxyUtils.java b/azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/util/GradleProxyUtils.java similarity index 94% rename from azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/util/GradleProxyUtils.java rename to azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/util/GradleProxyUtils.java index ab83a43..c09e913 100644 --- a/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/util/GradleProxyUtils.java +++ b/azure-gradle-plugins-common/src/main/java/com/microsoft/azure/gradle/util/GradleProxyUtils.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. */ -package com.microsoft.azure.plugin.functions.gradle.util; +package com.microsoft.azure.gradle.util; import com.azure.core.util.Configuration; import com.microsoft.azure.toolkit.lib.common.proxy.ProxyManager; diff --git a/settings.gradle b/settings.gradle index 5274485..53572bc 100644 --- a/settings.gradle +++ b/settings.gradle @@ -23,4 +23,5 @@ */ rootProject.name = 'azure-gradle-plugins' +include 'azure-gradle-plugins-common' include 'azure-functions-gradle-plugin' \ No newline at end of file