Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0


The implementation of PersistentStateComponent works by serializing public fields, annotated private fields and bean properties into an XML format. The following types of values can be persisted:

  • numbers (both primitive types, such as int, and boxed types, such as Integer);
  • booleans;
  • strings;
  • collections;
  • maps;
  • enums.

In order to exclude a public field or bean property from serialization, you can annotate the field or getter with the @com.intellij.util.xmlb.annotations.Transient annotation.


In order to specify where exactly the persisted values wiil be stored, you need to add a @State annotation to the PersistentStateComponent class. It has the following fields:

  • name (required) - specifies the name of the state (name of the root tag in XML)
  • One or more of @com.intellij.openapi.components.Storage annotations (required) - specify the storage locations for .ipr and directory-based projects
  • reloadable (optional) - if set to false, complete project reload is required when the XML file is changed externally and the state has changed.

The simplest ways of specifying the @Storage annotation are as follows:

  • @Storage(id="other", file = StoragePathMacros.APP_CONFIG + "/other.xml") for application-level values
  • @Storage(id="other", file = StoragePathMacros.PROJECT_FILE) for values stored in the project file (for .ipr based projects)
  • @Storage(id = "dir", file = StoragePathMacros.PROJECT_CONFIG_DIR + "/other.xml", scheme = StorageScheme.DIRECTORY_BASED)}) for values stored in the project directory (for directory-based projects)
  • @Storage(id="other", file = StoragePathMacros.WORKSPACE_FILE) for values stored in the workspace file

The roamingType parameter of the @Storage annotation specifies the roaming type when the Settings Repository plugin is used.