mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-355465 Multiple Projects In Workspace: multimodule Gradle projects loose their JDK
fix gradle jdk on import GitOrigin-RevId: e3662b135fde7e07b76ec962a1c02b49744df5a9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e26bd43692
commit
f9f7fd7da6
+43
-36
@@ -26,6 +26,7 @@ import org.jetbrains.plugins.gradle.service.execution.GradleDaemonJvmHelper
|
||||
import org.jetbrains.plugins.gradle.service.project.GradleNotification
|
||||
import org.jetbrains.plugins.gradle.service.project.GradleNotificationIdsHolder
|
||||
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings
|
||||
import org.jetbrains.plugins.gradle.startup.GradleProjectSettingsUpdater.Util
|
||||
import org.jetbrains.plugins.gradle.util.GradleBundle
|
||||
import org.jetbrains.plugins.gradle.util.GradleConstants
|
||||
import org.jetbrains.plugins.gradle.util.getGradleJvmLookupProvider
|
||||
@@ -116,47 +117,53 @@ internal class GradleProjectSettingsUpdater : ExternalSystemSettingsListenerEx {
|
||||
|
||||
if (manager !is GradleManager) return
|
||||
for (projectSettings in settings) {
|
||||
if (projectSettings !is GradleProjectSettings) continue
|
||||
if (GradleDaemonJvmHelper.isProjectUsingDaemonJvmCriteria(projectSettings)) continue
|
||||
val statusFuture = Util.updateGradleJvm(project, projectSettings)
|
||||
statusFuture.thenAccept {
|
||||
if (it.updated && it.sdkName != null) notifyGradleJvmChangeInfo(project, projectSettings, it.sdkName, it.sdk)
|
||||
if (projectSettings is GradleProjectSettings) {
|
||||
fixGradleJvm(project, projectSettings)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun notifyGradleJvmChangeInfo(
|
||||
project: Project,
|
||||
projectSettings: GradleProjectSettings,
|
||||
gradleJvm: String,
|
||||
sdk: Sdk?
|
||||
) {
|
||||
if (sdk == null) return
|
||||
val versionString = sdk.versionString ?: return
|
||||
val homePath = sdk.homePath ?: return
|
||||
val externalProjectPath = projectSettings.externalProjectPath ?: return
|
||||
|
||||
val presentablePath = SdkListPresenter.presentDetectedSdkPath(homePath)
|
||||
val notificationTitle = GradleBundle.message("gradle.notifications.java.home.change.title")
|
||||
val notificationContent = GradleBundle.message("gradle.notifications.java.home.change.content", gradleJvm, versionString,
|
||||
presentablePath)
|
||||
val notification = GradleNotification.gradleNotificationGroup.createNotification(notificationTitle, notificationContent, INFORMATION)
|
||||
notification.setDisplayId(GradleNotificationIdsHolder.jvmConfigured)
|
||||
notification.addAction(NotificationAction.createSimple(GradleBundle.message("gradle.open.gradle.settings")) {
|
||||
showGradleProjectSettings(project, externalProjectPath)
|
||||
})
|
||||
notification.notify(project)
|
||||
fun fixGradleJvm(project: Project, projectSettings: GradleProjectSettings) {
|
||||
if (GradleDaemonJvmHelper.isProjectUsingDaemonJvmCriteria(projectSettings)) return
|
||||
val statusFuture = Util.updateGradleJvm(project, projectSettings)
|
||||
statusFuture.thenAccept {
|
||||
if (it.updated && it.sdkName != null) notifyGradleJvmChangeInfo(project, projectSettings, it.sdkName, it.sdk)
|
||||
}
|
||||
}
|
||||
|
||||
private fun showGradleProjectSettings(project: Project, externalProjectPath: String) {
|
||||
val manager = ExternalSystemApiUtil.getManager(GradleConstants.SYSTEM_ID)
|
||||
val configurable = (manager as ExternalSystemConfigurableAware).getConfigurable(project)
|
||||
if (configurable is AbstractExternalSystemConfigurable<*, *, *>) {
|
||||
val settingsUtil = ShowSettingsUtil.getInstance()
|
||||
settingsUtil.editConfigurable(project, configurable) {
|
||||
configurable.selectProject(externalProjectPath)
|
||||
}
|
||||
private fun notifyGradleJvmChangeInfo(
|
||||
project: Project,
|
||||
projectSettings: GradleProjectSettings,
|
||||
gradleJvm: String,
|
||||
sdk: Sdk?
|
||||
) {
|
||||
if (sdk == null) return
|
||||
val versionString = sdk.versionString ?: return
|
||||
val homePath = sdk.homePath ?: return
|
||||
val externalProjectPath = projectSettings.externalProjectPath ?: return
|
||||
|
||||
val presentablePath = SdkListPresenter.presentDetectedSdkPath(homePath)
|
||||
val notificationTitle = GradleBundle.message("gradle.notifications.java.home.change.title")
|
||||
val notificationContent = GradleBundle.message("gradle.notifications.java.home.change.content", gradleJvm, versionString,
|
||||
presentablePath)
|
||||
val notification = GradleNotification.gradleNotificationGroup.createNotification(notificationTitle, notificationContent, INFORMATION)
|
||||
notification.setDisplayId(GradleNotificationIdsHolder.jvmConfigured)
|
||||
notification.addAction(NotificationAction.createSimple(GradleBundle.message("gradle.open.gradle.settings")) {
|
||||
showGradleProjectSettings(project, externalProjectPath)
|
||||
})
|
||||
notification.notify(project)
|
||||
}
|
||||
|
||||
private fun showGradleProjectSettings(project: Project, externalProjectPath: String) {
|
||||
val manager = ExternalSystemApiUtil.getManager(GradleConstants.SYSTEM_ID)
|
||||
val configurable = (manager as ExternalSystemConfigurableAware).getConfigurable(project)
|
||||
if (configurable is AbstractExternalSystemConfigurable<*, *, *>) {
|
||||
val settingsUtil = ShowSettingsUtil.getInstance()
|
||||
settingsUtil.editConfigurable(project, configurable) {
|
||||
configurable.selectProject(externalProjectPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user