use of com.intellij.openapi.externalSystem.model.task.event.ExternalSystemProgressEventUnsupportedImpl in project intellij-community by JetBrains.
the class GradleTaskManager method executeTasks.
@Override
public void executeTasks(@NotNull final ExternalSystemTaskId id, @NotNull final List<String> taskNames, @NotNull String projectPath, @Nullable GradleExecutionSettings settings, @Nullable final String jvmAgentSetup, @NotNull final ExternalSystemTaskNotificationListener listener) throws ExternalSystemException {
// TODO add support for external process mode
if (ExternalSystemApiUtil.isInProcessMode(GradleConstants.SYSTEM_ID)) {
for (GradleTaskManagerExtension gradleTaskManagerExtension : GradleTaskManagerExtension.EP_NAME.getExtensions()) {
if (gradleTaskManagerExtension.executeTasks(id, taskNames, projectPath, settings, jvmAgentSetup, listener)) {
return;
}
}
}
GradleExecutionSettings effectiveSettings = settings == null ? new GradleExecutionSettings(null, null, DistributionType.BUNDLED, false) : settings;
Function<ProjectConnection, Void> f = connection -> {
final List<String> initScripts = ContainerUtil.newArrayList();
final GradleProjectResolverExtension projectResolverChain = GradleProjectResolver.createProjectResolverChain(effectiveSettings);
for (GradleProjectResolverExtension resolverExtension = projectResolverChain; resolverExtension != null; resolverExtension = resolverExtension.getNext()) {
final String resolverClassName = resolverExtension.getClass().getName();
resolverExtension.enhanceTaskProcessing(taskNames, jvmAgentSetup, script -> {
if (StringUtil.isNotEmpty(script)) {
ContainerUtil.addAllNotNull(initScripts, "//-- Generated by " + resolverClassName, script, "//");
}
});
}
final String initScript = effectiveSettings.getUserData(INIT_SCRIPT_KEY);
if (StringUtil.isNotEmpty(initScript)) {
ContainerUtil.addAll(initScripts, "//-- Additional script", initScript, "//");
}
if (!initScripts.isEmpty()) {
try {
File tempFile = GradleExecutionHelper.writeToFileGradleInitScript(StringUtil.join(initScripts, SystemProperties.getLineSeparator()));
effectiveSettings.withArguments(GradleConstants.INIT_SCRIPT_CMD_OPTION, tempFile.getAbsolutePath());
} catch (IOException e) {
throw new ExternalSystemException(e);
}
}
GradleVersion gradleVersion = GradleExecutionHelper.getGradleVersion(connection);
if (gradleVersion != null && gradleVersion.compareTo(GradleVersion.version("2.5")) < 0) {
listener.onStatusChange(new ExternalSystemTaskExecutionEvent(id, new ExternalSystemProgressEventUnsupportedImpl(gradleVersion + " does not support executions view")));
}
for (GradleBuildParticipant buildParticipant : effectiveSettings.getExecutionWorkspace().getBuildParticipants()) {
effectiveSettings.withArguments(GradleConstants.INCLUDE_BUILD_CMD_OPTION, buildParticipant.getProjectPath());
}
BuildLauncher launcher = myHelper.getBuildLauncher(id, connection, effectiveSettings, listener);
launcher.forTasks(ArrayUtil.toStringArray(taskNames));
if (gradleVersion != null && gradleVersion.compareTo(GradleVersion.version("2.1")) < 0) {
myCancellationMap.put(id, new UnsupportedCancellationToken());
} else {
final CancellationTokenSource cancellationTokenSource = GradleConnector.newCancellationTokenSource();
launcher.withCancellationToken(cancellationTokenSource.token());
myCancellationMap.put(id, cancellationTokenSource);
}
try {
launcher.run();
} finally {
myCancellationMap.remove(id);
}
return null;
};
myHelper.execute(projectPath, effectiveSettings, f);
}
Aggregations