How do I share (just) project code style settings with other IDEA users?

I'd like to share my project's code style settings with other IDEA users. Documentation says that Settings -> Code Style -> Export will create an XML file in the config\codeStyles folder, but it doesn't (at least not on a Mac). All I have is an empty config folder. I don't want to share the .ipr file because it contains lots of other stuff (e.g. dependencies) which shouldn't be shared this way (this is a Maven-based project). Any advice? I'm using IDEA 9.0 Ultimate.

8 comments
Comment actions Permalink

Which config directory are you checking? I've gotten thrown off before having multiple directories in home that all start with .IntelliJ or .Idea. For instance, right now I have both .IntelliJIdea90 and .IdeaIC90. It's easy for me to check the wrong one.

On our project we've never used the export functionality. Just creating a new code style (or saving the current one with a different name) causes a file to be created at config/codestyles. We check that file into source control and anyone who uses IDEA just grabs that file and drops it in the config/codestyle directory. Next time IDEA is run, it's selectable.

0
Comment actions Permalink

I've checked:
~/.IntelliJIdea90/
~/Library/Application Support/IntelliJIDEA90/
IntelliJ IDEA 9.0.app/

Only the first one contains a config directory, but it's empty.

I wish I could just export code style settings to a file (with the usual save dialog), check that in to source control, and then point IDEA to this file. IDEA would then periodically check the file for changes and reload settings if necessary. That's a simple and reliable mechanism to solve the distribution problem. Several Eclipse plugins do it this way (e.g. the CheckStyle plugin).

0
Comment actions Permalink

Global code styles are saved in ~/.IntelliJIdea90/config/codestyles/ (obviously change the 90 for other versions of Idea). If your config directory is empty as you said, open the file <idea-install-dir>/bin/idea.properties and look at the idea.config.path key to see where the files are getting placed. It should be ${user.home}/.IntelliJIdea90/config unless you (or someone else) has altered it.

If you use a project code style, and you are using the directory based project, it is saved in <project-root>/.idea/projectCodeStyle.xml. If you are using file based project structure (i.e. the .ipr file), they are saved in the project's .ipr file along with all the other project settings.

The easiest way (and the "appropriate" way) to do what you are trying to do is to:

1) Make your project use the directory based format if not already (File | Save as Directory-Based Format...) {The purpose of the directory based format is to allow for project settings to be committed to version control}

2) Set a project code style up - you can either use the "Copy to Project" button on the Project Settings | Code Style dialog window to copy a global code style to the project. Or simply select "Use per project settings" and make the desired settings

3) Check the .idea directory into version control. If you do not want to share other project or common settings, flag the other settings file to be ignored in the Changes tool Window. No matter what, you will want to ignore the workspace.xml file (it saves things like tool window positions, currently opened files, favorites, etc.) and the tasks.xml file.


Now if someone changes the style settings and commits them to version control, when you update the .idea directory, you will get the changes and they will be used.

0
Comment actions Permalink

thanks for the detailled process Mark.

But how would share a global Code Style for all projects within an
organisation?

Up to know I had to know that the global Code Style had change, and
copy it to the each project Code Style then commit, to be able to share
it for all projects.
Obviously, one person has to be responsible for this task otherwise it
never stays consistant accross projects. (And even with on person
responsible, this is hard to achieve)

Does the new way in Idea9 help in this respect?

rgds
nodje


On 2010-01-02 14:30:52 +0800, Mark Vedder <no_reply@jetbrains.com> said:

Global code styles are saved in ~/.IntelliJIdea90/config/codestyles/
(obviously change the 90 for other versions of Idea). If your config
directory is empty as you said, open the file
<idea-install-dir>/bin/idea.properties and look at the idea.config.path
key to see where the files are getting placed. It should be
${user.home}/.IntelliJIdea90/config unless you (or someone else) has
altered it.

If you use a project code style, and you are using the directory based
project, it is saved in <project-root>/.idea/projectCodeStyle.xml. If
you are using file based project structure (i.e. the .ipr file), they
are saved in the project's .ipr file along with all the other project
settings.

The easiest way (and the "appropriate" way) to do what you are trying
to do is to:

1) Make your project use the directory based format if not already
(File | Save as Directory-Based Format...) {The purpose of the
directory based format is to allow for project settings to be committed
to version control}

2) Set a project code style up - you can either use the "Copy to
Project" button on the Project Settings | Code Style dialog window to
copy a global code style to the project. Or simply select "Use per
project settings" and make the desired settings

3) Check the .idea directory into version control. If you do not want
to share other project or common settings, flag the other settings file
to be ignored in the Changes tool Window. No matter what, you will want
to ignore the workspace.xml file (it saves things like tool window
positions, currently opened files, favorites, etc.) and the tasks.xml
file.


Now if someone changes the style settings and commits them to version
control, when you update the .idea directory, you will get the changes
and they will be used.

---
Original message URL: http://www.jetbrains.net/devnet/message/5253535#5253535



0
Comment actions Permalink

In pretty much any situation, you will have to know the style settings have changed so that you can do a local update (i.e. get the latest from the version control). If you use a project based setting file, having to know this will be less of a challenge since if you do an update on the entire project, you'd get any changes to the settings.

I guess a question I would have is does your code style settings change all that often? Most shops establish one and that's that. The only changes would be to accommodate new languages, or if the IDE added some options. That's the likely reason IDEA does not have the feature you describe.

Off the top of my head, some "hacks" of how you could use a version controlled global settings file would  be to either put that file within your config directory under version control -- a risky and unusual thing to do IMHO. Or simply copy the new version into your config directory when ever it changes. With both these options, you would have to know about the change so you could either initiate a version control update, or copy the file over. Also, I do not know if IDEA would detect the change without a restart. Alternatively, you could place the file external to IDEA's config directory and then use a logical link to point to it. (You can use Link Shell Extension or a similar utility to create logical links in Windows.) Again, you would still need to initiate a version control update when the file changes.But you would do such in the external directory, not IDEA's config directory.

Probably the best recommendation would be to use project based style settings so that the updating is more automatic (when you update the entire project) and easier to spot as you work in the project. Then to keep all the project's in sync, have a script that distributes a new settings file to all the projects. So you update the settings file, run the script which checks it into version control for each project. Then as people work in the various projects and do updates, they get the new settings.

Good luck.

0
Comment actions Permalink

Hello Peter,

One way to do this more easily is to use directory-based project format and
share only the XML files containing the code style, keeping the rest of project
files local.

I'd like to share my project's code style settings with other IDEA
users. Documentation says that Settings -> Code Style -> Export will
create an XML file in the config\codeStyles folder, but it doesn't (at
least not on a Mac). All I have is an empty config folder. I don't
want to share the .ipr file because it contains lots of other stuff
(e.g. dependencies) which shouldn't be shared this way (this is a
Maven-based project). Any advice? I'm using IDEA 9.0 Ultimate.

---
Original message URL:
http://www.jetbrains.net/devnet/message/5253515#5253515

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

In the cold weather, the UGG boots are considered as the best shoes.More and more people like wearing the UGG boots such as the http://sell-ugg.com/UGG-Classic-Metallic-5812/c9/index.html.With its development ,the UGG boots have lauched different kinds of boots into the fashion market,including the http://uggboots-euro.com/UGG-Classic-Short-Boots/c3/index.html and the http://uggboots-euro.com/UGG-Women%27s-ighkoo/c23/index.html.However,in the fashion world,if you want to be more attractive and elegant,the beautiful shoes are not enough.You have to choose the best stylish handbag to match your shoes.Therefor,the designer replica handbags are very necessary.If you want to buy the best designer cheap handbags,i would like to introduce two famous brand handbags to you.I think there must be one handbag is your favorite.One is the famous brand http://www.famousbrandbag.com/Versace/c40/index.html,the other is the Ferragamo Handbags.Both of them are the famous brand in the world.Their quality are very good.

---
Original message URL: http://www.jetbrains.net/devnet/message/5254894#5254894

0
Comment actions Permalink

Hello,

For any other mac users reading this,  I wanted to confirm that this is a bug on mac version of 93.13. The codestyles are not exported to or loaded from the appropriate code styles folder. Works fine on ubuntu and windows.

Ed

0

Please sign in to leave a comment.