mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-13 15:52:01 +07:00
[maven] [IDEA-362005] persist enabled profiles as a string
(cherry picked from commit ee26d496b43c7dcb8d569780d256394f2b0463fd) IJ-CR-148925 GitOrigin-RevId: 9cacde8d170cf81bc4236ebb00f957b10900a956
This commit is contained in:
committed by
intellij-monorepo-bot
parent
143de32be1
commit
670145195c
@@ -3,24 +3,17 @@ package org.jetbrains.idea.maven.project;
|
||||
|
||||
import com.intellij.util.xmlb.annotations.Transient;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public final class MavenWorkspacePersistedSettings {
|
||||
|
||||
private final MavenWorkspaceSettings wrappee;
|
||||
|
||||
public String explicitlyEnabledProfiles;
|
||||
public String explicitlyDisabledProfiles;
|
||||
|
||||
public MavenWorkspacePersistedSettings(MavenWorkspaceSettings wrappee) { this.wrappee = wrappee; }
|
||||
|
||||
public MavenWorkspacePersistedSettings() { this.wrappee = new MavenWorkspaceSettings(); }
|
||||
|
||||
public void setEnabledProfiles(Collection<String> profiles) {
|
||||
wrappee.setEnabledProfiles(profiles);
|
||||
}
|
||||
|
||||
public void setDisabledProfiles(Collection<String> profiles) {
|
||||
wrappee.setDisabledProfiles(profiles);
|
||||
}
|
||||
|
||||
public MavenGeneralSettings getGeneralSettings() {
|
||||
return wrappee.getGeneralSettings().cloneForPersistence();
|
||||
}
|
||||
|
||||
@@ -7,9 +7,12 @@ import com.intellij.openapi.components.Storage;
|
||||
import com.intellij.openapi.components.StoragePathMacros;
|
||||
import com.intellij.openapi.externalSystem.autoimport.ExternalSystemProjectTrackerSettings;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.idea.maven.model.MavenExplicitProfiles;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
@State(name = "MavenImportPreferences", storages = @Storage(StoragePathMacros.WORKSPACE_FILE))
|
||||
@SuppressWarnings("LightServiceMigrationCode")
|
||||
@@ -35,18 +38,32 @@ public final class MavenWorkspaceSettingsComponent implements PersistentStateCom
|
||||
@NotNull
|
||||
public MavenWorkspacePersistedSettings getState() {
|
||||
MavenExplicitProfiles profiles = MavenProjectsManager.getInstance(myProject).getExplicitProfiles();
|
||||
mySettings.setEnabledProfiles(profiles.getEnabledProfiles());
|
||||
mySettings.setDisabledProfiles(profiles.getDisabledProfiles());
|
||||
mySettings.explicitlyEnabledProfiles = StringUtil.nullize(StringUtil.join(profiles.getEnabledProfiles(), ","));
|
||||
mySettings.explicitlyDisabledProfiles = StringUtil.nullize(StringUtil.join(profiles.getDisabledProfiles(), ","));
|
||||
mySettings.getRealSettings().enabledProfiles = new ArrayList<>(profiles.getEnabledProfiles());
|
||||
mySettings.getRealSettings().disabledProfiles = new ArrayList<>(profiles.getDisabledProfiles());
|
||||
return mySettings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(@NotNull MavenWorkspacePersistedSettings state) {
|
||||
mySettings = state;
|
||||
applyProfiles(mySettings);
|
||||
applyDefaults(mySettings.getRealSettings());
|
||||
migrateSettings(mySettings.getRealSettings());
|
||||
}
|
||||
|
||||
private static void applyProfiles(MavenWorkspacePersistedSettings settings) {
|
||||
var wrappee = settings.getRealSettings();
|
||||
if (settings.explicitlyEnabledProfiles != null) {
|
||||
settings.getRealSettings().setEnabledProfiles(StringUtil.split(settings.explicitlyEnabledProfiles, ","));
|
||||
}
|
||||
|
||||
if (settings.explicitlyDisabledProfiles != null) {
|
||||
settings.getRealSettings().setDisabledProfiles(StringUtil.split(settings.explicitlyDisabledProfiles, ","));
|
||||
}
|
||||
}
|
||||
|
||||
public MavenWorkspaceSettings getSettings() {
|
||||
return mySettings.getRealSettings();
|
||||
}
|
||||
|
||||
@@ -39,7 +39,11 @@ public class MavenSettingsTest extends MavenTestCase {
|
||||
}
|
||||
|
||||
public void testImportingSettings() {
|
||||
allowAccessToDirsIfExists(System.getenv("JAVA_HOME"));
|
||||
var javaHome = System.getenv("JAVA_HOME");
|
||||
if (javaHome != null) {
|
||||
allowAccessToDirsIfExists(System.getenv("JAVA_HOME"));
|
||||
}
|
||||
|
||||
assertEquals(new MavenImportingSettings(), new MavenImportingSettings());
|
||||
MavenImportingConfigurable importingConfigurable = new MavenImportingConfigurable(getProject());
|
||||
importingConfigurable.reset();
|
||||
|
||||
Reference in New Issue
Block a user