title: Gradle println prints when it is not called
body: <p>My goal is to have a message printed to the console whenever the <code>idea</code> task is run, but unfortunately the message is printed whenever anything is run. Why are the print lines executing when the <code>idea</code> task is not being run? How can I display a message only when the <code>idea</code> task is executed? </p>
  
  <p>build.gradle</p>
  
  <pre><code>apply plugin: 'idea'
  
  task hello &lt;&lt; {
      println 'Hello world!'
  }
  
  tasks.idea() {
      println '*********************************************************'
      println '* You should open build.gradle as a native project from *'
      println '* within IntelliJ.                                      *'
      println '*********************************************************'
  }
  </code></pre>
  
  <p>Output of the command <code>gradle hello</code></p>
  
  <pre><code>*********************************************************
  * You should open build.gradle as a native project from *
  * within IntelliJ.                                      *
  *********************************************************
  :hello
  Hello world!
  
  BUILD SUCCESSFUL
  
  Total time: 2.846 secs
  </code></pre>
  
  <p><strong>Working Solution</strong></p>
  
  <pre><code>tasks.getByPath('idea') &lt;&lt; {
      println '*********************************************************'
      println '* You should open build.gradle as a native project from *'
      println '* within IntelliJ.                                      *'
      println '*********************************************************'
  }
  </code></pre>