将 Eclipse 项目签入 SVN
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3518841/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Checking in an Eclipse project into SVN
提问by user220201
I want to checkin a Dynamic Web Project I created in eclipse into svn. Can someone tell me which files I have to check in and which one I should not? The idea is to be able to check out the project using the New Project Wizard so that I can create the Dynamic Web Project again. More specifically here are the files/directories I have in the project --
我想将我在 eclipse 中创建的动态 Web 项目检入 svn。有人可以告诉我哪些文件必须签入,哪些不应该签入?这个想法是能够使用新建项目向导签出项目,以便我可以再次创建动态 Web 项目。更具体地说,这里是我在项目中的文件/目录——
- src
- WebContent
- build
- dist
- build.xml
- .project
- .classpath
- .settings/
- 源文件
- 网页内容
- 建造
- 区
- 构建文件
- 。项目
- .classpath
- .设置/
The build directory is not supposed to checked in obviously. What about the other ones? I am guessing all the . files should not be checked in either. Can some one verify this? What is this dist directory and the .settings directory?
构建目录显然不应该签入。其他的呢?我猜所有的。文件也不应该被检入。有人可以验证这一点吗?这个 dist 目录和 .settings 目录是什么?
Also where does eclipse store the Server information (tomcat)? I don't want to check it in either.
另外eclipse在哪里存储服务器信息(tomcat)?我也不想检查。
EDIT:
编辑:
I initially checked in all of the above except the build directory of course. When I checked out the project from inside Eclipse it did not prompt me to create a new project since the .project is there but Eclipse was creating a JavaEE project or something instead of the Dynamic Web Project. Did anyone else run into this behavior?
我最初检查了上述所有内容,当然除了构建目录。当我从 Eclipse 内部检出该项目时,它没有提示我创建一个新项目,因为 .project 在那里,但 Eclipse 正在创建一个 JavaEE 项目或其他东西而不是动态 Web 项目。有没有其他人遇到过这种行为?
** EDIT 2 **
** 编辑 2 **
Found it! Turns out I should not check in the following --
找到了!原来我不应该检查以下内容——
- .project
- .settings/
- .classpath
- 。项目
- .设置/
- .classpath
Once these 3 are removed the New project Wizard works as expected and everything is fine.
删除这 3 个后,新项目向导会按预期工作,一切正常。
采纳答案by Adriaan Koster
If you check in .classpath/.project/.settings
you make your project Eclipse-specific. What about developers who work with Netbeans
or IntelliJ
? IMO it is cleaner to keep your project IDE-independent and easy to set up.
如果您签入,.classpath/.project/.settings
您将使您的项目特定于Eclipse。与Netbeans
或 合作的开发人员IntelliJ
呢?IMO 使您的项目独立于 IDE 并且易于设置更简洁。
I usually go for a Maven build. The pom.xml
specifies all the required dependencies and mvn eclipse:eclipse
generates the .classpath/.project
files for you.
我通常会选择 Maven 构建。在pom.xml
指定所有所需的依赖,并mvn eclipse:eclipse
生成.classpath/.project
文件为您服务。
The .settings
directory contains local settings (like which Java version you want to use). IMO it is not useful to check this in. You can enforce Java version compliance via the Maven2 pom.
该.settings
目录包含本地设置(例如您要使用的 Java 版本)。IMO 将其签入是没有用的。您可以通过 Maven2 pom 强制执行 Java 版本合规性。
Finally, for your next project, my protip is to svn-ignore
the files or directories you don't want in SVN beforeyour first commit. In a Maven2 setup that would be .settings
.classpath
.project
target
(the default output directory of Maven2) and any other generated stuff (log files, gfembed directories, etc). In your case you would ignore build
and dist
instead of target
.
最后,对于您的下一个项目,我的建议是在您第一次提交之前svn-ignore
在 SVN 中不需要的文件或目录 。在 Maven2 设置中(Maven2的默认输出目录)和任何其他生成的东西(日志文件、gfembed 目录等)。在您的情况下,您将忽略and而不是..settings
.classpath
.project
target
build
dist
target
You can svn-ignore
files or directories with RIGHT_MOUSE->Team->'Add to svn:ignore'
(I use the Subclipse plugin). Ignore instructions are stored as svn-properties
on the parent directory. The properties on a directory can be viewed by RIGHT_MOUSE->Team->Show properties
. You can also edit the properties directly there by clicking on the value field. Make sure there is an end of line after each property.
您可以使用svn-ignore
文件或目录RIGHT_MOUSE->Team->'Add to svn:ignore'
(我使用 Subclipse 插件)。忽略指令存储svn-properties
在父目录中。可以通过 来查看目录上的属性RIGHT_MOUSE->Team->Show properties
。您还可以通过单击值字段直接在那里编辑属性。确保每个属性后面都有行尾。
Now that you have already committed and then removed these files, ignoring is not going to work anymore in my experience. Somehow I have never managed to successfully ignore generated files which have ever been checked into the SVN repository; they are like zombies, always coming back from the dead. Maybe by deleting their entries physically in the SVN repo this can be achieved, but I've never done it.
既然您已经提交并删除了这些文件,根据我的经验,忽略将不再起作用。不知何故,我从未设法成功忽略曾经被签入 SVN 存储库的生成文件;他们就像僵尸,总是死而复生。也许通过在 SVN 存储库中物理删除他们的条目可以实现这一点,但我从未这样做过。
回答by pavanlimo
In our case, we have checked in all you mentioned in the list except, .settings/.
在我们的例子中,我们已经检查了您在列表中提到的所有内容,除了 .settings/。
With .classpath
and .project
checked in, users can quickly check out the project and fire up Eclipse on a new computer and just start working on it; the alternative being to configure the project manually and adding in all the jar dependencies painstakingly (if you use ant). Many open source projects do this.
使用.classpath
并.project
签入,用户可以快速签出项目并在新计算机上启动 Eclipse 并开始处理它;另一种方法是手动配置项目并煞费苦心地添加所有 jar 依赖项(如果您使用 ant)。许多开源项目都是这样做的。
Read this, there are some really good points to ponder about.
阅读本文,有一些非常好的要点值得思考。
回答by Ankit Bansal
Good Question... Many of us are in a dilemma on whether we want to check in IDE related files or not. I normally go for checking in .classpath for eclipse and I use eclipse variables to make sure that team needs to just change the variable value and it works. We also check in .project so that team need not to create new project in their workspace.
好问题... 我们中的许多人在是否要签入与 IDE 相关的文件方面处于两难境地。我通常会检查 .classpath 以进行 eclipse 并使用 eclipse 变量来确保团队只需要更改变量值并且它可以工作。我们还签入 .project 以便团队无需在他们的工作区中创建新项目。
回答by Javid Jamae
I would omit the .project, .settings/, dist, and build.
我会省略 .project、.settings/、dist 和 build。
The .classpath can be left in if you use variables instead of hardcoded paths. This is useful so you don't have to rebuild your classpath every time you check out the project.
如果您使用变量而不是硬编码路径,则可以保留 .classpath。这很有用,因此您不必每次检出项目时都重新构建类路径。