title: Checking that Gradle system properties have been set
body: <h1>The Question</h1>
  
  <p>How do I check to see if a System property has been properly set from within a <code>build.gradle</code> file?</p>
  
  <h1>The Situation</h1>
  
  <p>I have a <code>gradle.properties</code> file in my root directory that looks something like this:</p>
  
  <pre><code>systemProp.user=exampleUsername
  systemProp.password=examplePassword
  </code></pre>
  
  <p>I would like to validate the existence of these properties, something like:</p>
  
  <pre><code>if (!System.hasProperty('user')) {
        throw new InvalidUserDataException("No user found in `gradle.properties`; please set one.")
  }
  </code></pre>
  
  <h1>Some Code</h1>
  
  <p>I've tried the following:</p>
  
  <ul>
  <li><p><code>project.hasProperty('user')</code> returns <code>false</code></p></li>
  <li><p><code>System.properties.get('user')</code> returns <code>exampleUsername</code></p></li>
  <li><p><code>System.hasProperty('user')</code> returns <code>null</code></p></li>
  <li><p><code>System.properties.get('user') == true</code> returns true for non-falsey
  values</p></li>
  </ul>