Mercurial ignore-file for Eclipse and Android development

10,159

Solution 1

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

  • 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.

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)

Solution 2

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

Solution 3

Here is my hgignore:

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

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

Solution 4

well if its android projects than

local.properties should also be ignored

Solution 5

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

#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

Share:
10,159
Julian
Author by

Julian

Software Craftsman

Updated on June 14, 2022

Comments

  • Julian
    Julian about 2 years

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

    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 .hgignore file to use for Eclipse and Android development?

    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 .classpath and .project be omitted from version control as well?

    -- 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 .hgignore listed 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 .classpath and .project should not be excluded.

    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 is all 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 .hgignore file 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 why your 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.)
  • Julian
    Julian almost 14 years
    +1: The hg status --unknown --no-status >> .hgignore seems like a nice trick, thanks :) As I'm fairly new with Android development, I was however hoping for a comprehensive and concrete example - as you point out, the second point of the two is the hard part.
  • Julian
    Julian almost 14 years
    +1 for a specific example. I will however wait a bit for more answers/comments before accepting, to better tell whether it's a good one or not;)
  • Tim Pietzcker
    Tim Pietzcker almost 14 years
    Shouldn't you be escaping the dots in lines 3-5?
  • Julian
    Julian almost 14 years
    The Android-specific `gen` folder is at least missing from this one, that I'm sure of.
  • Julian
    Julian over 13 years
    Just for future references (and, as it would be a shame to late the bounty go to waste ;): even though not completely specific, this answer provided what I found to be the most useful. As for a full example, I ended up using what I wrote in the original post (and that seems to be sufficient, after some weeks of experimenting).
  • Brill Pappin
    Brill Pappin about 10 years
    I think local.properties if from Android Studio.
  • Brill Pappin
    Brill Pappin about 10 years
    Are you using glob or regex?