Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial .hgignore for Android Studio projects

What files should be ignored in Mercurial when using Android Studio (1.0 RC4 Windows) for development?

Creating new application project also creates .gitignore file. I have translated that to following .hgignore file

syntax: glob
.hgignore
.gradle
local.properties
.idea/workspace.xml
.idea/libraries
.DS_Store
build

But when I do Add to VCS for my project, some files that are not in ignore list are not being added to Mercurial. Files left out are:

.idea\.name
.idea\compiler.xml
.idea\copyright\profiles_settings.xml
.idea\encodings.xml
.idea\gradle.xml
.idea\misc.xml
.idea\modules.xml
.idea\scopes\scope_settings.xml
.idea\vcs.xml
build.gradle
MyApplication.iml
gradle.properties
gradle\wrapper\gradle-wrapper.jar
gradle\wrapper\gradle-wrapper.properties
gradlew
gradlew.bat
settings.gradle

Should I add those files to ignore list, or should I add them to VCS?

It is also unclear what should be done with .iml files. Adding project to Mercurial using AS will add app\app.iml file, but adding project to Git using AS will leave that file untracked.

I don't want to track superfluous files in VCS, but I don't want to miss storing important ones. There are numerous sources on which files should be tracked, but information differs so greatly it is hard to make any definite conclusion.

Update: final version of my .hgignore file

syntax: glob
.hgignore
.gradle
local.properties
.idea
.DS_Store
build
*.iml
gradlew
gradlew.bat

For sharing project among developers following files have to be commited to VCS or AS will not be able to import project on another machine:

gradle.properties
gradle\wrapper\gradle-wrapper.jar
gradle\wrapper\gradle-wrapper.properties
like image 751
Dalija Prasnikar Avatar asked Dec 05 '14 08:12

Dalija Prasnikar


2 Answers

This is what I ended up with for gradle based Android Studio (1.5) projects:

syntax: glob
*.iml
.gradle
.idea/dictionaries
.idea/libraries
.idea/tasks.xml
.idea/workspace.xml
build
gen
local.properties

I think this is a very complete list. The only questionable option imho is whether you ignore *.iml files or not. They duplicate information from build.gradle, are automatically generated and constantly updated by Android Studio, but on the other hand new developers will need to "Import project" instead of "Open an existing Android Studio project" if you decide not to track them.

Contrary to the other answer, I would strongly recommend checking all the gradle wrapper files into VCS. The wrapper's purpose is to bootsrap the installation of gradle. If you for example want to set up automatic builds, you only need to check out the project, create local.properties or corresponding environment variables and execute gradlew assemble. The build system will then automatically install the gradle version specified in your gradle-wrapper.properties to perform the assemble task. This is valuable information to share.

Also check this official JetBrains Support article: https://intellij-support.jetbrains.com/hc/en-us/articles/206827587-How-to-manage-projects-under-Version-Control-Systems

like image 89
Nappy Avatar answered Oct 11 '22 05:10

Nappy


By dint of .ignore plugin you can generate .hgignore just in two clicks. Open the context menu on a root folder, select 'New >> .ignore file >> .hgignore'. Then for Android Studio project simply tick the checkboxes (templates) listed below:

  • Android
  • Gradle (optional)
  • JetBrains
  • AppEngine (optional)

Add syntax: glob to the top of the generated file.

like image 28
naXa Avatar answered Oct 11 '22 04:10

naXa