split gradle plugin common to allow sharing code between gradle webapp plugins (#87)
This commit is contained in:
Родитель
5140ea5016
Коммит
d93ca48af4
|
@ -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'
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
rootProject.name = 'azure-gradle-plugins-common'
|
|
@ -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<String, String> appSettings;
|
||||
private String deploymentSlotName;
|
||||
private String deploymentSlotConfigurationSource;
|
||||
}
|
|
@ -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;
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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;
|
|
@ -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<WebAppArtifact> webAppArtifacts;
|
||||
}
|
|
@ -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;
|
|
@ -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 {
|
||||
|
|
@ -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;
|
||||
|
|
@ -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";
|
|
@ -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;
|
|
@ -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;
|
|
@ -23,4 +23,5 @@
|
|||
*/
|
||||
rootProject.name = 'azure-gradle-plugins'
|
||||
|
||||
include 'azure-gradle-plugins-common'
|
||||
include 'azure-functions-gradle-plugin'
|
Загрузка…
Ссылка в новой задаче