简体   繁体   English

如何在用户之间共享Eclipse项目首选项?

[英]How to share Eclipse project preferences between users?

We have several devs in the team, the source code is managed using the Mercurial DVCS. 我们团队中有几个开发人员,源代码使用Mercurial DVCS进行管理。

The .metadata folder is not under the source control. .metadata文件夹不在源代码管理下。

The problem, is that when I configure project dependencies (jars, user libraries, source code paths, etc ...) they are stored inside the .metadata folder, namely in .metadata\\.plugins\\org.eclipse.core.runtime\\.settings\\org.eclipse.jdt.core.prefs 问题是,当我配置项目依赖项(jar,用户库,源代码路径等等)时,它们存储在.metadata文件夹中,即.metadata\\.plugins\\org.eclipse.core.runtime\\.settings\\org.eclipse.jdt.core.prefs

Since this file is not managed by DVCS, all the devs need to repeat the project configuration process all over again. 由于此文件不是由DVCS管理的,因此所有开发人员都需要重新重复项目配置过程。 For a new dev in the team this is a major head ache. 对于团队中的新开发者而言,这是一个主要的头痛。

My question is there a sane procedure to share this kind of configuration data? 我的问题是有一个合理的程序来共享这种配置数据? I am new to the world of Java and Eclipse, so maybe I am missing something really basic here. 我是Java和Eclipse世界的新手,所以也许我错过了一些非常基本的东西。

EDIT 编辑

The problem is that I have been using User Libraries , which are defined globally and thus are not shared. 问题是我一直在使用User Libraries ,这些User Libraries是全局定义的,因此不会共享。 Using External Jars solves the problem, because these are recorded in the .classpath file inside the project directory. 使用External Jars解决了这个问题,因为它们记录在项目目录中的.classpath文件中。

You can prepare a preferences file ( .epf ) and store it in source control. 您可以准备首选项文件( .epf )并将其存储在源代码管理中。 Each developer will have to import this file once in each workspace they're using. 每个开发人员都必须在他们使用的每个工作区中导入一次该文件。

To create a preference file, go to File → Export... → General → Preferences. 要创建首选项文件,请转到文件→导出...→常规→首选项。 You can then edit the .epf file, so that it only contains the preferences you want to share with everyone. 然后,您可以编辑.epf文件,以便它只包含您要与所有人共享的首选项。 This way you can share code style preferences, formatting options, compiler warnings, JRE settings, UI tweaks, and many more types of Eclipse preferences. 这样,您可以共享代码样式首选项,格式选项,编译器警告,JRE设置,UI调整以及更多类型的Eclipse首选项。

A short answer would be - use an IDE-independent project configuration tool like Maven . 简短的回答是 - 使用像Maven这样的独立于IDE的项目配置工具。

Another possibility is ant - a very powerful build tool. 另一种可能性是ant - 一种非常强大的构建工具。 Slightly out-of-vogue lately. 最近稍微不流行了。

Sharing the buidfiles used by such a tool is a very common option for making your project settings and dependencies managable and easily portable. 共享此类工具使用的buidfiles是一个非常常见的选项,可以使您的项目设置和依赖项可管理且易于移植。

Sharing the eclipse-generated metadata is on the other hand discouraged as eclipse stores dependencies with their absolute pathes (not sure if this is always the case, but definitely sometimes), and those pathes can cause a set of issues (experienced first-hand). 另一方面,共享eclipse生成的元数据是不鼓励的,因为eclipse使用它们的绝对路径存储依赖项(不确定是否总是如此,但有时肯定),这些路径可能会导致一系列问题(亲身体验) 。 Especially if shared between OS borders (win-linux) 特别是如果在OS边界之间共享(win-linux)

You can specify a lot of properties in the project configuration instead of in the global configuration. 您可以在项目配置中指定许多属性,而不是在全局配置中指定。 Just right-click on the project and select "Properties" there. 只需右键单击该项目,然后选择“属性”。

Eclipse then saves the preferences in the project directory instead of in the workspace configuration directory. 然后,Eclipse将首选项保存在项目目录中,而不是保存在工作空间配置目录中。 That way you can check-in the project specific configuration into your SCM and share it with other project members. 这样,您可以将项目特定配置签入SCM并与其他项目成员共享。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM