Search in sources :

Example 1 with MavenAzureMessager

use of com.microsoft.azure.toolkit.maven.common.messager.MavenAzureMessager in project azure-maven-plugins by microsoft.

the class AbstractAzureMojo method execute.

// region Entry Point
@Override
public void execute() throws MojoExecutionException {
    try {
        AzureMessager.setDefaultMessager(new MavenAzureMessager());
        Azure.az().config().setLogLevel(HttpLogDetailLevel.NONE.name());
        Azure.az().config().setUserAgent(getUserAgent());
        // init proxy manager
        initMavenSettingsProxy(Optional.ofNullable(this.session).map(MavenSession::getRequest).orElse(null));
        ProxyManager.getInstance().applyProxy();
        initTelemetryProxy();
        telemetryProxy.addDefaultProperty(PROXY, String.valueOf(ProxyManager.getInstance().isProxyEnabled()));
        // Work around for Application Insights Java SDK:
        // Sometimes, NoClassDefFoundError will be thrown even after Maven build is completed successfully.
        // An issue has been filed at https://github.com/Microsoft/ApplicationInsights-Java/issues/416
        // Before this issue is fixed, set default uncaught exception handler for all threads as work around.
        Thread.setDefaultUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler());
        final Properties prop = new Properties();
        if (isFirstRun(prop)) {
            infoWithMultipleLines(PRIVACY_STATEMENT);
            updateConfigurationFile(prop);
        }
        if (isSkipMojo()) {
            Log.info("Skip execution.");
            onSkipped();
        } else {
            beforeMojoExecution();
            doExecute();
            afterMojoExecution();
        }
    } catch (Exception e) {
        onMojoError(e);
    } finally {
        // /main/java/com/microsoft/applicationinsights/internal/channel/common/ApacheSender43.java#L103
        try {
            // Sleep to wait ai sdk flush telemetries
            Thread.sleep(2 * 1000);
        } catch (InterruptedException e) {
        // swallow this exception
        }
        ApacheSenderFactory.INSTANCE.create().close();
    }
}
Also used : MavenAzureMessager(com.microsoft.azure.toolkit.maven.common.messager.MavenAzureMessager) MavenSession(org.apache.maven.execution.MavenSession) Properties(java.util.Properties) AzureExecutionException(com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException) LoginFailureException(com.microsoft.azure.toolkit.lib.auth.exception.LoginFailureException) AzureToolkitAuthenticationException(com.microsoft.azure.toolkit.lib.auth.exception.AzureToolkitAuthenticationException) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) AzureLoginException(com.microsoft.azure.toolkit.lib.auth.exception.AzureLoginException) MavenDecryptException(com.microsoft.azure.maven.exception.MavenDecryptException)

Aggregations

MavenDecryptException (com.microsoft.azure.maven.exception.MavenDecryptException)1 AzureLoginException (com.microsoft.azure.toolkit.lib.auth.exception.AzureLoginException)1 AzureToolkitAuthenticationException (com.microsoft.azure.toolkit.lib.auth.exception.AzureToolkitAuthenticationException)1 LoginFailureException (com.microsoft.azure.toolkit.lib.auth.exception.LoginFailureException)1 AzureExecutionException (com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException)1 MavenAzureMessager (com.microsoft.azure.toolkit.maven.common.messager.MavenAzureMessager)1 IOException (java.io.IOException)1 Properties (java.util.Properties)1 MavenSession (org.apache.maven.execution.MavenSession)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1