title: Gradle set property in custom task
body: <p>I have a gradle task which runs some code checks, which is usually executed during build.
  Since this tasks takes a long time, I implemented a flag so that it is not run during normal build, but needs to be enabled via a property:</p>
  
  <pre><code>tasks.withType(MyTaskType) {
      //config switch "-Pcheck=true"
      enabled = project.getProperties().getOrDefault('check', false).equals('true')
  }
  </code></pre>
  
  <p>Now I can start it in the terminal via: <code>./gradlew build -Pcheck=true</code></p>
  
  <p>Now I also want to have a task "buildWithCheck", which sets this property and then executes the build task.</p>
  
  <p>How can I do this? What I tried:</p>
  
  <pre><code>task buildWithCheck {
    doFirst{
      project.getProperties().put('check','true')
    }
    dependsOn tasks['build']
  }
  </code></pre>