void (@NotNull ExternalSystemTaskId id, @NotNull String projectPath, @NotNull GradleExecutionSettings settings, @Nullable GradleVersion gradleVersion, @NotNull ExternalSystemTaskNotificationListener listener, @NotNull ProjectConnection connection, @NotNull CancellationToken cancellationToken) { long ttlInMs = settings.getRemoteProcessIdleTtlInMs(); try { settings.setRemoteProcessIdleTtlInMs(100); if (ExternalSystemExecutionAware.Companion.getEnvironmentConfigurationProvider(settings) != null) { // todo add the support for org.jetbrains.plugins.gradle.settings.DistributionType.WRAPPED executeWrapperTask(id, settings, projectPath, listener, connection, cancellationToken); Path wrapperPropertiesFile = GradleUtil.findDefaultWrapperPropertiesFile(projectPath); if (wrapperPropertiesFile != null) { settings.setWrapperPropertyFile(wrapperPropertiesFile.toString()); } } else { Supplier<String> propertiesFile = setupWrapperTaskInInitScript(gradleVersion, settings); executeWrapperTask(id, settings, projectPath, listener, connection, cancellationToken); String wrapperPropertiesFile = propertiesFile.get(); if (wrapperPropertiesFile != null) { settings.setWrapperPropertyFile(wrapperPropertiesFile); } } } catch (ProcessCanceledException e) { throw e; } catch (IOException e) { LOG.warn("Can't update wrapper", e); } catch (Throwable e) { LOG.warn("Can't update wrapper", e); Throwable rootCause = ExceptionUtil.getRootCause(e); ExternalSystemException externalSystemException = new ExternalSystemException(ExceptionUtil.getMessage(rootCause)); externalSystemException.initCause(e); throw externalSystemException; } finally { settings.setRemoteProcessIdleTtlInMs(ttlInMs); try { // if autoimport is active, it should be notified of new files creation as early as possible, // to avoid triggering unnecessary re-imports (caused by creation of wrapper) VfsUtil.markDirtyAndRefresh(false, true, true, Path.of(projectPath, "gradle").toFile()); } catch (IllegalPathStateException ignore) { } } }