Repository: hannah-sten/texify-idea
Issue: Unable to run an application properly with activated TeXiFy plugin

#### Type of JetBrains IDE (IntelliJ, PyCharm, etc.) and version
IntelliJ IDEA 2023.1.2 (Ultimate Edition) Build #IU-231.9011.34

#### Operating System 
macOS 13.3.1 (a) Apple M1 Pro


#### TeXiFy IDEA version
0.7.30-alpha.3

#### What I did (steps to reproduce)
I run a java application.

#### Expected behavior
The maven built step should be executed before the application starts.

#### Actual behavior
The maven built step is not executed.

Changed files:
src/nl/hannahsten/texifyidea/modules/LatexModuleType.kt, src/nl/hannahsten/texifyidea/util/Projects.kt, src/nl/hannahsten/texifyidea/run/LatexProjectTaskRunner.kt

diff --git a/src/nl/hannahsten/texifyidea/modules/LatexModuleType.kt b/src/nl/hannahsten/texifyidea/modules/LatexModuleType.kt
index e41ed5035..4df182725 100644
--- a/src/nl/hannahsten/texifyidea/modules/LatexModuleType.kt
+++ b/src/nl/hannahsten/texifyidea/modules/LatexModuleType.kt
@@ -5,6 +5,8 @@ import nl.hannahsten.texifyidea.TexifyIcons
 
 /**
  * Note: ModuleTypes are deprecated, see [ModuleType].
+ * Therefore, we do not register it in plugin.xml, so it won't show to the user.
+ * We still use it for new project creation though.
  *
  * @author Sten Wessel
  */
diff --git a/src/nl/hannahsten/texifyidea/run/LatexProjectTaskRunner.kt b/src/nl/hannahsten/texifyidea/run/LatexProjectTaskRunner.kt
index ec2f5c378..c4c37354c 100644
--- a/src/nl/hannahsten/texifyidea/run/LatexProjectTaskRunner.kt
+++ b/src/nl/hannahsten/texifyidea/run/LatexProjectTaskRunner.kt
@@ -1,16 +1,19 @@
 package nl.hannahsten.texifyidea.run
 
+import com.intellij.execution.RunManager
 import com.intellij.execution.executors.DefaultRunExecutor
 import com.intellij.execution.impl.RunConfigurationBeforeRunProvider
 import com.intellij.execution.impl.RunManagerImpl
 import com.intellij.execution.runners.ExecutionEnvironmentBuilder
+import com.intellij.openapi.module.ModuleType
 import com.intellij.openapi.project.Project
 import com.intellij.task.ModuleBuildTask
 import com.intellij.task.ProjectTask
 import com.intellij.task.ProjectTaskContext
 import com.intellij.task.ProjectTaskRunner
+import nl.hannahsten.texifyidea.modules.LatexModuleType
+import nl.hannahsten.texifyidea.run.latex.LatexRunConfiguration
 import nl.hannahsten.texifyidea.util.getLatexRunConfigurations
-import nl.hannahsten.texifyidea.util.isLatexProject
 import org.jetbrains.concurrency.AsyncPromise
 import org.jetbrains.concurrency.Promise
 
@@ -22,7 +25,8 @@ import org.jetbrains.concurrency.Promise
 class LatexProjectTaskRunner : ProjectTaskRunner() {
 
     override fun canRun(projectTask: ProjectTask): Boolean {
-        return projectTask is ModuleBuildTask && projectTask.module.project.isLatexProject()
+        // Only run if we're only going to build LaTeX run configurations: don't interfere with other languages (e.g. maven tasks)
+        return projectTask is ModuleBuildTask && (ModuleType.get(projectTask.module).id == LatexModuleType.ID || RunManager.getInstance(projectTask.module.project).allConfigurationsList.all { it is LatexRunConfiguration })
     }
 
     override fun run(project: Project, context: ProjectTaskContext, vararg tasks: ProjectTask?): Promise<Result> {
diff --git a/src/nl/hannahsten/texifyidea/util/Projects.kt b/src/nl/hannahsten/texifyidea/util/Projects.kt
index eedc0d7fe..869e9a2c8 100644
--- a/src/nl/hannahsten/texifyidea/util/Projects.kt
+++ b/src/nl/hannahsten/texifyidea/util/Projects.kt
@@ -1,7 +1,6 @@
 package nl.hannahsten.texifyidea.util
 
 import com.intellij.execution.RunManager
-import com.intellij.execution.impl.RunManagerImpl
 import com.intellij.openapi.application.ApplicationNamesInfo
 import com.intellij.openapi.application.runReadAction
 import com.intellij.openapi.fileEditor.FileEditorManager
@@ -81,7 +80,7 @@ fun Project.allFiles(type: FileType): Collection<VirtualFile> {
  */
 fun Project.getLatexRunConfigurations(): Collection<LatexRunConfiguration> {
     if (isDisposed) return emptyList()
-    return (RunManagerImpl.getInstanceImpl(this) as RunManager).allConfigurationsList.filterIsInstance<LatexRunConfiguration>()
+    return RunManager.getInstance(this).allConfigurationsList.filterIsInstance<LatexRunConfiguration>()
 }
 
 /**