Cordova Build - ignore files

olanod picture olanod · Jan 15, 2014 · Viewed 7.5k times · Source

When compiling a cordova application every single file in my /www folder gets copied to the assets/www folder(android) but I'd like to customize what files are copied. I use several pseudo languages like CoffeeScript, Jade or Stylus which are auto-compiled by my IDE and they shouldn't be shipped into the final application.

Answer

gustavohenke picture gustavohenke · Dec 2, 2014

With the help of this article, I found that you can create/edit the platform/android/ant.properties, and add the following line to it:

aapt.ignore.assets=!*.map:!thumbs.db:!.git:.*:*~

With this line, any file or directory that matches one of these patterns will not be included in the .apk file:

  • *.map
  • thumbs.db
  • .git
  • .*
  • *~

I found that editing the platforms/android/build.xml won't work because it's overwritten each time the build is invoked; also, creating a build.xml file in the root of the project didn't work.

The rules for this property are the following, taken from $ANDROID_HOME/tools/ant/build.xml:

<!-- 'aapt.ignore.assets' is the list of file patterns to ignore under /res and /assets.
         Default is "!.svn:!.git:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~"

         Overall patterns syntax is:
           [!][<dir>|<file>][*suffix-match|prefix-match*|full-match]:more:patterns...

         - The first character flag ! avoids printing a warning.
         - Pattern can have the flag "<dir>" to match only directories
           or "<file>" to match only files. Default is to match both.
         - Match is not case-sensitive.
    -->
    <property name="aapt.ignore.assets" value="" />