mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
avoid duplicates in Gradle beforeRunTask import.
Fixes https://github.com/JetBrains/gradle-idea-ext-plugin/issues/15
This commit is contained in:
+11
@@ -14,6 +14,17 @@ import java.util.Map;
|
||||
public interface BeforeRunTaskImporter {
|
||||
ExtensionPointName<BeforeRunTaskImporter> EP_NAME = ExtensionPointName.create("com.intellij.externalSystem.beforeRunTaskImporter");
|
||||
|
||||
/**
|
||||
* Given a map of configuration settings,
|
||||
* optionally create relevant BeforeRunTask if it is missing from beforeRunTasks list
|
||||
*
|
||||
* @param project
|
||||
* @param modelsProvider
|
||||
* @param runConfiguration
|
||||
* @param beforeRunTasks
|
||||
* @param cfg
|
||||
* @return
|
||||
*/
|
||||
List<BeforeRunTask> process(@NotNull Project project,
|
||||
@NotNull IdeModifiableModelsProvider modelsProvider,
|
||||
@NotNull RunConfiguration runConfiguration,
|
||||
|
||||
+11
-1
@@ -5,6 +5,7 @@ import com.intellij.execution.BeforeRunTask
|
||||
import com.intellij.execution.BeforeRunTaskProvider
|
||||
import com.intellij.execution.configurations.RunConfiguration
|
||||
import com.intellij.openapi.externalSystem.model.project.settings.ConfigurationData
|
||||
import com.intellij.openapi.externalSystem.service.execution.ExternalSystemBeforeRunTask
|
||||
import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider
|
||||
import com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManagerImpl
|
||||
import com.intellij.openapi.externalSystem.service.project.manage.ExternalSystemTaskActivator
|
||||
@@ -30,7 +31,16 @@ class GradleBeforeRunTaskImporter: BeforeRunTaskImporter {
|
||||
consumeIfCast(cfg["projectPath"], String::class.java) { externalProjectPath = it }
|
||||
}
|
||||
task.isEnabled = true
|
||||
beforeRunTasks.add(task)
|
||||
|
||||
val taskExists = beforeRunTasks.filterIsInstance<ExternalSystemBeforeRunTask>()
|
||||
.any {
|
||||
it.taskExecutionSettings.taskNames == task.taskExecutionSettings.taskNames &&
|
||||
it.taskExecutionSettings.externalProjectPath == task.taskExecutionSettings.externalProjectPath
|
||||
}
|
||||
|
||||
if (!taskExists) {
|
||||
beforeRunTasks.add(task)
|
||||
}
|
||||
return beforeRunTasks
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user