title: How to get property from gradle.properties
body: <p>If I set a property in my <code>gradle.properties</code> file using the command line like so: </p>
  
  <p><code>gradle build -Dproperty=myString</code></p>
  
  <p>and in my Android project have a <code>configuration.properties</code> in my resources directory, how can I get <code>configuration.properties</code> to read the new property from the <code>gradle.properties</code> file?</p>
  
  <p>I've tried the following setup:</p>
  
  <p><strong>gradle.properties</strong></p>
  
  <pre><code>property=defaultString
  anotherProperty=defaultBoolean
  </code></pre>
  
  <p><strong>configuration.properties</strong></p>
  
  <pre><code>myProperty=@property@
  </code></pre>
  
  <hr>
  
  <p><strong>POTENTIAL SOLUTION 1</strong></p>
  
  <p><em>Using a <code>configuration.properties</code> file for each flavor.</em></p>
  
  <p>The per-flavor resources sounded like a great idea, but I wanted to have a default list in <code>main</code>, and only override the properties needed. I have a lot of properties, and some flavors would only need to override one. So this does work, but is not ideal.</p>
  
  <hr>
  
  <p><strong>POTENTIAL SOLUTION 2</strong></p>
  
  <p><em>Using <code>buildConfigField</code> to pass what I need to the Java code.</em></p>
  
  <p>The problem here is that I have two modules: <code>app</code> and <code>api</code> - where <code>api</code> is a dependency of <code>app</code>. Setting a <code>buildConfigField</code> in the <code>app</code> <code>build.gradle</code> lets me access them in the <code>app</code> code, but I would also need to access it from the <code>api</code> module.</p>