简体   繁体   English

将Eclipse项目签入SVN

[英]Checking in an Eclipse project into SVN

I want to checkin a Dynamic Web Project I created in eclipse into svn. 我想检查我在eclipse中创建的动态Web项目到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. 我们的想法是能够使用“新建项目向导”检出项目,以便我可以再次创建动态Web项目。 More specifically here are the files/directories I have in the project -- 更具体地说,这是我在项目中的文件/目录 -

  • src SRC
  • WebContent 网页内容
  • build 建立
  • dist DIST
  • build.xml build.xml文件
  • .project 。项目
  • .classpath 的.classpath
  • .settings/ .settings /

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)? 另外eclipse在哪里存储服务器信息(tomcat)? I don't want to check it in either. 我也不想检查它。

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. 当我从Eclipse内部检出项目时,它并没有提示我创建一个新项目,因为.project在那里,但是Eclipse正在创建一个JavaEE项目,而不是动态Web项目。 Did anyone else run into this behavior? 有没有其他人遇到这种行为?

** EDIT 2 ** **编辑2 **

Found it! 找到了! Turns out I should not check in the following -- 事实证明我不应该检查以下内容 -

  • .project 。项目
  • .settings/ .settings /
  • .classpath 的.classpath

Once these 3 are removed the New project Wizard works as expected and everything is fine. 删除这3个后,新项目向导按预期工作,一切正常。

If you check in .classpath/.project/.settings you make your project Eclipse-specific. 如果您签入.classpath/.project/.settings可以使项目特定于Eclipse。 What about developers who work with Netbeans or IntelliJ ? 那些使用NetbeansIntelliJ开发人员呢? IMO it is cleaner to keep your project IDE-independent and easy to set up. IMO让您的项目独立于IDE并且易于设置更清晰。

I usually go for a Maven build. 我通常会去Maven构建。 The pom.xml specifies all the required dependencies and mvn eclipse:eclipse generates the .classpath/.project files for you. pom.xml指定了所有必需的依赖项和mvn eclipse:eclipse为您生成.classpath/.project文件。

The .settings directory contains local settings (like which Java version you want to use). .settings目录包含本地设置(例如您要使用的Java版本)。 IMO it is not useful to check this in. You can enforce Java version compliance via the Maven2 pom. 在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 before your first commit. 最后,对于你的下一个项目,我的protip是你第一次提交之前 svn- svn-ignore你不想在SVN中使用的文件或目录。 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). 在Maven2设置中,它将是.settings .classpath .project target (Maven2的默认输出目录)和任何其他生成的东西(日志文件,gfembed目录等)。 In your case you would ignore build and dist instead of target . 在你的情况下,你会忽略builddist而不是target

You can svn-ignore files or directories with RIGHT_MOUSE->Team->'Add to svn:ignore' (I use the Subclipse plugin). 您可以使用RIGHT_MOUSE->Team->'Add to svn:ignore' (我使用Subclipse插件) svn-ignore文件或目录。 Ignore instructions are stored as svn-properties on the parent directory. 忽略指令在父目录中存储为svn-properties The properties on a directory can be viewed by RIGHT_MOUSE->Team->Show properties . 可以通过RIGHT_MOUSE->Team->Show properties查看目录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. 确保每个属性后都有一个行尾。

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; 不知何故,我从未设法成功忽略已经检入SVN存储库的生成文件; 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回购中删除他们的条目,这可以实现,但我从来没有做过。

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; 通过签入.classpath.project ,用户可以快速签出项目并在新计算机上启动Eclipse,然后开始处理它; the alternative being to configure the project manually and adding in all the jar dependencies painstakingly (if you use ant). 另一种方法是手动配置项目并精心添加所有jar依赖项(如果使用ant)。 Many open source projects do this. 许多开源项目都是这样做的。

Read this , there are some really good points to ponder about. 阅读本文 ,有一些非常好的思考点。

Good Question... Many of us are in a dilemma on whether we want to check in IDE related files or not. 好问题......我们中的许多人是否想要检查IDE相关文件处于两难境地。 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. 我通常会去检查eclipse中的.classpath,并使用eclipse变量来确保团队只需要更改变量值就行了。 We also check in .project so that team need not to create new project in their workspace. 我们还检查.project,以便团队不需要在他们的工作区中创建新项目。

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. 如果使用变量而不是硬编码路径,则可以保留.classpath。 This is useful so you don't have to rebuild your classpath every time you check out the project. 这很有用,因此每次签出项目时都不必重建类路径。

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

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