title: Maven Resource Filtering Breaking Downloads
body: <p>I have a Maven/Java application. Part of the application allows you to download some documents. Here is the project setup.</p>
  
  <pre><code>+src
      +main
          +resources
              +downloads
                  MyDocument.docx
              jdbc.properties
  pom.xml
  </code></pre>
  
  <p>The downloads work correctly when <code>jdbc.properties</code> has the hardcoded values inside them. However, I am trying to update the application to use Maven profiles and specify the different database connections for the different environments. I manage to get it to work with the following in <code>pom.xml</code>.</p>
  
  <pre><code>&lt;build&gt;
      &lt;resources&gt;
          &lt;resource&gt;
              &lt;directory&gt;src/main/resources&lt;/directory&gt;
              &lt;filtering&gt;true&lt;/filtering&gt;
          &lt;/resource&gt;
      &lt;/resources&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>However, even though the <code>jdbc.properties</code> file gets correctly populated with the correct environment database information, the download feature stopped working. The file will be downloaded, but when you try to open it, it says <code>The file MyDocument.docx cannot be opened because there are problems with the contents.</code>.</p>
  
  <p>I tried changing the <code>&lt;directory&gt;</code> to <code>src/main/resources/*.properties</code> and adding an additional <code>&lt;resource&gt;</code> where I turn the <code>&lt;filtering&gt;</code> to false for <code>src/main/resources/downloads</code>. But neither approach worked.  How can I prevent the Maven filtering from corrupting the files?</p>
  
  <p>FYI - I looked inside the WAR and the documents cannot be opened from there either (they are already corrupt). </p>