public void execute()

in azure-maven-plugin-lib/src/main/java/com/microsoft/azure/maven/AbstractAzureMojo.java [495:545]


    public void execute() throws MojoExecutionException {
        try {
            MavenActionManager.register();
            AzureTaskManager.register(new MavenAzureTaskManager());
            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 {
            // When maven goal executes too quick, The HTTPClient of AI SDK may not fully initialize and will step
            // into endless loop when close, we need to call it in main thread.
            // Refer here for detail codes: https://github.com/Microsoft/ApplicationInsights-Java/blob/master/core/src
            // /main/java/com/microsoft/applicationinsights/internal/channel/common/ApacheSender43.java#L103
            Optional.ofNullable(TextIOUtils.getTextTerminal()).ifPresent(TextTerminal::dispose);
            try {
                // Sleep to wait ai sdk flush telemetries
                Thread.sleep(2 * 1000);
            } catch (InterruptedException e) {
                // swallow this exception
            }
            ApacheSenderFactory.INSTANCE.create().close();
        }
    }