How to replace token in taglibs tld file?

When generating my jar file I would like to replace some tokens in my .tld file

jar {
    manifest.attributes["Created-By"] = "${System.getProperty("java.version")} (${System.getProperty("java.specification.vendor")})"
    manifest.attributes["Implementation-Title"] = project.name
    manifest.attributes["Implementation-Version"] = project.version
    from("${rootProject.projectDir}/src/dist") {
        include "LICENSE"
        include "NOTICE"
        into "META-INF"
        expand(copyright: new Date().format("yyyy"), version: project.version)
    }
    from("${rootProject.projectDir}/src/main/resources/META-INF") {
     include "my.tld"
     into "META-INF"
     expand(version: project.version)
    }
}

I tried something like above, but it results in 2 my.tld files in the META-INF of my jar file.

What’s the best approach to replace the tokens?

^M