boolean (@NotNull ExternalSystemRunConfiguration configuration, @NotNull ConfigurationContext context, @NotNull Ref<PsiElement> sourceElement) { ExternalSystemTaskExecutionSettings taskExecutionSettings = configuration.getSettings(); if (!GradleConstants.SYSTEM_ID.equals(taskExecutionSettings.getExternalSystemId())) return false; final Location contextLocation = context.getLocation(); if (!isFromGroovyGradleScript(contextLocation)) return false; final Module module = context.getModule(); if (module == null) return false; String projectPath = resolveProjectPath(module); if (projectPath == null) { VirtualFile virtualFile = contextLocation.getVirtualFile(); projectPath = virtualFile != null ? virtualFile.getPath() : null; } if (projectPath == null) { return false; } List<String> tasksToRun = getTasksTarget(contextLocation); taskExecutionSettings.setExternalProjectPath(projectPath); taskExecutionSettings.setTaskNames(tasksToRun); configuration.setName(AbstractExternalSystemTaskConfigurationType.generateName(module.getProject(), taskExecutionSettings)); return true; }