Including generated files in output jar

I’m trying to include a generated file in the jar artifact of a groovy build. I generate the file by using

def versionFilePath = "$buildDir/classes/version.config"
compile files(versionFilePath) {
 builtBy "generateVersionStamp"

but I cannot get it to be included in the output Jar. I’ve tried


with no luck. Any suggestions? Is there a better way to embed version information in an artifact?

You want:


That’s a fine strategy, unless you need this file on your test classpath.