@@ -13,16 +13,13 @@ import com.intellij.notification.NotificationType
13
13
import com.intellij.openapi.actionSystem.ActionUpdateThread
14
14
import com.intellij.openapi.actionSystem.AnAction
15
15
import com.intellij.openapi.actionSystem.AnActionEvent
16
- import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId
17
- import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener
18
- import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskType
19
16
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil
20
17
import com.intellij.openapi.progress.ProgressIndicator
21
18
import com.intellij.openapi.progress.Task
22
19
import com.intellij.openapi.project.Project
23
20
import org.gradle.tooling.Failure
24
21
import org.gradle.tooling.model.GradleProject
25
- import org.jetbrains.kotlin.idea.configuration.GRADLE_SYSTEM_ID
22
+ import org.jetbrains.plugins.gradle.service.execution.GradleExecutionHelper
26
23
import org.jetbrains.plugins.gradle.settings.GradleExecutionSettings
27
24
import org.jetbrains.plugins.gradle.util.GradleConstants
28
25
@@ -42,7 +39,8 @@ class DownloadSchemaAction : AnAction() {
42
39
}
43
40
44
41
private val DOWNLOAD_SCHEMA_TASK_REGEX = Regex (" download.+ApolloSchemaFrom(Introspection|Registry)" )
45
- private const val SCHEMA_CONFIGURATION_DOC_URL = " https://www.apollographql.com/docs/kotlin/advanced/plugin-configuration#downloading-a-schema"
42
+ private const val SCHEMA_CONFIGURATION_DOC_URL =
43
+ " https://www.apollographql.com/docs/kotlin/advanced/plugin-configuration#downloading-a-schema"
46
44
47
45
private class DownloadSchemaTask (project : Project ) : Task.Backgroundable(
48
46
project,
@@ -51,14 +49,13 @@ private class DownloadSchemaTask(project: Project) : Task.Backgroundable(
51
49
) {
52
50
override fun run (indicator : ProgressIndicator ) {
53
51
val rootProjectPath = project.getGradleRootPath() ? : return
54
- val gradleExecutionHelper = GradleExecutionHelperCompat ()
55
- val executionSettings = ExternalSystemApiUtil .getExecutionSettings<GradleExecutionSettings >(project, rootProjectPath, GradleConstants .SYSTEM_ID )
52
+ val gradleExecutionHelper = GradleExecutionHelper ()
53
+ val executionSettings =
54
+ ExternalSystemApiUtil .getExecutionSettings<GradleExecutionSettings >(project, rootProjectPath, GradleConstants .SYSTEM_ID )
56
55
val rootGradleProject = gradleExecutionHelper.execute(rootProjectPath, executionSettings) { connection ->
57
56
logd(" Fetch Gradle project model" )
58
57
return @execute try {
59
- val id = ExternalSystemTaskId .create(GRADLE_SYSTEM_ID , ExternalSystemTaskType .RESOLVE_PROJECT , project)
60
- gradleExecutionHelper.getModelBuilder(GradleProject ::class .java, connection, id, executionSettings, ExternalSystemTaskNotificationListener .NULL_OBJECT )
61
- .get()
58
+ connection.model<GradleProject >(GradleProject ::class .java).get()
62
59
} catch (t: Throwable ) {
63
60
logw(t, " Couldn't fetch Gradle project model" )
64
61
null
@@ -85,8 +82,7 @@ private class DownloadSchemaTask(project: Project) : Task.Backgroundable(
85
82
86
83
gradleExecutionHelper.execute(rootProjectPath, executionSettings) { connection ->
87
84
try {
88
- val id = ExternalSystemTaskId .create(GRADLE_SYSTEM_ID , ExternalSystemTaskType .EXECUTE_TASK , project)
89
- gradleExecutionHelper.getBuildLauncher(connection, id, allDownloadSchemaTasks, executionSettings, ExternalSystemTaskNotificationListener .NULL_OBJECT )
85
+ connection.newBuild()
90
86
.forTasks(* allDownloadSchemaTasks.toTypedArray())
91
87
.addProgressListener(object : SimpleProgressListener () {
92
88
override fun onFailure (failures : List <Failure >) {
@@ -95,14 +91,16 @@ private class DownloadSchemaTask(project: Project) : Task.Backgroundable(
95
91
project = project,
96
92
title = ApolloBundle .message(" action.DownloadSchemaAction.buildFail.title" ),
97
93
content = ApolloBundle .message(" action.DownloadSchemaAction.buildFail.content" , failures.firstOrNull()?.message
98
- ? : " (no message)" , allDownloadSchemaTasks.joinToString(" " )),
94
+ ? : " (no message)" , allDownloadSchemaTasks.joinToString(" " )
95
+ ),
99
96
type = NotificationType .WARNING
100
97
)
101
98
}
102
99
103
100
override fun onSuccess () {
104
101
super .onSuccess()
105
- val schemas = if (allDownloadSchemaTasks.size > 1 ) ApolloBundle .message(" action.DownloadSchemaAction.schema.plural" ) else ApolloBundle .message(" action.DownloadSchemaAction.schema.singular" )
102
+ val schemas =
103
+ if (allDownloadSchemaTasks.size > 1 ) ApolloBundle .message(" action.DownloadSchemaAction.schema.plural" ) else ApolloBundle .message(" action.DownloadSchemaAction.schema.singular" )
106
104
showNotification(
107
105
project = project,
108
106
content = ApolloBundle .message(" action.DownloadSchemaAction.buildSuccess.content" , schemas),
0 commit comments