mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fix user's project name discarded by external system
This commit is contained in:
committed by
Nikita Iarychenko
parent
53df6a9c15
commit
cf89e00ac1
Generated
+1
-4
@@ -433,7 +433,6 @@
|
||||
<module name="lib.ch_qos_logback-logback-classic-1_3_14_http_import" options="-proc:none -XepDisableAllChecks" />
|
||||
<module name="lib.ch_qos_logback-logback-core-1_3_14_http_import" options="-proc:none -XepDisableAllChecks" />
|
||||
<module name="lib.clikt" options="-proc:none -XepDisableAllChecks" />
|
||||
<module name="lib.cloud-config-client" options="-proc:none -XepDisableAllChecks" />
|
||||
<module name="lib.codeowners-jetbrains-patronus-codeowners-lib-ownership" options="-Xlint:-options -source 25 -target 25 -XDskipDuplicateBridges=true -XDcompilePolicy=simple --should-stop=ifError=FLOW -g -parameters -Xep:IgnoredPureGetter:OFF -Xep:EmptyTopLevelDeclaration:OFF -Xep:LenientFormatStringValidation:OFF -Xep:ReturnMissingNullable:OFF -Xep:UseCorrectAssertInTests:OFF -Xmaxwarns -1" />
|
||||
<module name="lib.com-jetbrains-fus-reporting-ap-validation-all" options="-proc:none -XepDisableAllChecks" />
|
||||
<module name="lib.com-jetbrains-fus-reporting-fus-api" options="-proc:none -XepDisableAllChecks" />
|
||||
@@ -683,7 +682,6 @@
|
||||
<module name="lib.grpc-stub" options="-proc:none -XepDisableAllChecks" />
|
||||
<module name="lib.guava-testlib" options="-proc:none -XepDisableAllChecks" />
|
||||
<module name="lib.http-client" options="-Xlint:-options -source 25 -target 25 -XDskipDuplicateBridges=true -XDcompilePolicy=simple --should-stop=ifError=FLOW -g -parameters -Xep:IgnoredPureGetter:OFF -Xep:EmptyTopLevelDeclaration:OFF -Xep:LenientFormatStringValidation:OFF -Xep:ReturnMissingNullable:OFF -Xep:UseCorrectAssertInTests:OFF -Xmaxwarns -1" />
|
||||
<module name="lib.idea-community-customization-tips-idea-ce" options="-proc:none -XepDisableAllChecks" />
|
||||
<module name="lib.info_cukes-cucumber-html-0_2_6_http_import" options="-proc:none -XepDisableAllChecks" />
|
||||
<module name="lib.info_cukes-gherkin-2_12_2_http_import" options="-proc:none -XepDisableAllChecks" />
|
||||
<module name="lib.intellij-plugin-structure" options="-Xlint:-options -source 25 -target 25 -XDskipDuplicateBridges=true -XDcompilePolicy=simple --should-stop=ifError=FLOW -g -parameters -Xep:IgnoredPureGetter:OFF -Xep:EmptyTopLevelDeclaration:OFF -Xep:LenientFormatStringValidation:OFF -Xep:ReturnMissingNullable:OFF -Xep:UseCorrectAssertInTests:OFF -Xmaxwarns -1" />
|
||||
@@ -693,6 +691,7 @@
|
||||
<module name="lib.io-github-smiley4-schema-kenerator-serialization" options="-proc:none -XepDisableAllChecks" />
|
||||
<module name="lib.io-modelcontextprotocol-kotlin-sdk" options="-Xlint:-options -source 25 -target 25 -XDskipDuplicateBridges=true -XDcompilePolicy=simple --should-stop=ifError=FLOW -g -parameters -Xep:IgnoredPureGetter:OFF -Xep:EmptyTopLevelDeclaration:OFF -Xep:LenientFormatStringValidation:OFF -Xep:ReturnMissingNullable:OFF -Xep:UseCorrectAssertInTests:OFF -Xmaxwarns -1" />
|
||||
<module name="lib.io-qameta-allure-java-commons" options="-Xlint:-options -source 25 -target 25 -XDskipDuplicateBridges=true -XDcompilePolicy=simple --should-stop=ifError=FLOW -g -parameters -Xep:IgnoredPureGetter:OFF -Xep:EmptyTopLevelDeclaration:OFF -Xep:LenientFormatStringValidation:OFF -Xep:ReturnMissingNullable:OFF -Xep:UseCorrectAssertInTests:OFF -Xmaxwarns -1" />
|
||||
<module name="lib.io-sentry" options="-proc:none -XepDisableAllChecks" />
|
||||
<module name="lib.io_coil-kt_coil3-coil-compose-core-jvm-3_2_0_http_import" options="-proc:none -XepDisableAllChecks" />
|
||||
<module name="lib.io_coil-kt_coil3-coil-compose-jvm-3_2_0_http_import" options="-proc:none -XepDisableAllChecks" />
|
||||
<module name="lib.io_coil-kt_coil3-coil-core-jvm-3_2_0_http_import" options="-proc:none -XepDisableAllChecks" />
|
||||
@@ -1912,7 +1911,6 @@
|
||||
<module name="platform.platform-impl.ide-impl_test_lib" options="--add-exports=java.desktop/sun.awt=ALL-UNNAMED --add-exports=java.desktop/sun.font=ALL-UNNAMED --add-exports=java.desktop/java.awt.peer=ALL-UNNAMED --add-exports=jdk.attach/sun.tools.attach=ALL-UNNAMED --add-exports=java.desktop/sun.awt.image=ALL-UNNAMED --add-exports=java.desktop/sun.awt.datatransfer=ALL-UNNAMED --add-exports=java.desktop/sun.swing=ALL-UNNAMED --add-exports=java.base/sun.nio.fs=ALL-UNNAMED -proc:none -nowarn -XepDisableAllChecks" />
|
||||
<module name="platform.platform-resources.resources_resources" options="-Xlint:-options -source 25 -target 25 -XDskipDuplicateBridges=true -XDcompilePolicy=simple --should-stop=ifError=FLOW -g -parameters -Xep:IgnoredPureGetter:OFF -Xep:EmptyTopLevelDeclaration:OFF -Xep:LenientFormatStringValidation:OFF -Xep:ReturnMissingNullable:OFF -Xep:UseCorrectAssertInTests:OFF -Xmaxwarns -1" />
|
||||
<module name="platform.platform-tests.benchmarks.benchmarks_test" options="-Xlint:-options -source 25 -target 25 -XDskipDuplicateBridges=true -XDcompilePolicy=simple --should-stop=ifError=FLOW -g -parameters -Xep:IgnoredPureGetter:OFF -Xep:EmptyTopLevelDeclaration:OFF -Xep:LenientFormatStringValidation:OFF -Xep:ReturnMissingNullable:OFF -Xep:UseCorrectAssertInTests:OFF -Xmaxwarns -1" />
|
||||
<module name="platform.platform-tests.benchmarks.benchmarks_test_lib" options="-nowarn -XepDisableAllChecks" />
|
||||
<module name="platform.platform-tests.durability.durability_test" options="-Xlint:-options -source 25 -target 25 -XDskipDuplicateBridges=true -XDcompilePolicy=simple --should-stop=ifError=FLOW -g -parameters -Xep:IgnoredPureGetter:OFF -Xep:EmptyTopLevelDeclaration:OFF -Xep:LenientFormatStringValidation:OFF -Xep:ReturnMissingNullable:OFF -Xep:UseCorrectAssertInTests:OFF -Xmaxwarns -1" />
|
||||
<module name="platform.platform-tests.tests_test" options="-Xlint:-options -source 25 -target 25 -XDskipDuplicateBridges=true -XDcompilePolicy=simple --should-stop=ifError=FLOW -g -parameters -Xep:IgnoredPureGetter:OFF -Xep:EmptyTopLevelDeclaration:OFF -Xep:LenientFormatStringValidation:OFF -Xep:ReturnMissingNullable:OFF -Xep:UseCorrectAssertInTests:OFF -Xmaxwarns -1" />
|
||||
<module name="platform.pluginSystem.parser.impl.pluginSystem-parser-impl-tests_test" options="-Xlint:-options -source 25 -target 25 -XDskipDuplicateBridges=true -XDcompilePolicy=simple --should-stop=ifError=FLOW -g -parameters -Xep:IgnoredPureGetter:OFF -Xep:EmptyTopLevelDeclaration:OFF -Xep:LenientFormatStringValidation:OFF -Xep:ReturnMissingNullable:OFF -Xep:UseCorrectAssertInTests:OFF -Xmaxwarns -1" />
|
||||
@@ -2247,7 +2245,6 @@
|
||||
<module name="plugins.search-everywhere-ml.searchEverywhereMl-tests_test" options="-Xlint:-options -source 25 -target 25 -XDskipDuplicateBridges=true -XDcompilePolicy=simple --should-stop=ifError=FLOW -g -parameters -Xep:IgnoredPureGetter:OFF -Xep:EmptyTopLevelDeclaration:OFF -Xep:LenientFormatStringValidation:OFF -Xep:ReturnMissingNullable:OFF -Xep:UseCorrectAssertInTests:OFF -Xmaxwarns -1" />
|
||||
<module name="plugins.search-everywhere-ml.typos.searchEverywhereMl-typos-tests_test" options="-Xlint:-options -source 25 -target 25 -XDskipDuplicateBridges=true -XDcompilePolicy=simple --should-stop=ifError=FLOW -g -parameters -Xep:IgnoredPureGetter:OFF -Xep:EmptyTopLevelDeclaration:OFF -Xep:LenientFormatStringValidation:OFF -Xep:ReturnMissingNullable:OFF -Xep:UseCorrectAssertInTests:OFF -Xmaxwarns -1" />
|
||||
<module name="plugins.settings-repository.settingsRepository-tests_test" options="-Xlint:-options -source 25 -target 25 -XDskipDuplicateBridges=true -XDcompilePolicy=simple --should-stop=ifError=FLOW -g -parameters -Xep:IgnoredPureGetter:OFF -Xep:EmptyTopLevelDeclaration:OFF -Xep:LenientFormatStringValidation:OFF -Xep:ReturnMissingNullable:OFF -Xep:UseCorrectAssertInTests:OFF -Xmaxwarns -1" />
|
||||
<module name="plugins.settings-sync.jba.settingsSync-tests_test" options="-Xlint:-options -source 25 -target 25 -XDskipDuplicateBridges=true -XDcompilePolicy=simple --should-stop=ifError=FLOW -g -parameters -Xep:IgnoredPureGetter:OFF -Xep:EmptyTopLevelDeclaration:OFF -Xep:LenientFormatStringValidation:OFF -Xep:ReturnMissingNullable:OFF -Xep:UseCorrectAssertInTests:OFF -Xmaxwarns -1" />
|
||||
<module name="plugins.sh.copyright.copyright-tests_test" options="-Xlint:-options -source 25 -target 25 -XDskipDuplicateBridges=true -XDcompilePolicy=simple --should-stop=ifError=FLOW -g -parameters -Xep:IgnoredPureGetter:OFF -Xep:EmptyTopLevelDeclaration:OFF -Xep:LenientFormatStringValidation:OFF -Xep:ReturnMissingNullable:OFF -Xep:UseCorrectAssertInTests:OFF -Xmaxwarns -1" />
|
||||
<module name="plugins.sh.core.tests_test" options="-Xlint:-options -source 25 -target 25 -XDskipDuplicateBridges=true -XDcompilePolicy=simple --should-stop=ifError=FLOW -g -parameters -Xep:IgnoredPureGetter:OFF -Xep:EmptyTopLevelDeclaration:OFF -Xep:LenientFormatStringValidation:OFF -Xep:ReturnMissingNullable:OFF -Xep:UseCorrectAssertInTests:OFF -Xmaxwarns -1" />
|
||||
<module name="plugins.stats-collector.statsCollector-tests_test" options="-Xlint:-options -source 25 -target 25 -XDskipDuplicateBridges=true -XDcompilePolicy=simple --should-stop=ifError=FLOW -g -parameters -Xep:IgnoredPureGetter:OFF -Xep:EmptyTopLevelDeclaration:OFF -Xep:LenientFormatStringValidation:OFF -Xep:ReturnMissingNullable:OFF -Xep:UseCorrectAssertInTests:OFF -Xmaxwarns -1" />
|
||||
|
||||
+26
-3
@@ -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 Aleksandr Eliseev 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 com.intellij.openapi.roots.ui.configuration;
|
||||
|
||||
@@ -28,9 +31,10 @@ import com.intellij.project.ProjectKt;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.openide.project.ProjectNameCustomizationState;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
@@ -150,7 +154,15 @@ public class ProjectConfigurable extends ProjectStructureElementConfigurable<Pro
|
||||
myUi.applyProjectJdkConfigurable();
|
||||
|
||||
if (myProject instanceof ProjectEx) {
|
||||
((ProjectEx)myProject).setProjectName(getProjectName());
|
||||
ProjectEx projectEx = (ProjectEx)myProject;
|
||||
String newName = getProjectName();
|
||||
projectEx.setProjectName(newName);
|
||||
// Record whether the user explicitly customized the name.
|
||||
// An external system (e.g. Gradle) sync must not overwrite a customized name;
|
||||
// resetting it to the directory name clears the flag so the sync can drive it again.
|
||||
ProjectNameCustomizationState.Companion.getInstance(myProject).setUserCustomizedName(
|
||||
isCustomProjectName(myProject, newName)
|
||||
);
|
||||
if (myDetailsComponent != null) myDetailsComponent.setText(getBannerSlogan());
|
||||
}
|
||||
});
|
||||
@@ -212,6 +224,17 @@ public class ProjectConfigurable extends ProjectStructureElementConfigurable<Pro
|
||||
return myProject.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given name is a user customization, i.e. it differs from the project's
|
||||
* directory name (the default project name). Used to decide whether an external system sync may
|
||||
* override the project name.
|
||||
*/
|
||||
private static boolean isCustomProjectName(@NotNull Project project, @NotNull String name) {
|
||||
String basePath = project.getBasePath();
|
||||
if (basePath == null) return true;
|
||||
return !name.equals(new File(basePath).getName());
|
||||
}
|
||||
|
||||
private @Nullable String getOriginalCompilerOutputUrl() {
|
||||
final CompilerProjectExtension extension = CompilerProjectExtension.getInstance(myProject);
|
||||
return extension != null ? extension.getCompilerOutputUrl() : null;
|
||||
|
||||
+11
-2
@@ -1,4 +1,7 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
//
|
||||
// Modified by Aleksandr Eliseev 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 com.intellij.openapi.externalSystem.service.project.manage;
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
@@ -10,6 +13,7 @@ import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsPr
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
|
||||
import com.intellij.openapi.externalSystem.util.Order;
|
||||
import ru.openide.project.ProjectNameCustomizationState;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ex.ProjectEx;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -45,9 +49,14 @@ public final class ProjectDataServiceImpl extends AbstractProjectDataService<Pro
|
||||
if (!ExternalSystemApiUtil.isOneToOneMapping(project, node.getData(), modelsProvider.getModules())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!project.getName().equals(projectData.getInternalName())) {
|
||||
renameProject(projectData.getInternalName(), projectData.getOwner(), project);
|
||||
// Don't overwrite a project name the user has explicitly customized (via File | Project
|
||||
// Structure or Refactor | Rename) when the external (e.g. Gradle) root project name differs.
|
||||
// A Gradle-driven rename (no user customization) still propagates, including across multiple syncs.
|
||||
if (!ProjectNameCustomizationState.Companion.getInstance(project).getUserCustomizedName()) {
|
||||
renameProject(projectData.getInternalName(), projectData.getOwner(), project);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
-1
@@ -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 Aleksandr Eliseev 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 com.intellij.platform.renameProject;
|
||||
|
||||
import com.intellij.ide.IdeBundle;
|
||||
@@ -28,6 +31,9 @@ import com.intellij.refactoring.rename.RenameHandler;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.openide.project.ProjectNameCustomizationState;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public final class RenameProjectHandler implements RenameHandler, TitledHandler {
|
||||
@@ -89,6 +95,13 @@ public final class RenameProjectHandler implements RenameHandler, TitledHandler
|
||||
public static boolean renameProject(@NotNull ProjectEx project, @Nullable Module module, String newName){
|
||||
if (shouldRenameProject(project, module, newName)) {
|
||||
project.setProjectName(newName);
|
||||
// The user explicitly renamed the project from Refactor | Rename. Record it as a
|
||||
// customization so an external system (e.g. Gradle) sync doesn't overwrite it; resetting the
|
||||
// name to the directory name clears it and lets the sync drive the name again.
|
||||
String basePath = project.getBasePath();
|
||||
ProjectNameCustomizationState.Companion.getInstance(project).setUserCustomizedName(
|
||||
basePath == null || !newName.equals(new File(basePath).getName())
|
||||
);
|
||||
project.save();
|
||||
}
|
||||
|
||||
@@ -126,4 +139,4 @@ public final class RenameProjectHandler implements RenameHandler, TitledHandler
|
||||
|
||||
return module == PrimaryModuleManager.findPrimaryModule(project);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
// OpenIDE Project
|
||||
// Copyright (C) 2026 “Open Development Platform” Ltd. (https://openide.ru)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License version 3 or later as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
package ru.openide.project
|
||||
|
||||
import com.intellij.openapi.components.PersistentStateComponent
|
||||
import com.intellij.openapi.components.Service
|
||||
import com.intellij.openapi.components.State
|
||||
import com.intellij.openapi.components.Storage
|
||||
import com.intellij.openapi.components.StoragePathMacros
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.util.xmlb.XmlSerializerUtil
|
||||
|
||||
/**
|
||||
* Tracks whether the user has explicitly customized the IDE project name (via File | Project
|
||||
* Structure or Refactor | Rename on the project), as opposed to the name being derived from the
|
||||
* project directory or set by an external system (e.g. Gradle) sync.
|
||||
*
|
||||
* An external system sync that wants to rename the project to match the build model must respect
|
||||
* this flag: once the user has chosen a custom name, the sync must not overwrite it. The flag is
|
||||
* cleared again when the user resets the name to the project directory name, so an external system
|
||||
* can resume driving the name.
|
||||
*/
|
||||
@Service(Service.Level.PROJECT)
|
||||
@State(name = "ProjectNameCustomizationState", storages = [Storage(StoragePathMacros.WORKSPACE_FILE)])
|
||||
class ProjectNameCustomizationState : PersistentStateComponent<ProjectNameCustomizationState> {
|
||||
|
||||
companion object {
|
||||
fun getInstance(project: Project): ProjectNameCustomizationState =
|
||||
project.getService(ProjectNameCustomizationState::class.java)
|
||||
}
|
||||
|
||||
var userCustomizedName: Boolean = false
|
||||
|
||||
override fun getState(): ProjectNameCustomizationState = this
|
||||
|
||||
override fun loadState(state: ProjectNameCustomizationState) {
|
||||
XmlSerializerUtil.copyBean(state, this)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user