Linux 用于 Eclipse 和 Android 开发的 Mercurial 忽略文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3677245/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 23:28:34  来源:igfitidea点击:

Mercurial ignore-file for Eclipse and Android development

androideclipsemercurialhgignore

提问by Julian

I have seen samples for Mercurial ignore files for Visual Studio, amongst others.

我已经看到了用于Visual Studio等的Mercurial 忽略文件的示例。

I've just started playing around with Android development, and I also use this time to experimenting with Mercurial. So my question is: does anyone have a good example of a .hgignorefile to use for Eclipse and Android development?

我刚刚开始玩 Android 开发,我也利用这段时间尝试使用 Mercurial。所以我的问题是:有没有人有一个很好的.hgignore文件示例用于 Eclipse 和 Android 开发?

For starters I've got the following myself:

对于初学者,我自己有以下内容:

# use glob syntax
syntax: glob

# Ignore patterns
.metadata\
bin\
gen\

Are there any other ignore patterns that should be included? Should for instance the Eclipse files .classpathand .projectbe omitted from version control as well?

是否应该包含其他任何忽略模式?例如 Eclipse 文件是否.classpath.project应该从版本控制中省略?

-- Edit below --

-- 下面编辑 --

I haven't quite gotten the answers I hoped for yet, so I'll put out a bounty and try to specify a bit clearer what I'm looking for.

我还没有得到我希望的答案,所以我会悬赏并尝试更清楚地说明我在寻找什么。

After experimenting a bit myself, I seem to have found that the suggested .hgignorelisted above seems to be sufficient. The only addition I've made, is one line with .settings(this was a folder that appeared after I ran Android Tools -> Fix Project Properties). I've also found that (as mentioned by Ry4an) that the Eclipse files .classpathand .projectshould notbe excluded.

经过我自己的一些实验,我似乎发现.hgignore上面列出的建议似乎就足够了。我所做的唯一添加是一行.settings(这是我运行Android Tools -> Fix Project Properties后出现的文件夹)。我还发现,(由Ry4an提到的),因为Eclipse文件.classpath.project应该被排除在外。

I am however uncertain that this small ignore file will be sufficient when I get to projects a bit bigger than the basic tutorials (if it actually isall good, please explain why, and you'll get the credit). So to summarize what I'm looking for:

不过,我不确定这个小忽略文件就足够了,当我到达项目比基本教程大一点(如果它实际上都好,请解释原因,你会得到信贷)。所以总结一下我在找什么:

  • I want a concrete example for a .hgignorefile for an Android project under Eclipse
  • The ignore file should be so that whenever I check out a copy of the repository at a new location, it should work straight away (i.e. without having to mess with paths and references, add missing files etc.)
  • Please also explain whyyour include file looks like it does (I want to understand why certain files/directories are excluded (and why some definitely should be included))
  • If you include OS specific excludes, please also state so (I'm running on Windows 7 btw.)
  • 我想要一个.hgignoreEclipse 下 Android 项目文件的具体示例
  • 忽略文件应该是这样,每当我在新位置检出存储库的副本时,它应该立即工作(即不必弄乱路径和引用,添加丢失的文件等)
  • 还请解释为什么您的包含文件看起来像它(我想了解为什么排除某些文件/目录(以及为什么肯定应该包含某些文件))
  • 如果您包含特定于操作系统的排除项,请同时说明(顺便说一句,我在 Windows 7 上运行。)

采纳答案by Ry4an Brase

The eclipse files should definitely be added. The general guideline is to add:

绝对应该添加 eclipse 文件。一般准则是添加:

  • everything that is hand written/typed
  • the minimal subset of everything else necessary to build the project
  • 手写/打字的一切
  • 构建项目所需的所有其他内容的最小子集

That last one is where your judgement comes in. It clearly excludes the .jar files you build yourself and your final .apk, but does it include third party .jar's you use? Some people do include them, but better is to include a configuration file for a dependency manager like 'ivy' which lets the next builder download the requirements they need automatically.

最后一个是您判断的依据。它显然不包括您自己构建的 .jar 文件和最终的 .apk,但它是否包括您使用的第三方 .jar 文件?有些人确实包含它们,但更好的是包含一个像“ivy”这样的依赖管理器的配置文件,它让下一个构建器自动下载他们需要的需求。

After auto-creating a project in my tools of choice, I'll just do a command like this:

在我选择的工具中自动创建一个项目后,我将执行如下命令:

hg status --unknown --no-status >> .hgignore

which adds the list of all unknown files to .hgignore. Then I go in and remove things I wants saved (ex: .project) and wildcard files that will grow siblings (ex: **.class)

它将所有未知文件的列表添加到 .hgignore。然后我进入并删除我想要保存的内容(例如:.project)和将增加兄弟姐妹的通配符文件(例如:**.class)

回答by Fred Grott

well if its android projects than

好吧,如果它的 android 项目比

local.properties should also be ignored

local.properties 也应该被忽略

回答by Andrew

Here is my hgignore:

这是我的 hgignore:

syntax: regexp
\.DS_Store
.swo
.swp
.metadata/
/bin/

Whether it's a good one or not is a separate issue

好不好是另外一回事

回答by codingatty

There's a very nice sample .hgignore for Android at http://androidfragments.blogspot.com/2011/11/hgignore-for-android.html

http://androidfragments.blogspot.com/2011/11/hgignore-for-android.html 上有一个非常好的 Android 示例 .hgignore

回答by Andrey Epifantsev

I have found a good example of .hgignore. It works for me.

我找到了 .hgignore 的一个很好的例子。这个对我有用。

#Mercurial Ignore Rules for Android
#Save as .hgignore in the repository base directory and add it to source control.
syntax: glob
*.class
*.apk
*.dex
*.ap_
*.suo

syntax: regexp
^(.*[\/])?gen[\/].*
^(.*[\/])?bin[\/].*
^(.*[\/])?obj[\/].*
^(.*[\/])?log[\/].*
^(.*[\/])?obf[\/].*
^(.*[\/])?jars[\/].*
^(.*[\/])?jar-sources[\/].*
^(.*[\/])?javadoc[\/].*
^(.*[\/])?\.svn[\/].*
^(.*[\/])?\.metadata[\/].*
^(.*[\/])?\.settings[\/].*

Source: http://androidfragments.blogspot.ru/2011/11/hgignore-for-android.html

来源:http: //androidfragments.blogspot.ru/2011/11/hgignore-for-android.html