How Do I Convert an Ant Execution of Groovy Class in Gradle?

I am trying to migrate an existing Ant build to a Gradle build for a project based on Groovy.

I’m having problems with converting the segment below from a groovy-tasks.xml file into my build.gradle file:

<target name="template" depends="createjson">
        <groovy>
            <classpath>
                <pathelement location="classes"/>
                <pathelement location="src"/>
            </classpath>
            import com.mycompany.template.TemplateCreator
            def tc = new TemplateCreator()
            tc.main()
        </groovy>
    </target>

I have tried ant.importBuild ‘groovy-tasks.xml’ and then running gradle template, but I receive an error saying “There should not have been any compilation from this call”.

Is there a native way to do this in Gradle without Ant? If not, I’m okay with using ant.importBuild somehow to make it work.