Eclipse project.properties反斜杠路径被认为是有害的

ste*_*eha 9 eclipse mercurial path backslash

我正在开发一个正在开发Android软件的团队.一些团队成员使用Windows,一些人使用Mac,我知道使用Linux.每个人都使用Eclipse.

Eclipse写了一个名为的文件project.properties; 这是一个例子.最重要的部分是最后三行,即android库引用路径.

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-17
android.library.reference.1=../private-code/lib/SomeLibrary
android.library.reference.2=../google-play-services_lib
android.library.reference.3=../FacebookSDK
Run Code Online (Sandbox Code Playgroud)

以上是Mac或Linux上的Eclipse编写文件时的文件.当Windows上的Eclipse写入时,库引用行使用反斜杠写入.

当然在Windows上,反斜杠是可接受的路径分隔符.但是在Mac和Linux上,这样的路径不起作用.问题是,在Windows上,正斜杠工作得非常好.因此,我们的策略现在始终是使用正斜杠提交文件,以便它适用于所有人.

但这对我们的Windows用户来说是一种痛苦,当Windows用户犯了错误时,对我们其他人来说是一种痛苦,所以我正在寻找一种技术解决方案.我有两个想法:

  • 在Windows上的Eclipse中查找某个设置,告诉它在保存文件中的路径时使用正斜杠project.properties.(为什么这不是默认的?!?)

  • 我们使用Mercurial,因此:安装一些可以解决问题的"钩子".

    • 在Windows计算机上安装提交挂钩,以便将文件提交到存储库中,并使用正斜杠替换反斜杠.
    • 在Mac和Linux计算机上安装拉钩; 因此,如果文件以反斜杠提交,则在写入文件时它们会被修复.

提交钩子看起来更干净,所以如果两者都可用,我会在一个拉钩上取一个提交钩子.

我找到了一个Mercurial扩展,它将标签编辑到空格,这至少与我想要的类似.这很复杂,我有点怀疑尝试将其修改为我需要的东西.

https://www.mercurial-scm.org/wiki/CheckFilesExtension

另一种策略是添加一个检测路径中反斜杠的钩子,并简单地中止提交,强制Windows用户在提交之前手动修复文件.那比没有好.

ian*_*its 0

由于本地库的路径各不相同,我们遇到了类似的情况,因此经过一段时间的搜索,我们发现使用集中存储库工具(Git for us)的最佳实践是“从存储库中删除所有 eclipse 依赖/特定设置文件”。这对我们来说效果很好。这样,对 Eclipse 设置文件的更改将不会影响中央存储库或被提交。