title: Executing custom Gradle task using scripts
body: <p>How to write the task in the build.gradle which will execute this code:</p>
  <pre><code>**gradle hideSecret -Pkey=test123456 -PkeyName=YourSecretKeyName**
  </code></pre>
  <p>I use this lib: <a href="https://github.com/klaxit/hidden-secrets-gradle-plugin" rel="nofollow noreferrer">https://github.com/klaxit/hidden-secrets-gradle-plugin</a>
  and I want to make the hideSecrets automatically in pre build.</p>
  <p>Smth like this:</p>
  <pre><code>task hideSecret {
      doLast {
          exec {
              workingDir &quot;${rootDir}&quot;
              commandLine &quot;hideSecret -Pkey=${key} -PkeyName=${keyName}&quot;
          }
      }
  }
  
  afterEvaluate {
      tasks.getByName(&quot;preBuild&quot;).dependsOn(&quot;hideSecret&quot;)
  }
  </code></pre>