title: How to determine if a Gradle task was instantiated (Configuration Avoidance API)
body: <p>I am trying to improve the performance of our Gradle builds and discovered the Gradle Task Configuration Avoidance API (<a href="https://docs.gradle.org/current/userguide/task_configuration_avoidance.html" rel="nofollow noreferrer">https://docs.gradle.org/current/userguide/task_configuration_avoidance.html</a>). It allows to postpone the creation and configuration of a task, unless it is really needed. This might save a lot of startup time and as we call Gradle multiple times during a build, this could amount to considerable time savings.</p>
  
  <p>We developed some plugins for internal use and I put an effort into changing how I define the tasks to avoid creation when not needed. I want to test if my changes are successful and the task instantiation is delayed.</p>
  
  <p>Simple example of how to create a task without instantiating it:</p>
  
  <pre><code>class MyTask extends DefaultTask {
  }
  
  TaskProvider customTask = tasks.register("customAction", MyTask) {
      println "task configured!"  // configuration time output
      doLast {
          println "action 1!"    // execution time output
      }
  }
  
  // configuration like this avoids task instantiation
  tasks.named("customAction") {
      doLast {
          println "action 2!"
      }
  }
  
  tasks.withType(MyTask).configureEach {
      doLast {
          println "action 3!"
      }
  }
  </code></pre>
  
  <p>Executing <code>gradle help</code> does not print the "task configured!" message, while <code>gradle customAction</code> does.</p>
  
  <p>To make sure I do not accidentally trigger task instantiation, I would like to write tests for our plugins. But I could not find a way to determine if a task is instantiated or not.</p>
  
  <p>I know about Build Scans (<a href="https://guides.gradle.org/creating-build-scans/" rel="nofollow noreferrer">https://guides.gradle.org/creating-build-scans/</a>), but our corporate guidelines are strict and clearance is pending, so I can not use it for now. Also, I do not see a way to use it in tests.</p>
  
  <p>Is there a way to</p>
  
  <ul>
  <li>get a list of created/instantiated tasks from the Gradle project?</li>
  <li>or is there any property on Task or TaskProvider showing whether the task has been created/instantiated?</li>
  <li>or can buildscans be used offline somehow?</li>
  </ul>
  
  <p>It would be cool, if the solution could be used in the plugin's test code, but manual evaluation would also be valuable.</p>