6

I have a generated string resource xml file in my project which is generated from a file with a .template extension. I'm trying to exclude this template from the build since it gives me duplicate resource error. The following does not work for me and I'm stuck:

  sourceSets {
       main {
           manifest.srcFile 'AndroidManifest.xml'
           java.srcDirs = ['src']
           resources.srcDirs = ['res']
           resources.exclude '**/build_id.template'
           res.srcDirs = ['res']
           res.exclude '**/build_id.template'
           assets.srcDirs = ['assets']
       }
   }

The error:

Error:Error: Duplicate resources: <project-dir>/res/values/build_id.template:string/build_id, <project-dir>/res/values/build_id.xml:string/build_id

How can I exclude a particular resource file properly?

3k-
  • 2,467
  • 2
  • 23
  • 24

1 Answers1

0

For the sanity of other folks working on your project, I strongly discourage putting templates (input) and auto-generated files (output) in the same directory. You could create your own, independent 'templates' directory to keep it from being included in your build.

Jeff Brateman
  • 3,229
  • 2
  • 20
  • 26