Could not get property unknown property '' for a task
<p>Working to get Gradle to generate a CSV file and trying to create properties for my build.gradle file that can be passed in from the command line.</p>

<p>I've inserted the following into gradle.properties:</p>

<pre><code>userCount=100
</code></pre>

<p>In my build.gradle file</p>

<pre><code>    task writeUsersFile &lt;&lt; {
    if (project.hasProperty('userCount')){
        args = getProperty(userCount)
    }
    outputFile.withWriter { out -&gt;
    1.upto($userCount) {
      out.println(String.format(userNameFmt, it, testPassword))
    } 
  } 
}
</code></pre>

<p>When I run the Gradle process via the command line I encounter the following:</p>

<pre><code>Could not get unknown property '100' for task ':writeUsersFile' of type org.gradle.api.DefaultTask.
</code></pre>

<p>If I pass the parameter in from the command line, it's appropriately updating the error from the default of '100' to the value I'm passing. </p>

<p>Have also tried:</p>

<pre><code>task writeUsersFile &lt;&lt; {
    userCount = project.hasProperty('userCount') ? project.userCount : ''
    outputFile.withWriter { out -&gt;
    1.upto($userCount) {
      out.println(String.format(userNameFmt, it, testPassword))
    }
  }
}
</code></pre>

<p>and that results in:</p>

<pre><code>Could not get unknown property '$userCount' for task ':writeUsersFile' of type org.gradle.api.DefaultTask.
</code></pre>

<p>The writing of the file is working fine if I define <code>userCount=100</code> (or whatever arbitrary number) directly in my build.gradle, the roadblock is setting the argument for the # of users.</p>