ASPR-3486 Проблемы с Maven

(cherry picked from commit 3753bc956b)
This commit is contained in:
Egor
2026-09-17 12:44:38 +04:00
committed by Nikita Iarychenko
parent d4c21040ad
commit 23c33937d9
5 changed files with 56 additions and 3 deletions
@@ -1,4 +1,7 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
//
// Modified by Egor Prokopov at 2026 as part of the OpenIDE project(https://openide.ru).
// Any modifications are available on the same license terms as the original source code.
package org.jetbrains.idea.maven.execution;
import com.intellij.execution.target.LanguageRuntimeConfiguration;
@@ -70,6 +73,8 @@ public class MavenRunnerPanel {
ui.envVariablesComponent.setEnvs(data.getEnvironmentProperties());
ui.envVariablesComponent.setPassParentEnvs(data.isPassParentEnv());
ui.scriptDirField.setText(data.getScriptDirectory());
}
@@ -86,6 +91,7 @@ public class MavenRunnerPanel {
data.setMavenProperties(ui.propertiesPanel.getDataAsMap());
data.setEnvironmentProperties(ui.envVariablesComponent.getEnvs());
data.setPassParentEnv(ui.envVariablesComponent.isPassParentEnvs());
data.setScriptDirectory(ui.scriptDirField.getText().trim());
}
public Project getProject() {
@@ -1,4 +1,7 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
//
// Modified by Egor Prokopov at 2026 as part of the OpenIDE project(https://openide.ru).
// Any modifications are available on the same license terms as the original source code.
package org.jetbrains.idea.maven.execution;
import com.intellij.openapi.Disposable;
@@ -30,6 +33,8 @@ public class MavenRunnerSettings implements Cloneable {
private Map<String, String> environmentProperties = new HashMap<>();
private boolean passParentEnv = true;
private @NotNull String scriptDirectory = "";
private DisposableWrapperList<Listener> myListeners = new DisposableWrapperList<>();
public boolean isDelegateBuildToMaven() {
@@ -98,6 +103,14 @@ public class MavenRunnerSettings implements Cloneable {
this.passParentEnv = passParentEnv;
}
public @NotNull @NlsSafe String getScriptDirectory() {
return scriptDirectory;
}
public void setScriptDirectory(@Nullable String scriptDirectory) {
this.scriptDirectory = Objects.requireNonNullElse(scriptDirectory, "");
}
public void addListener(@NotNull Listener l, @NotNull Disposable disposable) {
myListeners.add(l, disposable);
}
@@ -130,6 +143,7 @@ public class MavenRunnerSettings implements Cloneable {
if (!vmOptions.equals(that.vmOptions)) return false;
if (!environmentProperties.equals(that.environmentProperties)) return false;
if (passParentEnv != that.passParentEnv) return false;
if (!scriptDirectory.equals(that.scriptDirectory)) return false;
return true;
}
@@ -143,6 +157,7 @@ public class MavenRunnerSettings implements Cloneable {
result = 31 * result + (skipTests ? 1 : 0);
result = 31 * result + environmentProperties.hashCode();
result = 31 * result + (mavenProperties != null ? mavenProperties.hashCode() : 0);
result = 31 * result + scriptDirectory.hashCode();
return result;
}
@@ -1,13 +1,20 @@
// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
//
// Modified by Egor Prokopov at 2026 as part of the OpenIDE project(https://openide.ru).
// Any modifications are available on the same license terms as the original source code.
package org.jetbrains.idea.maven.execution
import com.intellij.execution.configuration.EnvironmentVariablesComponent
import com.intellij.openapi.application.PathManager
import com.intellij.openapi.externalSystem.service.ui.ExternalSystemJdkComboBox
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.ComboBox
import com.intellij.openapi.ui.TextFieldWithBrowseButton
import com.intellij.ui.ClientProperty
import com.intellij.ui.RawCommandLineEditor
import com.intellij.ui.UserActivityWatcher
import com.intellij.ui.components.JBTextField
import com.intellij.ui.dsl.builder.Align
import com.intellij.ui.dsl.builder.AlignX
import com.intellij.ui.dsl.builder.Row
@@ -35,6 +42,8 @@ internal class MavenRunnerUi(project: Project, runConfigurationMode: Boolean, pr
@JvmField
val propertiesPanel = MavenPropertiesPanel(properties)
lateinit var scriptDirField: TextFieldWithBrowseButton
private lateinit var jdkRow: Row
private lateinit var targetJdkRow: Row
@@ -73,6 +82,20 @@ internal class MavenRunnerUi(project: Project, runConfigurationMode: Boolean, pr
}
}
row(MavenConfigurableBundle.message("maven.settings.runner.script.dir")) {
val fileChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor()
.withTitle(MavenConfigurableBundle.message("maven.settings.runner.script.dir.title"))
scriptDirField = textFieldWithBrowseButton(fileChooserDescriptor, project)
.align(AlignX.FILL)
.applyToComponent {
val scriptDirTooltip = MavenConfigurableBundle.message("maven.settings.runner.script.dir.tooltip")
toolTipText = scriptDirTooltip
textField.toolTipText = scriptDirTooltip
(textField as JBTextField).emptyText.text = PathManager.getTempPath()
}
.component
}
group(MavenConfigurableBundle.message("maven.settings.runner.properties"), indent = false) {
row {
skipTestsCheckBox = checkBox(MavenConfigurableBundle.message("maven.settings.runner.skip.tests"))
@@ -1,5 +1,7 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
//
// Modified by Egor Prokopov at 2026 as part of the OpenIDE project(https://openide.ru).
// Any modifications are available on the same license terms as the original source code.
package org.jetbrains.idea.maven.execution.run
import com.intellij.build.BuildDescriptor
@@ -33,12 +35,12 @@ import com.intellij.execution.ui.ConsoleView
import com.intellij.execution.util.ProgramParametersUtil
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.DefaultActionGroup
import com.intellij.openapi.application.PathManager
import com.intellij.openapi.application.readAction
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskType
import com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfigurationViewManager
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.util.io.FileUtilRt
import com.intellij.openapi.util.registry.Registry
import com.intellij.platform.eel.EelApi
import com.intellij.platform.eel.EelOsFamily
@@ -225,7 +227,8 @@ class MavenShCommandLineState(val environment: ExecutionEnvironment, private val
tmpData.append(commandPrefix).append(batParams.list.joinToString(" ") { CommandLineUtil.escapeParameterOnWindows(it, true) })
val tempDirectory = FileUtilRt.getTempDirectory()
val runnerSettings = myConfiguration.runnerSettings ?: MavenRunner.getInstance(myConfiguration.project).state
val tempDirectory = runnerSettings.scriptDirectory.takeIf { it.isNotBlank() } ?: PathManager.getTempDir().toString()
val tmpBat = FileUtil.createTempFile(java.io.File(tempDirectory), "mvn-idea-exec", ".bat", false, true)
@@ -2,6 +2,9 @@
#
# Modified by Nikita Iarychenko at 2025 as part of the OpenIDE project(https://openide.ru).
# Any modifications are available on the same license terms as the original source code.
#
# Modified by Egor Prokopov at 2026 as part of the OpenIDE project(https://openide.ru).
# Any modifications are available on the same license terms as the original source code.
maven.settings.override=Override
maven.settings.environment.home.directory=Maven &home path
maven.settings.on.targets.environment.home.directory=Maven &home path on {0}
@@ -106,6 +109,9 @@ maven.settings.runner.vm.options=&VM Options:
maven.settings.runner.jre=&JRE:
maven.settings.runner.properties=Properties:
maven.settings.runner.skip.tests=Skip &Tests
maven.settings.runner.script.dir=Maven &script directory:
maven.settings.runner.script.dir.title=Select Maven Script Directory
maven.settings.runner.script.dir.tooltip=<html>Directory for the temporary Maven launcher script (mvn-idea-exec.bat).<br/>Leave empty to use the IDE temp dir. Override when AppLocker or Group Policy<br/>forbids script execution from system or %LOCALAPPDATA% temp folders.</html>
maven.settings.runner.properties.not.defined=No properties defined
maven.settings.archetype.add.repository=<html>Repository <i>(optional)</i></html>
maven.settings.archetype.add.groupid=GroupId