In a nutshell, you would declare a Gradle task that calls the preprocessor via the Ant task, reconfigure ‘sourceSets.main.groovy.srcDirs’ to point to the output directory of that task, and add the necessary task dependencies (e.g. ‘compileGroovy.dependsOn(preprocessGroovySources)’).