Run gradle task from condition
<p>I am relatively new to gradle so please be patient with me.
My build.gradle:</p>

<pre><code>def releaseBol = false

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    lintOptions {
        abortOnError false
    }

    ...
    if (project.hasProperty('RELEASE') &amp;&amp; project.ext.RELEASE == '1')
        releaseBol = true


    if (releaseBol)
    {
       ..
       //some code
       ..

    }

}

...

task runScheduleReader()  {
    javaexec {
        println 'here1'
        main="-jar";
        args = [
                "../Generator.jar"

        ]
    }
}
</code></pre>

<p>What I wish to is to run <code>runScheduleReader</code> if <code>releaseBol</code> is set to <code>true</code>, but I get an error when just moving it there, how can I do this?</p>