Preprocessing source in Gradle builds

(Russel Winder) #1

What is the correct way of running a Gradle preprocess over Groovy source that is preprocessed with in an Ant build?

(Peter Niederwieser) #2

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)’).

(Russel Winder) #3

Thanks for the confirmation that this is the official right way.

The biggest problem was replacing the sourceSet rather than adding to it :slight_smile:

Sorry for the delay in getting back to you, but you know how much I hate forums.