Why does ant task get executed while project is evaluated?

I have multiple projects and one of the project’s buld.gradle has ant task.
While evaluating the project, it is observed that ant task is getting executed.
How should we restrict it?

I am using
gradle 6.0.1
Java 11

My build.gradle is like this

println “Project directory name: $name”
FileCollection ia_task_lib = files( “$install_anywhere_home/resource/build/iaant.jar” )
FileCollection runtime_inclusions = files ( “$rootDir/…/lib/log4j.jar”,
“$rootDir/…/lib/CommonCore.jar”,
“$rootDir/…/lib/InstallerSupport.jar”,
“$rootDir/…/lib/InstallUtil.jar”,
“$rootDir/…/lib/mksapi.jar”,
“$rootDir/…/lib/com.dynatrace.diagnostics.sdk.jar”,
“$rootDir/…/lib/OracleThinDrivers.jar”,
“$rootDir/…/lib/sqljdbc4.jar”,
“$rootDir/…/lib/ucp.jar”,
“$rootDir/…/lib/WtLogR.jar”,
“$rootDir/…/lib/PSMJavaValidation.jar”,
“$rootDir/…/lib/json-20160212.jar”,
“$rootDir/…/lib/jackson-databind-2.6.1.jar”)

configurations {
antcp
inclusionary
}

dependencies {
println “NOW INTO PSM_IA dependencies”
compile project(’:PSMInstallationBundle’)
compile project(’:PAAgent’)
antcp ia_task_lib
inclusionary runtime_inclusions

testCompile files(
“$rootDir/…/lib/PAAgentConfig/testng-6.9.10.jar”,
“$rootDir/…/lib/PAAgentConfig/jcommander-1.48.jar”)
println “NOW EXITING PSM_IA dependencies”
}

jar {
println “NOW INTO PSM_IA JAR”
dependsOn configurations.inclusionary
from { configurations.inclusionary.collect { it.isDirectory() ? it : zipTree(it) } }
println “NOW EXITING PSM_IA JAR”
}

task definition_of_install_anywhere_tasks {
ClassLoader acl = ant.class.classLoader
configurations.antcp.each {
acl.addURL(it.toURI().toURL())
}

println “ANT CLASSPATH: ${configurations.antcp.asPath}”

ant.taskdef(name: ‘ia_builder’,
classname: ‘com.zerog.ia.integration.ant.InstallAnywhereAntTask’,
classpath: configurations.antcp.asPath
)

//define another task by xsu
ant.taskdef(name: ‘ia_builder2’,
classname: ‘com.zerog.ia.integration.ant.InstallAnywhereAntTask’,
classpath: configurations.antcp.asPath
)
}

task ia_build(dependsOn: [’:PAAgent:jar’,‘definition_of_install_anywhere_tasks’]) {
ant.ia_builder(IALocation: “$install_anywhere_home”,
iaProjectFile: “$projectDir/PSM_IA.iap_xml”,
failOnError: ‘true’,
BuildOutputLocation: “$projectDir/build/libs”,
BuildWorkdirLocation: “$projectDir/build/libs”,
BuildLinuxWithVM: ‘false’,
BuildLinuxWithoutVM: ‘true’,
BuildHPUXWithVM: ‘false’,
BuildHPUXWithoutVM: ‘true’,
BuildAIXWithVM: ‘false’,
BuildAIXWithoutVM: ‘true’,
BuildSolarisWithVM: ‘false’,
BuildSolarisWithoutVM: ‘true’,
BuildNamedUnixWithVM: ‘false’,
BuildNamedUnixWithoutVM: ‘true’,
BuildWindowsWithVM: ‘false’,
BuildWindowsWithoutVM: ‘true’,
BuildPureJava: ‘true’,
OverrideAllPlatformSettings: ‘true’
)
}