User: kyle wood Date: 19 Jan 26 21:21 Revision: 419823852f2350b939a6b5eef713e0482f83540c Summary: Open Build tool window for Maven import as well TeamCity URL: http://ci.mcdev.io:80/viewModification.html?tab=vcsModificationFiles&modId=10403&personal=false Index: src/main/kotlin/creator/custom/finalizers/ImportGradleProjectFinalizer.kt =================================================================== --- src/main/kotlin/creator/custom/finalizers/ImportGradleProjectFinalizer.kt (revision b4398bed90d60211504e405a30d81abe8cc6be6e) +++ src/main/kotlin/creator/custom/finalizers/ImportGradleProjectFinalizer.kt (revision 419823852f2350b939a6b5eef713e0482f83540c) @@ -50,26 +50,30 @@ linkAndSyncGradleProject(project, projectDir) } + openBuildToolWindow(project) + + link.await() + + thisLogger().info("Linking done") + } + } +} + +suspend fun openBuildToolWindow(project: Project) = coroutineScope { - runCatching { - // Try to open the tool window after starting the sync. - // Having the tool window open will provide better context to the user about what's going on. - // The Build tool window isn't registered until a build is running, so we can't just open the tool window - // like normal here, we have to wait until after the build starts. - val manager = ToolWindowManager.getInstance(project) + runCatching { + // Try to open the tool window after starting the sync. + // Having the tool window open will provide better context to the user about what's going on. + // The Build tool window isn't registered until a build is running, so we can't just open the tool window + // like normal here, we have to wait until after the build starts. + val manager = ToolWindowManager.getInstance(project) - for (i in 0 until 10) { + for (i in 0 until 5) { - delay(250) - manager.getToolWindow("Build")?.let { - withContext(Dispatchers.EDT) { - it.show() - } - break - } - } - } + delay(250) + manager.getToolWindow("Build")?.let { + withContext(Dispatchers.EDT) { + it.show() + } + break + } + } + } - - link.await() - - thisLogger().info("Linking done") - } +} - } -} Index: src/main/kotlin/creator/custom/finalizers/ImportMavenProjectFinalizer.kt =================================================================== --- src/main/kotlin/creator/custom/finalizers/ImportMavenProjectFinalizer.kt (revision b4398bed90d60211504e405a30d81abe8cc6be6e) +++ src/main/kotlin/creator/custom/finalizers/ImportMavenProjectFinalizer.kt (revision 419823852f2350b939a6b5eef713e0482f83540c) @@ -25,6 +25,8 @@ import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VfsUtil import java.nio.file.Path +import kotlinx.coroutines.async +import kotlinx.coroutines.coroutineScope import org.jetbrains.idea.maven.buildtool.MavenSyncSpec import org.jetbrains.idea.maven.project.MavenProjectsManager @@ -35,16 +37,23 @@ project: Project, properties: Map, templateProperties: Map - ) { + ) = coroutineScope { val projectDir = context.projectFileDirectory val pomFile = VfsUtil.findFile(Path.of(projectDir).resolve("pom.xml"), true) - ?: return + ?: return@coroutineScope thisLogger().info("Invoking import on EDT pomFile = ${pomFile.path}") val projectsManager = MavenProjectsManager.getInstance(project) projectsManager.addManagedFiles(listOf(pomFile)) + + val import = async { - projectsManager.updateAllMavenProjects(MavenSyncSpec.incremental("ImportMavenProjectFinalizer", false)) + projectsManager.updateAllMavenProjects(MavenSyncSpec.incremental("ImportMavenProjectFinalizer", false)) + } + openBuildToolWindow(project) + + import.await() + thisLogger().info("Import finished") } }