Class AbstractAzureMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
    Direct Known Subclasses:
    AbstractAppServiceMojo

    public abstract class AbstractAzureMojo
    extends org.apache.maven.plugin.AbstractMojo
    Base abstract class for all Azure Mojos.
    • Field Detail

      • CONFIGURATION_PATH

        private static final String CONFIGURATION_PATH
      • project

        @Parameter(defaultValue="${project}",
                   readonly=true,
                   required=true)
        protected org.apache.maven.project.MavenProject project
      • session

        @Parameter(defaultValue="${session}",
                   readonly=true,
                   required=true)
        protected org.apache.maven.execution.MavenSession session
      • buildDirectory

        @Parameter(defaultValue="${project.build.directory}",
                   readonly=true,
                   required=true)
        protected File buildDirectory
      • plugin

        @Parameter(defaultValue="${plugin}",
                   readonly=true,
                   required=true)
        protected org.apache.maven.plugin.descriptor.PluginDescriptor plugin
      • settings

        @Parameter(defaultValue="${settings}",
                   readonly=true,
                   required=true)
        protected org.apache.maven.settings.Settings settings
        The system settings for Maven. This is the instance resulting from merging global and user-level settings files.
      • mavenResourcesFiltering

        @Component(role=org.apache.maven.shared.filtering.MavenResourcesFiltering.class,
                   hint="default")
        protected org.apache.maven.shared.filtering.MavenResourcesFiltering mavenResourcesFiltering
      • subscriptionId

        @Parameter
        protected String subscriptionId
        Azure subscription Id. You only need to specify it when:
        • you are using authentication file
        • there are more than one subscription in the authentication file
        Since:
        0.1.0
      • allowTelemetry

        @Parameter(property="allowTelemetry",
                   defaultValue="true")
        protected boolean allowTelemetry
        Boolean flag to turn on/off telemetry within current Maven plugin.
        Since:
        0.1.0
      • failsOnError

        @Parameter(property="failsOnError",
                   defaultValue="true")
        protected boolean failsOnError
        Boolean flag to control whether throwing exception from current Maven plugin when meeting any error.

        If set to true, the exception from current Maven plugin will fail the current Maven run.

        Since:
        0.1.0
      • httpProxyHost

        @Parameter(property="httpProxyHost")
        protected String httpProxyHost
        Use a HTTP proxy host for the Azure Auth Client
      • httpProxyPort

        @Parameter(property="httpProxyPort")
        protected String httpProxyPort
        Use a HTTP proxy port for the Azure Auth Client
      • authType

        @Parameter(property="authType")
        protected String authType
        Authentication type, could be oauth2, device_code, azure_cli,..., see AuthType If this is not set, maven plugin try all available auth methods with certain order
        Since:
        1.2.13
      • settingsDecrypter

        @Component
        protected org.apache.maven.settings.crypto.SettingsDecrypter settingsDecrypter
      • azureAccount

        private com.microsoft.azure.toolkit.lib.auth.Account azureAccount
      • azure

        private com.microsoft.azure.management.Azure azure
      • telemetryProxy

        protected com.microsoft.azure.toolkit.lib.common.telemetry.AzureTelemetryClient telemetryProxy
      • sessionId

        private final String sessionId
      • installationId

        private final String installationId
    • Constructor Detail

      • AbstractAzureMojo

        public AbstractAzureMojo()
    • Method Detail

      • getBuildDirectoryAbsolutePath

        public String getBuildDirectoryAbsolutePath()
      • getInstallationId

        public String getInstallationId()
      • getPluginName

        public String getPluginName()
      • getPluginVersion

        public String getPluginVersion()
      • getUserAgent

        public String getUserAgent()
      • getHttpProxyPort

        public int getHttpProxyPort()
      • getAuthType

        protected String getAuthType()
      • selectSubscription

        protected String selectSubscription​(com.microsoft.azure.toolkit.lib.common.model.Subscription[] subscriptions)
                                     throws com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException
        Throws:
        com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException
      • getAzureAccount

        protected com.microsoft.azure.toolkit.lib.auth.Account getAzureAccount()
                                                                        throws MavenDecryptException,
                                                                               com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException,
                                                                               com.microsoft.azure.toolkit.lib.auth.exception.LoginFailureException
        Throws:
        MavenDecryptException
        com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException
        com.microsoft.azure.toolkit.lib.auth.exception.LoginFailureException
      • selectSubscription

        protected void selectSubscription()
      • login

        protected com.microsoft.azure.toolkit.lib.auth.Account login​(@Nonnull
                                                                     com.microsoft.azure.toolkit.lib.auth.model.AuthConfiguration auth)
      • accountLogin

        private static com.microsoft.azure.toolkit.lib.auth.Account accountLogin​(@Nonnull
                                                                                 com.microsoft.azure.toolkit.lib.auth.model.AuthConfiguration auth)
      • handleDeviceCodeAccount

        private static com.microsoft.azure.toolkit.lib.auth.Account handleDeviceCodeAccount​(com.microsoft.azure.toolkit.lib.auth.Account account)
      • promptAzureEnvironment

        private static void promptAzureEnvironment​(com.azure.core.management.AzureEnvironment env)
      • promptForOAuthOrDeviceCodeLogin

        private static void promptForOAuthOrDeviceCodeLogin​(com.microsoft.azure.toolkit.lib.auth.model.AuthType authType)
      • findFirstAvailableAccount

        private static reactor.core.publisher.Mono<com.microsoft.azure.toolkit.lib.auth.Account> findFirstAvailableAccount()
      • doServicePrincipalLogin

        private static com.microsoft.azure.toolkit.lib.auth.Account doServicePrincipalLogin​(com.microsoft.azure.toolkit.lib.auth.model.AuthConfiguration auth)
      • checkAccountAvailable

        private static reactor.core.publisher.Mono<com.microsoft.azure.toolkit.lib.auth.Account> checkAccountAvailable​(com.microsoft.azure.toolkit.lib.auth.Account account)
      • printCredentialDescription

        protected static void printCredentialDescription​(com.microsoft.azure.toolkit.lib.auth.Account account,
                                                         boolean skipType)
      • initTelemetryProxy

        protected void initTelemetryProxy()
      • printCurrentSubscription

        protected static void printCurrentSubscription​(com.microsoft.azure.management.Azure azure)
      • getTelemetryProperties

        public Map<String,​String> getTelemetryProperties()
      • getActualAuthType

        public String getActualAuthType()
      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • initMavenSettingsProxy

        private static void initMavenSettingsProxy​(org.apache.maven.execution.MavenExecutionRequest request)
      • isSkipMojo

        protected boolean isSkipMojo()
        Sub-class can override this method to decide whether skip execution.
        Returns:
        Boolean to indicate whether skip execution.
      • doExecute

        protected abstract void doExecute()
                                   throws com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException
        Entry point of sub-class. Sub-class should implement this method to do real work.
        Throws:
        com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException
      • onSkipped

        protected void onSkipped()
      • beforeMojoExecution

        protected void beforeMojoExecution()
      • afterMojoExecution

        protected void afterMojoExecution()
      • trackMojoFailure

        protected void trackMojoFailure​(Throwable throwable)
      • highlightDefaultValue

        protected static String highlightDefaultValue​(String defaultValue)
      • onMojoError

        protected void onMojoError​(Exception exception)
                            throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • executeWithTimeRecorder

        protected void executeWithTimeRecorder​(AbstractAzureMojo.RunnableWithException operation,
                                               String name)
                                        throws com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException
        Throws:
        com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException
      • isFirstRun

        private boolean isFirstRun​(Properties prop)
      • updateConfigurationFile

        private void updateConfigurationFile​(Properties prop)
      • infoWithMultipleLines

        public void infoWithMultipleLines​(String messages)
      • getTargetSubscriptionId

        protected String getTargetSubscriptionId​(String defaultSubscriptionId,
                                                 List<com.microsoft.azure.toolkit.lib.common.model.Subscription> subscriptions,
                                                 List<com.microsoft.azure.toolkit.lib.common.model.Subscription> selectedSubscriptions)
                                          throws IOException,
                                                 com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException
        Throws:
        IOException
        com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException
      • checkSubscription

        protected static void checkSubscription​(List<com.microsoft.azure.toolkit.lib.common.model.Subscription> subscriptions,
                                                String targetSubscriptionId)
                                         throws com.microsoft.azure.toolkit.lib.auth.exception.AzureLoginException
        Throws:
        com.microsoft.azure.toolkit.lib.auth.exception.AzureLoginException
      • updateTelemetryProperties

        protected void updateTelemetryProperties()