Java 项目:应该将 .classpath .project 文件提交到存储库中吗? [英] Java project: should .classpath .project file be committed into repository?

查看:38
本文介绍了Java 项目:应该将 .classpath .project 文件提交到存储库中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该检入我的 .project 和 .classpath 文件吗?

Should I check in my .project and .classpath files?

我的朋友告诉我,我应该只检查 .java 文件和 build.xml 以保证可移植性.他说.classpath 会导致你在不同环境中的可移植性大大降低..project 完全是你本地的 eclipse 设置"

My friend told me that I should only check in .java files and the build.xml to guarantee portability. He said ".classpath will cause you much less portability on different environment. .project is entirely your local eclipse setting"

我同意他的观点,但部分同意.

I agree with him, but partially.

-- 不签入 .project 文件会使我的开发效率降低(我不能简单地从目录导入"项目代码)

-- Not checking in .project file will make my development less efficient (I can't simply "import" a project code from a directory)

-- 如果我仔细编写了 build.xml,不检查 .classpath 文件对我来说似乎没问题(?).

-- Not checking in .classpath file seems OK to me (?) if my build.xml is written carefully.

有人想在这里分享他们的经验吗?

Anyone wants to share their experience here?

推荐答案

检查 .project.classpath 没有任何问题.如果您的 build.xml 无法为您创建这两个文件,我会这样做.正如您所说,当您尝试创建新的 Eclipse 工作区时,错过这些文件会让人不舒服.

There is nothing wrong with checking in .project and .classpath. I would do so, if your build.xml isn't able to create both of the files for you. As you said, it's uncomfortable to miss these files when you try to create a new eclipse workspace.

在您签入 .classpath 之前,您应该确保其中没有绝对路径.使用文本编辑器将其转换为相对的.

Before you check in .classpath you should be sure that there is no absolute path in it. Convert it into a relative one with a text editor.

或者更好的是,在其他绝对路径中使用 eclipse 类路径变量,如@taylor-leese 评论.

Or even better, use eclipse classpath variables in your otherwise absolute pathes, like @taylor-leese commented.

这篇关于Java 项目:应该将 .classpath .project 文件提交到存储库中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆