title: Intellij + Gradle: properties file
body: <p>My configuration:</p>
  
  <p>Gradle installed via Homebrew (Mac OS), Intellij Idea 13.</p>
  
  <p>Preferences:</p>
  
  <p>"Use default Gradle wrapper"
  and gradle home: <code>/Users/my_username/.gradle</code></p>
  
  <hr>
  
  <p>For the following project:</p>
  
  <pre><code>/
   build.gradle
   gradle.properties
  </code></pre>
  
  <p>The gradle.properties file contains a variable <code>NAME = PJ</code>.
  I also have a gradle.properties under <code>/Users/my_username/.gradle/gradle.properties</code> having a variable <code>TEST=Hello</code>.</p>
  
  <p>For the given task, gradle prints Hello and null</p>
  
  <pre><code>task hello &lt;&lt; {
      println TEST
      println NAME
  }
  </code></pre>
  
  <p>Which means that it does not read by default the gradle.properties in the same directory. Is it a normal behavior or do I miss something in path variable so can the build.gradle script can read it?</p>
  
  <p>A work-around I found is to add:</p>
  
  <pre><code>file("gradle.properties").withInputStream {
      stream -&gt; new Properties().load(stream)
  }
  </code></pre>
  
  <p>When I used android studio the .properties file of the same dir was automatically imported.</p>
  
  <p>PS: Although TEST var gets printed I get a warning for <code>Cannot resolve symbol</code>. I saw around and this is typical error (?).</p>