Saturday, November 5, 2011

.hgignore for Android

If you use source control one of the first things you want to do is create an ignore rules file for binaries and auto generated files so they don't pollute check ins with useless changes.
Most developers out there use Mercurial and GIT for source control. Both of these systems are very similar and work fine for any project.

Here's the base .hgignore I've created over the course of making a few Android projects. This version is unique in that it will ignore the directories if your Android projects are placed in the root or in a subdirectory of the repository. It doesn't have that bug where a directory ending in an excluded directory's name also mistakenly get ignored. Like, should remain robin/ but bin/ is ignored.
#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[\\/].*

6 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. Thank you. Very nice. But wouldn't this exclude any 3rd party JARs? I know there are other ways to keep up with them but keeping them all in one place, especially keeping the version that the app is currently using, would see to be worth the little bit of extra space it could take up.

    ReplyDelete
  3. The 3rd party jars need to go into the \libs folder. \Jars shouldn't really be there but it is OK I will remove it from the post later. :)

    ReplyDelete
  4. Hi,

    Why didn't you include a build folder located in the SampleApp folder?
    SampleApp is the name of the application

    ReplyDelete